first
This commit is contained in:
24
node_modules/core-js/internals/iterator-map.js
generated
vendored
Normal file
24
node_modules/core-js/internals/iterator-map.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
var call = require('../internals/function-call');
|
||||
var aCallable = require('../internals/a-callable');
|
||||
var anObject = require('../internals/an-object');
|
||||
var getIteratorDirect = require('../internals/get-iterator-direct');
|
||||
var createIteratorProxy = require('../internals/iterator-create-proxy');
|
||||
var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');
|
||||
|
||||
var IteratorProxy = createIteratorProxy(function () {
|
||||
var iterator = this.iterator;
|
||||
var result = anObject(call(this.next, iterator));
|
||||
var done = this.done = !!result.done;
|
||||
if (!done) return callWithSafeIterationClosing(iterator, this.mapper, [result.value, this.counter++], true);
|
||||
});
|
||||
|
||||
// `Iterator.prototype.map` method
|
||||
// https://github.com/tc39/proposal-iterator-helpers
|
||||
module.exports = function map(mapper) {
|
||||
anObject(this);
|
||||
aCallable(mapper);
|
||||
return new IteratorProxy(getIteratorDirect(this), {
|
||||
mapper: mapper
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user