Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | // https://github.com/tc39/proposal-iterator-helpers
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var path = require('../internals/path');
|
---|
4 | var aFunction = require('../internals/a-function');
|
---|
5 | var anObject = require('../internals/an-object');
|
---|
6 | var toObject = require('../internals/to-object');
|
---|
7 | var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy');
|
---|
8 | var getAsyncIteratorMethod = require('../internals/get-async-iterator-method');
|
---|
9 |
|
---|
10 | var AsyncIterator = path.AsyncIterator;
|
---|
11 |
|
---|
12 | var AsyncIteratorProxy = createAsyncIteratorProxy(function (arg) {
|
---|
13 | return anObject(this.next.call(this.iterator, arg));
|
---|
14 | }, true);
|
---|
15 |
|
---|
16 | $({ target: 'AsyncIterator', stat: true }, {
|
---|
17 | from: function from(O) {
|
---|
18 | var object = toObject(O);
|
---|
19 | var usingIterator = getAsyncIteratorMethod(object);
|
---|
20 | var iterator;
|
---|
21 | if (usingIterator != null) {
|
---|
22 | iterator = aFunction(usingIterator).call(object);
|
---|
23 | if (iterator instanceof AsyncIterator) return iterator;
|
---|
24 | } else {
|
---|
25 | iterator = object;
|
---|
26 | } return new AsyncIteratorProxy({
|
---|
27 | iterator: iterator
|
---|
28 | });
|
---|
29 | }
|
---|
30 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.