Son CV dans un terminal web en Javascript!
https://terminal-cv.gregandev.fr
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.2 KiB
31 lines
1.2 KiB
1 year ago
|
// https://github.com/tc39/proposal-iterator-helpers
|
||
|
var $ = require('../internals/export');
|
||
|
var apply = require('../internals/function-apply');
|
||
|
var anObject = require('../internals/an-object');
|
||
|
var toObject = require('../internals/to-object');
|
||
|
var isPrototypeOf = require('../internals/object-is-prototype-of');
|
||
|
var IteratorPrototype = require('../internals/iterators-core').IteratorPrototype;
|
||
|
var createIteratorProxy = require('../internals/iterator-create-proxy');
|
||
|
var getIterator = require('../internals/get-iterator');
|
||
|
var getIteratorMethod = require('../internals/get-iterator-method');
|
||
|
|
||
|
var IteratorProxy = createIteratorProxy(function (args) {
|
||
|
var result = anObject(apply(this.next, this.iterator, args));
|
||
|
var done = this.done = !!result.done;
|
||
|
if (!done) return result.value;
|
||
|
}, true);
|
||
|
|
||
|
$({ target: 'Iterator', stat: true }, {
|
||
|
from: function from(O) {
|
||
|
var object = toObject(O);
|
||
|
var usingIterator = getIteratorMethod(object);
|
||
|
var iterator;
|
||
|
if (usingIterator) {
|
||
|
iterator = getIterator(object, usingIterator);
|
||
|
if (isPrototypeOf(IteratorPrototype, iterator)) return iterator;
|
||
|
} else {
|
||
|
iterator = object;
|
||
|
} return new IteratorProxy({ iterator: iterator });
|
||
|
}
|
||
|
});
|