-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { Enumerable } from './internal/Enumerable'; | ||
|
||
export default Enumerable; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import onErrorResumeNextFn from '../../static/onErrorResumeNext'; | ||
import { Enumerable } from '../../internal/Enumerable'; | ||
|
||
function onErrorResumeNext<TSource>(...sources: Iterable<TSource>[]): Enumerable<TSource> { | ||
return new Enumerable(onErrorResumeNextFn(...sources)); | ||
} | ||
|
||
Enumerable.onErrorResumeNext = onErrorResumeNext; | ||
|
||
declare module '../../internal/Enumerable' { | ||
namespace Enumerable { | ||
export function onErrorResumeNext<TSource>(...sources: Iterable<TSource>[]): Enumerable<TSource>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default function* onErrorResumeNext<TSource>(...sources: Iterable<TSource>[]) { | ||
for (const source of sources) { | ||
try { | ||
yield* source; | ||
} catch (error) { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as assert from 'assert'; | ||
import Enumerable from '../../src/'; | ||
|
||
describe('onErrorResumeNext()', () => { | ||
it('should creates a sequence that concatenates both given sequences', () => { | ||
const xs = { | ||
[Symbol.iterator]: function*() { | ||
yield 1; | ||
yield 2; | ||
throw new Error(); | ||
} | ||
}; | ||
const ys = { | ||
[Symbol.iterator]: function*() { | ||
yield 3; | ||
yield 4; | ||
throw new Error(); | ||
} | ||
}; | ||
assert.deepEqual(Enumerable.onErrorResumeNext(xs, ys).toArray(), [1, 2, 3, 4]); | ||
}); | ||
}); | ||
|