-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
23 changed files
with
199 additions
and
55 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
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 @@ | ||
require('../../modules/es.object.to-string'); | ||
require('../../modules/es.promise'); | ||
require('../../modules/esnext.async-iterator.constructor'); | ||
require('../../modules/esnext.async-iterator.indexed'); | ||
|
||
var entryUnbind = require('../../internals/entry-unbind'); | ||
|
||
module.exports = entryUnbind('AsyncIterator', 'indexed'); |
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 @@ | ||
require('../../modules/es.object.to-string'); | ||
require('../../modules/esnext.iterator.constructor'); | ||
require('../../modules/esnext.iterator.indexed'); | ||
|
||
var entryUnbind = require('../../internals/entry-unbind'); | ||
|
||
module.exports = entryUnbind('Iterator', 'indexed'); | ||
|
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,25 @@ | ||
'use strict'; | ||
// https://github.com/tc39/proposal-iterator-helpers | ||
var apply = require('../internals/function-apply'); | ||
var anObject = require('../internals/an-object'); | ||
var getIteratorDirect = require('../internals/get-iterator-direct'); | ||
var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy'); | ||
|
||
var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise, args) { | ||
var state = this; | ||
var iterator = state.iterator; | ||
|
||
return Promise.resolve(anObject(apply(state.next, iterator, args))).then(function (step) { | ||
if (anObject(step).done) { | ||
state.done = true; | ||
return { done: true, value: undefined }; | ||
} | ||
return { done: false, value: [state.index++, step.value] }; | ||
}); | ||
}); | ||
|
||
module.exports = function indexed() { | ||
return new AsyncIteratorProxy(getIteratorDirect(this), { | ||
index: 0 | ||
}); | ||
}; |
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,18 @@ | ||
'use strict'; | ||
// https://github.com/tc39/proposal-iterator-helpers | ||
var apply = require('../internals/function-apply'); | ||
var anObject = require('../internals/an-object'); | ||
var getIteratorDirect = require('../internals/get-iterator-direct'); | ||
var createIteratorProxy = require('../internals/iterator-create-proxy'); | ||
|
||
var IteratorProxy = createIteratorProxy(function (args) { | ||
var result = anObject(apply(this.next, this.iterator, args)); | ||
var done = this.done = !!result.done; | ||
if (!done) return [this.index++, result.value]; | ||
}); | ||
|
||
module.exports = function indexed() { | ||
return new IteratorProxy(getIteratorDirect(this), { | ||
index: 0 | ||
}); | ||
}; |
28 changes: 4 additions & 24 deletions
28
packages/core-js/modules/esnext.async-iterator.as-indexed-pairs.js
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,28 +1,8 @@ | ||
'use strict'; | ||
// TODO: Remove from `core-js@4` | ||
// https://github.com/tc39/proposal-iterator-helpers | ||
var $ = require('../internals/export'); | ||
var apply = require('../internals/function-apply'); | ||
var anObject = require('../internals/an-object'); | ||
var getIteratorDirect = require('../internals/get-iterator-direct'); | ||
var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy'); | ||
var indexed = require('../internals/async-iterator-indexed'); | ||
|
||
var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise, args) { | ||
var state = this; | ||
var iterator = state.iterator; | ||
|
||
return Promise.resolve(anObject(apply(state.next, iterator, args))).then(function (step) { | ||
if (anObject(step).done) { | ||
state.done = true; | ||
return { done: true, value: undefined }; | ||
} | ||
return { done: false, value: [state.index++, step.value] }; | ||
}); | ||
}); | ||
|
||
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, { | ||
asIndexedPairs: function asIndexedPairs() { | ||
return new AsyncIteratorProxy(getIteratorDirect(this), { | ||
index: 0 | ||
}); | ||
} | ||
$({ target: 'AsyncIterator', name: 'indexed', proto: true, real: true, forced: true }, { | ||
asIndexedPairs: indexed | ||
}); |
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,7 @@ | ||
// https://github.com/tc39/proposal-iterator-helpers | ||
var $ = require('../internals/export'); | ||
var indexed = require('../internals/async-iterator-indexed'); | ||
|
||
$({ target: 'AsyncIterator', proto: true, real: true, forced: true }, { | ||
indexed: indexed | ||
}); |
21 changes: 4 additions & 17 deletions
21
packages/core-js/modules/esnext.iterator.as-indexed-pairs.js
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,21 +1,8 @@ | ||
'use strict'; | ||
// TODO: Remove from `core-js@4` | ||
// https://github.com/tc39/proposal-iterator-helpers | ||
var $ = require('../internals/export'); | ||
var apply = require('../internals/function-apply'); | ||
var anObject = require('../internals/an-object'); | ||
var getIteratorDirect = require('../internals/get-iterator-direct'); | ||
var createIteratorProxy = require('../internals/iterator-create-proxy'); | ||
var indexed = require('../internals/iterator-indexed'); | ||
|
||
var IteratorProxy = createIteratorProxy(function (args) { | ||
var result = anObject(apply(this.next, this.iterator, args)); | ||
var done = this.done = !!result.done; | ||
if (!done) return [this.index++, result.value]; | ||
}); | ||
|
||
$({ target: 'Iterator', proto: true, real: true, forced: true }, { | ||
asIndexedPairs: function asIndexedPairs() { | ||
return new IteratorProxy(getIteratorDirect(this), { | ||
index: 0 | ||
}); | ||
} | ||
$({ target: 'Iterator', name: 'indexed', proto: true, real: true, forced: true }, { | ||
asIndexedPairs: indexed | ||
}); |
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,7 @@ | ||
// https://github.com/tc39/proposal-iterator-helpers | ||
var $ = require('../internals/export'); | ||
var indexed = require('../internals/iterator-indexed'); | ||
|
||
$({ target: 'Iterator', proto: true, real: true, forced: true }, { | ||
indexed: indexed | ||
}); |
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
Oops, something went wrong.