-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
Iterator
sequencing stage 2.7 proposal
- Loading branch information
Showing
12 changed files
with
116 additions
and
4 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,20 @@ | ||
'use strict'; | ||
require('../../modules/es.array.iterator'); | ||
require('../../modules/es.object.to-string'); | ||
require('../../modules/es.string.iterator'); | ||
require('../../modules/es.iterator.constructor'); | ||
require('../../modules/es.iterator.drop'); | ||
require('../../modules/es.iterator.every'); | ||
require('../../modules/es.iterator.filter'); | ||
require('../../modules/es.iterator.find'); | ||
require('../../modules/es.iterator.flat-map'); | ||
require('../../modules/es.iterator.for-each'); | ||
require('../../modules/es.iterator.map'); | ||
require('../../modules/es.iterator.reduce'); | ||
require('../../modules/es.iterator.some'); | ||
require('../../modules/es.iterator.take'); | ||
require('../../modules/es.iterator.to-array'); | ||
require('../../modules/esnext.iterator.concat'); | ||
var path = require('../../internals/path'); | ||
|
||
module.exports = path.Iterator.concat; |
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,56 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var call = require('../internals/function-call'); | ||
var aCallable = require('../internals/a-callable'); | ||
var anObject = require('../internals/an-object'); | ||
var getIteratorMethod = require('../internals/get-iterator-method'); | ||
var createIteratorProxy = require('../internals/iterator-create-proxy'); | ||
|
||
var $Array = Array; | ||
|
||
var IteratorProxy = createIteratorProxy(function () { | ||
while (true) { | ||
var iterator = this.iterator; | ||
if (!iterator) { | ||
var iterableIndex = this.nextIterableIndex++; | ||
var iterables = this.iterables; | ||
if (iterableIndex >= iterables.length) { | ||
this.done = true; | ||
return; | ||
} | ||
var entry = iterables[iterableIndex]; | ||
this.iterables[iterableIndex] = null; | ||
iterator = this.iterator = call(entry.method, entry.iterable); | ||
this.next = iterator.next; | ||
} | ||
var result = anObject(call(this.next, iterator)); | ||
if (result.done) { | ||
this.iterator = null; | ||
this.next = null; | ||
continue; | ||
} | ||
return result.value; | ||
} | ||
}); | ||
|
||
// `Iterator.concat` method | ||
// https://github.com/tc39/proposal-iterator-sequencing | ||
$({ target: 'Iterator', stat: true, forced: true }, { | ||
concat: function concat() { | ||
var length = arguments.length; | ||
var iterables = $Array(length); | ||
for (var index = 0; index < length; index++) { | ||
var item = anObject(arguments[index]); | ||
iterables[index] = { | ||
iterable: item, | ||
method: aCallable(getIteratorMethod(item)) | ||
}; | ||
} | ||
return new IteratorProxy({ | ||
iterables: iterables, | ||
nextIterableIndex: 0, | ||
iterator: null, | ||
next: null | ||
}); | ||
} | ||
}); |
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 @@ | ||
'use strict'; | ||
// https://github.com/tc39/proposal-iterator-sequencing | ||
require('../modules/esnext.iterator.concat'); |
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,6 @@ | ||
'use strict'; | ||
var parent = require('./3'); | ||
|
||
require('../proposals/iterator-sequencing'); | ||
|
||
module.exports = parent; |
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