forked from enviPath/enviPy
Current Dev State
This commit is contained in:
18
static/js/ketcher2/node_modules/array-reduce/index.js
generated
vendored
Normal file
18
static/js/ketcher2/node_modules/array-reduce/index.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
var hasOwn = Object.prototype.hasOwnProperty;
|
||||
|
||||
module.exports = function (xs, f, acc) {
|
||||
var hasAcc = arguments.length >= 3;
|
||||
if (hasAcc && xs.reduce) return xs.reduce(f, acc);
|
||||
if (xs.reduce) return xs.reduce(f);
|
||||
|
||||
for (var i = 0; i < xs.length; i++) {
|
||||
if (!hasOwn.call(xs, i)) continue;
|
||||
if (!hasAcc) {
|
||||
acc = xs[i];
|
||||
hasAcc = true;
|
||||
continue;
|
||||
}
|
||||
acc = f(acc, xs[i], i);
|
||||
}
|
||||
return acc;
|
||||
};
|
||||
Reference in New Issue
Block a user