aboutsummaryrefslogtreecommitdiff
path: root/node_modules/core-js/modules/$.array-methods.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
commitde98e0b232509d5f40c135d540a70e415272ff85 (patch)
treea79222a5b58484ab3b80d18efcaaa7ccc4769b33 /node_modules/core-js/modules/$.array-methods.js
parente0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff)
node_modules
Diffstat (limited to 'node_modules/core-js/modules/$.array-methods.js')
-rw-r--r--node_modules/core-js/modules/$.array-methods.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/node_modules/core-js/modules/$.array-methods.js b/node_modules/core-js/modules/$.array-methods.js
new file mode 100644
index 000000000..e70b99f4c
--- /dev/null
+++ b/node_modules/core-js/modules/$.array-methods.js
@@ -0,0 +1,43 @@
+// 0 -> Array#forEach
+// 1 -> Array#map
+// 2 -> Array#filter
+// 3 -> Array#some
+// 4 -> Array#every
+// 5 -> Array#find
+// 6 -> Array#findIndex
+var ctx = require('./$.ctx')
+ , IObject = require('./$.iobject')
+ , toObject = require('./$.to-object')
+ , toLength = require('./$.to-length')
+ , asc = require('./$.array-species-create');
+module.exports = function(TYPE){
+ var IS_MAP = TYPE == 1
+ , IS_FILTER = TYPE == 2
+ , IS_SOME = TYPE == 3
+ , IS_EVERY = TYPE == 4
+ , IS_FIND_INDEX = TYPE == 6
+ , NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
+ return function($this, callbackfn, that){
+ var O = toObject($this)
+ , self = IObject(O)
+ , f = ctx(callbackfn, that, 3)
+ , length = toLength(self.length)
+ , index = 0
+ , result = IS_MAP ? asc($this, length) : IS_FILTER ? asc($this, 0) : undefined
+ , val, res;
+ for(;length > index; index++)if(NO_HOLES || index in self){
+ val = self[index];
+ res = f(val, index, O);
+ if(TYPE){
+ if(IS_MAP)result[index] = res; // map
+ else if(res)switch(TYPE){
+ case 3: return true; // some
+ case 5: return val; // find
+ case 6: return index; // findIndex
+ case 2: result.push(val); // filter
+ } else if(IS_EVERY)return false; // every
+ }
+ }
+ return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
+ };
+}; \ No newline at end of file