/
lostSun
/
project-client-server-apps
Обзор
Документация
Войти
/
lostSun
/
project-client-server-apps
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
node_modules/core-js/modules/es.iterator.map.js
39 строк
2 KB
1lostsun
initial commit
05 май 2025, 11:35
05 май 2025, 11:35
fe8f535
Код
Авторство
О чём код?
'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 getIteratorDirect = require('../internals/get-iterator-direct'); var createIteratorProxy = require('../internals/iterator-create-proxy'); var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing'); var iteratorClose = require('../internals/iterator-close'); var iteratorHelperWithoutClosingOnEarlyError = require('../internals/iterator-helper-without-closing-on-early-error'); var IS_PURE = require('../internals/is-pure'); var mapWithoutClosingOnEarlyError = !IS_PURE && iteratorHelperWithoutClosingOnEarlyError('map', TypeError); 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://tc39.es/ecma262/#sec-iterator.prototype.map $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE || mapWithoutClosingOnEarlyError }, { map: function map(mapper) { anObject(this); try { aCallable(mapper); } catch (error) { iteratorClose(this, 'throw', error); } if (mapWithoutClosingOnEarlyError) return call(mapWithoutClosingOnEarlyError, this, mapper); return new IteratorProxy(getIteratorDirect(this), { mapper: mapper }); } });