3cecfa478732b8b75b722faf9967aaf9.json 8.7 KB

1
  1. {"ast":null,"code":"var bind = require('../internals/function-bind-context');\n\nvar IndexedObject = require('../internals/indexed-object');\n\nvar toObject = require('../internals/to-object');\n\nvar toLength = require('../internals/to-length');\n\nvar arraySpeciesCreate = require('../internals/array-species-create');\n\nvar push = [].push; // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterOut }` methods implementation\n\nvar createMethod = function (TYPE) {\n var IS_MAP = TYPE == 1;\n var IS_FILTER = TYPE == 2;\n var IS_SOME = TYPE == 3;\n var IS_EVERY = TYPE == 4;\n var IS_FIND_INDEX = TYPE == 6;\n var IS_FILTER_OUT = TYPE == 7;\n var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;\n return function ($this, callbackfn, that, specificCreate) {\n var O = toObject($this);\n var self = IndexedObject(O);\n var boundFunction = bind(callbackfn, that, 3);\n var length = toLength(self.length);\n var index = 0;\n var create = specificCreate || arraySpeciesCreate;\n var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_OUT ? create($this, 0) : undefined;\n var value, result;\n\n for (; length > index; index++) if (NO_HOLES || index in self) {\n value = self[index];\n result = boundFunction(value, index, O);\n\n if (TYPE) {\n if (IS_MAP) target[index] = result; // map\n else if (result) switch (TYPE) {\n case 3:\n return true;\n // some\n\n case 5:\n return value;\n // find\n\n case 6:\n return index;\n // findIndex\n\n case 2:\n push.call(target, value);\n // filter\n } else switch (TYPE) {\n case 4:\n return false;\n // every\n\n case 7:\n push.call(target, value);\n // filterOut\n }\n }\n }\n\n return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.forEach` method\n // https://tc39.es/ecma262/#sec-array.prototype.foreach\n forEach: createMethod(0),\n // `Array.prototype.map` method\n // https://tc39.es/ecma262/#sec-array.prototype.map\n map: createMethod(1),\n // `Array.prototype.filter` method\n // https://tc39.es/ecma262/#sec-array.prototype.filter\n filter: createMethod(2),\n // `Array.prototype.some` method\n // https://tc39.es/ecma262/#sec-array.prototype.some\n some: createMethod(3),\n // `Array.prototype.every` method\n // https://tc39.es/ecma262/#sec-array.prototype.every\n every: createMethod(4),\n // `Array.prototype.find` method\n // https://tc39.es/ecma262/#sec-array.prototype.find\n find: createMethod(5),\n // `Array.prototype.findIndex` method\n // https://tc39.es/ecma262/#sec-array.prototype.findIndex\n findIndex: createMethod(6),\n // `Array.prototype.filterOut` method\n // https://github.com/tc39/proposal-array-filtering\n filterOut: createMethod(7)\n};","map":{"version":3,"sources":["/Users/jane/Documents/Курс Front-end/HW8/myproject/node_modules/core-js-pure/internals/array-iteration.js"],"names":["bind","require","IndexedObject","toObject","toLength","arraySpeciesCreate","push","createMethod","TYPE","IS_MAP","IS_FILTER","IS_SOME","IS_EVERY","IS_FIND_INDEX","IS_FILTER_OUT","NO_HOLES","$this","callbackfn","that","specificCreate","O","self","boundFunction","length","index","create","target","undefined","value","result","call","module","exports","forEach","map","filter","some","every","find","findIndex","filterOut"],"mappings":"AAAA,IAAIA,IAAI,GAAGC,OAAO,CAAC,oCAAD,CAAlB;;AACA,IAAIC,aAAa,GAAGD,OAAO,CAAC,6BAAD,CAA3B;;AACA,IAAIE,QAAQ,GAAGF,OAAO,CAAC,wBAAD,CAAtB;;AACA,IAAIG,QAAQ,GAAGH,OAAO,CAAC,wBAAD,CAAtB;;AACA,IAAII,kBAAkB,GAAGJ,OAAO,CAAC,mCAAD,CAAhC;;AAEA,IAAIK,IAAI,GAAG,GAAGA,IAAd,C,CAEA;;AACA,IAAIC,YAAY,GAAG,UAAUC,IAAV,EAAgB;AACjC,MAAIC,MAAM,GAAGD,IAAI,IAAI,CAArB;AACA,MAAIE,SAAS,GAAGF,IAAI,IAAI,CAAxB;AACA,MAAIG,OAAO,GAAGH,IAAI,IAAI,CAAtB;AACA,MAAII,QAAQ,GAAGJ,IAAI,IAAI,CAAvB;AACA,MAAIK,aAAa,GAAGL,IAAI,IAAI,CAA5B;AACA,M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qBAAOJ,KAAP;AAA0B;;AAClC,iBAAK,CAAL;AAAQlB,cAAAA,IAAI,CAACwB,IAAL,CAAUJ,MAAV,EAAkBE,KAAlB;AAA0B;AAJnB,WAAZ,MAKE,QAAQpB,IAAR;AACL,iBAAK,CAAL;AAAQ,qBAAO,KAAP;AAA0B;;AAClC,iBAAK,CAAL;AAAQF,cAAAA,IAAI,CAACwB,IAAL,CAAUJ,MAAV,EAAkBE,KAAlB;AAA0B;AAF7B;AAIR;AACF;;AACD,WAAOf,aAAa,GAAG,CAAC,CAAJ,GAAQF,OAAO,IAAIC,QAAX,GAAsBA,QAAtB,GAAiCc,MAA7D;AACD,GA1BD;AA2BD,CAnCD;;AAqCAK,MAAM,CAACC,OAAP,GAAiB;AACf;AACA;AACAC,EAAAA,OAAO,EAAE1B,YAAY,CAAC,CAAD,CAHN;AAIf;AACA;AACA2B,EAAAA,GAAG,EAAE3B,YAAY,CAAC,CAAD,CANF;AAOf;AACA;AACA4B,EAAAA,MAAM,EAAE5B,YAAY,CAAC,CAAD,CATL;AAUf;AACA;AACA6B,EAAAA,IAAI,EAAE7B,YAAY,CAAC,CAAD,CAZH;AAaf;AACA;AACA8B,EAAAA,KAAK,EAAE9B,YAAY,CAAC,CAAD,CAfJ;AAgBf;AACA;AACA+B,EAAAA,IAAI,EAAE/B,YAAY,CAAC,CAAD,CAlBH;AAmBf;AACA;AACAgC,EAAAA,SAAS,EAAEhC,YAAY,CAAC,CAAD,CArBR;AAsBf;AACA;AACAiC,EAAAA,SAAS,EAAEjC,YAAY,CAAC,CAAD;AAxBR,CAAjB","sourcesContent":["var bind = require('../internals/function-bind-context');\nvar IndexedObject = require('../internals/indexed-object');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar arraySpeciesCreate = require('../internals/array-species-create');\n\nvar push = [].push;\n\n// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterOut }` methods implementation\nvar createMethod = function (TYPE) {\n var IS_MAP = TYPE == 1;\n var IS_FILTER = TYPE == 2;\n var IS_SOME = TYPE == 3;\n var IS_EVERY = TYPE == 4;\n var IS_FIND_INDEX = TYPE == 6;\n var IS_FILTER_OUT = TYPE == 7;\n var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;\n return function ($this, callbackfn, that, specificCreate) {\n var O = toObject($this);\n var self = IndexedObject(O);\n var boundFunction = bind(callbackfn, that, 3);\n var length = toLength(self.length);\n var index = 0;\n var create = specificCreate || arraySpeciesCreate;\n var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_OUT ? create($this, 0) : undefined;\n var value, result;\n for (;length > index; index++) if (NO_HOLES || index in self) {\n value = self[index];\n result = boundFunction(value, index, O);\n if (TYPE) {\n if (IS_MAP) target[index] = result; // map\n else if (result) switch (TYPE) {\n case 3: return true; // some\n case 5: return value; // find\n case 6: return index; // findIndex\n case 2: push.call(target, value); // filter\n } else switch (TYPE) {\n case 4: return false; // every\n case 7: push.call(target, value); // filterOut\n }\n }\n }\n return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.forEach` method\n // https://tc39.es/ecma262/#sec-array.prototype.foreach\n forEach: createMethod(0),\n // `Array.prototype.map` method\n // https://tc39.es/ecma262/#sec-array.prototype.map\n map: createMethod(1),\n // `Array.prototype.filter` method\n // https://tc39.es/ecma262/#sec-array.prototype.filter\n filter: createMethod(2),\n // `Array.prototype.some` method\n // https://tc39.es/ecma262/#sec-array.prototype.some\n some: createMethod(3),\n // `Array.prototype.every` method\n // https://tc39.es/ecma262/#sec-array.prototype.every\n every: createMethod(4),\n // `Array.prototype.find` method\n // https://tc39.es/ecma262/#sec-array.prototype.find\n find: createMethod(5),\n // `Array.prototype.findIndex` method\n // https://tc39.es/ecma262/#sec-array.prototype.findIndex\n findIndex: createMethod(6),\n // `Array.prototype.filterOut` method\n // https://github.com/tc39/proposal-array-filtering\n filterOut: createMethod(7)\n};\n"]},"metadata":{},"sourceType":"script"}