X-Git-Url: https://git.josue.xyz/?p=dotfiles%2F.git;a=blobdiff_plain;f=.config%2Fcoc%2Fextensions%2Fnode_modules%2Fcoc-prettier%2Fnode_modules%2Fcore-js%2Finternals%2Fiterate.js;h=58c0f32e248ad86e3976a9f68834b568c3d94950;hp=a68c416123bba1b05116711badcd9dc5ae3e1776;hb=4d07c77cf4d78cab8639e13ddc3c22495e585b0b;hpb=b3950616b54221c40a7dab9099bda675007e5b6e diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/core-js/internals/iterate.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/core-js/internals/iterate.js index a68c4161..58c0f32e 100644 --- a/.config/coc/extensions/node_modules/coc-prettier/node_modules/core-js/internals/iterate.js +++ b/.config/coc/extensions/node_modules/coc-prettier/node_modules/core-js/internals/iterate.js @@ -3,17 +3,33 @@ var isArrayIteratorMethod = require('../internals/is-array-iterator-method'); var toLength = require('../internals/to-length'); var bind = require('../internals/function-bind-context'); var getIteratorMethod = require('../internals/get-iterator-method'); -var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing'); +var iteratorClose = require('../internals/iterator-close'); var Result = function (stopped, result) { this.stopped = stopped; this.result = result; }; -var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITERATOR) { - var boundFunction = bind(fn, that, AS_ENTRIES ? 2 : 1); +module.exports = function (iterable, unboundFunction, options) { + var that = options && options.that; + var AS_ENTRIES = !!(options && options.AS_ENTRIES); + var IS_ITERATOR = !!(options && options.IS_ITERATOR); + var INTERRUPTED = !!(options && options.INTERRUPTED); + var fn = bind(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED); var iterator, iterFn, index, length, result, next, step; + var stop = function (condition) { + if (iterator) iteratorClose(iterator); + return new Result(true, condition); + }; + + var callFn = function (value) { + if (AS_ENTRIES) { + anObject(value); + return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); + } return INTERRUPTED ? fn(value, stop) : fn(value); + }; + if (IS_ITERATOR) { iterator = iterable; } else { @@ -22,9 +38,7 @@ var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITER // optimisation for array iterators if (isArrayIteratorMethod(iterFn)) { for (index = 0, length = toLength(iterable.length); length > index; index++) { - result = AS_ENTRIES - ? boundFunction(anObject(step = iterable[index])[0], step[1]) - : boundFunction(iterable[index]); + result = callFn(iterable[index]); if (result && result instanceof Result) return result; } return new Result(false); } @@ -33,11 +47,12 @@ var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITER next = iterator.next; while (!(step = next.call(iterator)).done) { - result = callWithSafeIterationClosing(iterator, boundFunction, step.value, AS_ENTRIES); + try { + result = callFn(step.value); + } catch (error) { + iteratorClose(iterator); + throw error; + } if (typeof result == 'object' && result && result instanceof Result) return result; } return new Result(false); }; - -iterate.stop = function (result) { - return new Result(true, result); -};