-
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.
Use
core-js-pure
for iterator helpers (#24)
* Use core-js-pure * Update PR number for core-js-pure ports
- Loading branch information
Showing
93 changed files
with
1,271 additions
and
742 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
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
20 changes: 20 additions & 0 deletions
20
packages/integration-test/importDefault/iteratorDrop.test.ts
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,20 @@ | ||
import { iteratorDrop } from 'iter-fest'; | ||
|
||
test('iteratorDrop should work', () => { | ||
// Copied from https://github.com/tc39/proposal-iterator-helpers. | ||
function* naturals() { | ||
let i = 0; | ||
|
||
while (true) { | ||
yield i; | ||
|
||
i += 1; | ||
} | ||
} | ||
|
||
const result = iteratorDrop(naturals(), 3); | ||
|
||
expect(result.next()).toEqual({ done: false, value: 3 }); | ||
expect(result.next()).toEqual({ done: false, value: 4 }); | ||
expect(result.next()).toEqual({ done: false, value: 5 }); | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/integration-test/importDefault/iteratorEvery.test.ts
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,3 @@ | ||
import { iteratorEvery } from 'iter-fest'; | ||
|
||
test('iteratorEvery should work', () => expect(iteratorEvery([1, 2, 3].values(), value => value)).toBe(true)); |
4 changes: 4 additions & 0 deletions
4
packages/integration-test/importDefault/iteratorFilter.test.ts
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,4 @@ | ||
import { iteratorFilter } from 'iter-fest'; | ||
|
||
test('iteratorFilter should work', () => | ||
expect(Array.from(iteratorFilter([1, 2, 3].values(), value => value % 2))).toEqual([1, 3])); |
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,3 @@ | ||
import { iteratorFind } from 'iter-fest'; | ||
|
||
test('iteratorFind should work', () => expect(iteratorFind([1, 2, 3].values(), value => value % 2)).toBe(1)); |
15 changes: 15 additions & 0 deletions
15
packages/integration-test/importDefault/iteratorFlatMap.test.ts
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,15 @@ | ||
import { iteratorFlatMap } from 'iter-fest'; | ||
|
||
test('iteratorFlatMap should work', () => { | ||
// Copied from https://github.com/tc39/proposal-iterator-helpers. | ||
const sunny = ["It's Sunny in", '', 'California'].values(); | ||
|
||
const result = iteratorFlatMap(sunny, value => value.split(' ').values()); | ||
|
||
expect(result.next()).toEqual({ done: false, value: "It's" }); | ||
expect(result.next()).toEqual({ done: false, value: 'Sunny' }); | ||
expect(result.next()).toEqual({ done: false, value: 'in' }); | ||
expect(result.next()).toEqual({ done: false, value: '' }); | ||
expect(result.next()).toEqual({ done: false, value: 'California' }); | ||
expect(result.next()).toEqual({ done: true, value: undefined }); | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/integration-test/importDefault/iteratorForEach.test.ts
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,9 @@ | ||
import { iteratorForEach } from 'iter-fest'; | ||
|
||
test('iteratorForEach should work', () => { | ||
const callbackfn = jest.fn(); | ||
|
||
iteratorForEach([1, 2, 3].values(), callbackfn); | ||
|
||
expect(callbackfn).toHaveBeenCalledTimes(3); | ||
}); |
15 changes: 15 additions & 0 deletions
15
packages/integration-test/importDefault/iteratorFrom.test.ts
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,15 @@ | ||
import { iteratorFrom } from 'iter-fest'; | ||
|
||
test('iteratorFrom', () => { | ||
// Copied from https://github.com/tc39/proposal-iterator-helpers. | ||
class Iter { | ||
next() { | ||
return { done: false, value: 1 }; | ||
} | ||
} | ||
|
||
const iter = new Iter(); | ||
const wrapper = iteratorFrom(iter); | ||
|
||
expect(wrapper.next()).toEqual({ done: false, value: 1 }); | ||
}); |
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 @@ | ||
import { iteratorMap } from 'iter-fest'; | ||
|
||
test('iteratorMap should work', () => | ||
expect(Array.from(iteratorMap([1, 2, 3].values(), value => String.fromCharCode(value + 64)))).toEqual([ | ||
'A', | ||
'B', | ||
'C' | ||
])); |
4 changes: 4 additions & 0 deletions
4
packages/integration-test/importDefault/iteratorReduce.test.ts
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,4 @@ | ||
import { iteratorReduce } from 'iter-fest'; | ||
|
||
test('iteratorReduce should work', () => | ||
expect(iteratorReduce([1, 2, 3].values(), (previousValue, currentValue) => previousValue + currentValue, 0)).toBe(6)); |
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,3 @@ | ||
import { iteratorSome } from 'iter-fest'; | ||
|
||
test('iteratorSome should work', () => expect(iteratorSome([1, 2, 3].values(), value => value % 2)).toBe(true)); |
21 changes: 21 additions & 0 deletions
21
packages/integration-test/importDefault/iteratorTake.test.ts
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,21 @@ | ||
import { iteratorTake } from 'iter-fest'; | ||
|
||
test('iteratorTake should work', () => { | ||
// Copied from https://github.com/tc39/proposal-iterator-helpers. | ||
function* naturals() { | ||
let i = 0; | ||
|
||
while (true) { | ||
yield i; | ||
|
||
i += 1; | ||
} | ||
} | ||
|
||
const result = iteratorTake(naturals(), 3); | ||
|
||
expect(result.next()).toEqual({ done: false, value: 0 }); | ||
expect(result.next()).toEqual({ done: false, value: 1 }); | ||
expect(result.next()).toEqual({ done: false, value: 2 }); | ||
expect(result.next()).toEqual({ done: true, value: undefined }); | ||
}); |
16 changes: 16 additions & 0 deletions
16
packages/integration-test/importDefault/iteratorToArray.test.ts
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,16 @@ | ||
import { iteratorTake, iteratorToArray } from 'iter-fest'; | ||
|
||
test('should follow TC39 proposal sample', () => { | ||
// Copied from https://github.com/tc39/proposal-iterator-helpers. | ||
function* naturals() { | ||
let i = 0; | ||
while (true) { | ||
yield i; | ||
i += 1; | ||
} | ||
} | ||
|
||
const result = iteratorToArray(iteratorTake(naturals(), 5)); | ||
|
||
expect(result).toEqual([0, 1, 2, 3, 4]); | ||
}); |
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
20 changes: 20 additions & 0 deletions
20
packages/integration-test/importNamed/iteratorDrop.test.ts
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,20 @@ | ||
import { iteratorDrop } from 'iter-fest/iteratorDrop'; | ||
|
||
test('iteratorDrop should work', () => { | ||
// Copied from https://github.com/tc39/proposal-iterator-helpers. | ||
function* naturals() { | ||
let i = 0; | ||
|
||
while (true) { | ||
yield i; | ||
|
||
i += 1; | ||
} | ||
} | ||
|
||
const result = iteratorDrop(naturals(), 3); | ||
|
||
expect(result.next()).toEqual({ done: false, value: 3 }); | ||
expect(result.next()).toEqual({ done: false, value: 4 }); | ||
expect(result.next()).toEqual({ done: false, value: 5 }); | ||
}); |
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,3 @@ | ||
import { iteratorEvery } from 'iter-fest/iteratorEvery'; | ||
|
||
test('iteratorEvery should work', () => expect(iteratorEvery([1, 2, 3].values(), value => value)).toBe(true)); |
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,4 @@ | ||
import { iteratorFilter } from 'iter-fest/iteratorFilter'; | ||
|
||
test('iteratorFilter should work', () => | ||
expect(Array.from(iteratorFilter([1, 2, 3].values(), value => value % 2))).toEqual([1, 3])); |
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,3 @@ | ||
import { iteratorFind } from 'iter-fest/iteratorFind'; | ||
|
||
test('iteratorFind should work', () => expect(iteratorFind([1, 2, 3].values(), value => value % 2)).toBe(1)); |
15 changes: 15 additions & 0 deletions
15
packages/integration-test/importNamed/iteratorFlatMap.test.ts
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,15 @@ | ||
import { iteratorFlatMap } from 'iter-fest/iteratorFlatMap'; | ||
|
||
test('iteratorFlatMap should work', () => { | ||
// Copied from https://github.com/tc39/proposal-iterator-helpers. | ||
const sunny = ["It's Sunny in", '', 'California'].values(); | ||
|
||
const result = iteratorFlatMap(sunny, value => value.split(' ').values()); | ||
|
||
expect(result.next()).toEqual({ done: false, value: "It's" }); | ||
expect(result.next()).toEqual({ done: false, value: 'Sunny' }); | ||
expect(result.next()).toEqual({ done: false, value: 'in' }); | ||
expect(result.next()).toEqual({ done: false, value: '' }); | ||
expect(result.next()).toEqual({ done: false, value: 'California' }); | ||
expect(result.next()).toEqual({ done: true, value: undefined }); | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/integration-test/importNamed/iteratorForEach.test.ts
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,9 @@ | ||
import { iteratorForEach } from 'iter-fest/iteratorForEach'; | ||
|
||
test('iteratorForEach should work', () => { | ||
const callbackfn = jest.fn(); | ||
|
||
iteratorForEach([1, 2, 3].values(), callbackfn); | ||
|
||
expect(callbackfn).toHaveBeenCalledTimes(3); | ||
}); |
Oops, something went wrong.