Skip to content

Commit

Permalink
fix(except): special treatment for string
Browse files Browse the repository at this point in the history
  • Loading branch information
rickardvh committed Dec 2, 2021
1 parent 7d46f15 commit 86faca3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/enumerable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ export class Enumerable<T> implements Iterable<T> {
*/
public except(iterable: Iterable<T>): this;
@parse((_thisRef: Enumerable<T>, itemOrIterable: T | Iterable<T>) => {
if (!Utils.isIterable(itemOrIterable)) {
if (!Utils.isIterable(itemOrIterable) || typeof itemOrIterable === 'string') {
return [(x: T) => x !== itemOrIterable];
}
const set = new Set(itemOrIterable as Iterable<T>);
Expand Down
4 changes: 2 additions & 2 deletions src/test/enumerable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1256,8 +1256,8 @@ describe('Enumerable', () => {
expect(new Enumerable([1, 2, 3]).except(0).toArray()).toEqual([1, 2, 3]);

jsc.assertForall(
jsc.array(jsc.nat), jsc.nat,
(xs: number[], a: number) =>
jsc.array(jsc.string), jsc.string,
(xs: string[], a: string) =>
!new Enumerable(xs).except(a).contains(a)
);
});
Expand Down

0 comments on commit 86faca3

Please sign in to comment.