array-reduce-x
Advanced tools
Comparing version
@@ -11,3 +11,2 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var natRed = [].reduce; | ||
var castObject = {}.constructor; | ||
var nativeReduce = typeof natRed === 'function' && natRed; | ||
@@ -22,3 +21,3 @@ | ||
var test2 = function test2() { | ||
var res = attempt.call(castObject('abc'), nativeReduce, function attemptee(acc, c) { | ||
var res = attempt.call(toObject('abc'), nativeReduce, function attemptee(acc, c) { | ||
return acc + c; | ||
@@ -59,6 +58,9 @@ }, 'x'); | ||
fragment.appendChild(div); | ||
var res = attempt.call(fragment.childNodes, nativeReduce, function attempte(acc, node) { | ||
var atemptee = function attempte(acc, node) { | ||
acc[acc.length] = node; | ||
return acc; | ||
}, []); | ||
}; | ||
var res = attempt.call(fragment.childNodes, nativeReduce, atemptee, []); | ||
return res.threw === false && res.value.length === 1 && res.value[0] === div; | ||
@@ -71,4 +73,5 @@ } | ||
var test6 = function test6() { | ||
var res = attempt.call('ab', nativeReduce, function attempte(_, __, ___, list) { | ||
return list; | ||
var res = attempt.call('ab', nativeReduce, function attempte() { | ||
/* eslint-disable-next-line prefer-rest-params */ | ||
return arguments[3]; | ||
}); | ||
@@ -83,68 +86,64 @@ return res.threw === false && _typeof(res.value) === 'object'; | ||
var patchedReduce = function patchedReduce() { | ||
return function reduce(array, callBack | ||
/* , initialValue */ | ||
) { | ||
requireObjectCoercible(array); | ||
var args = [assertIsFunction(callBack)]; | ||
var patchedReduce = function reduce(array, callBack | ||
/* , initialValue */ | ||
) { | ||
requireObjectCoercible(array); | ||
var args = [assertIsFunction(callBack)]; | ||
if (arguments.length > 2) { | ||
/* eslint-disable-next-line prefer-rest-params,prefer-destructuring */ | ||
args[1] = arguments[2]; | ||
} | ||
if (arguments.length > 2) { | ||
/* eslint-disable-next-line prefer-rest-params,prefer-destructuring */ | ||
args[1] = arguments[2]; | ||
} | ||
return nativeReduce.apply(array, args); | ||
}; | ||
return nativeReduce.apply(array, args); | ||
}; | ||
var implementation = function implementation() { | ||
return function reduce(array, callBack | ||
/* , initialValue */ | ||
) { | ||
var object = toObject(array); // If no callback function or if callback is not a callable function | ||
export var implementation = function reduce(array, callBack | ||
/* , initialValue */ | ||
) { | ||
var object = toObject(array); // If no callback function or if callback is not a callable function | ||
assertIsFunction(callBack); | ||
var iterable = splitIfBoxedBug(object); | ||
var length = toLength(iterable.length); | ||
var argsLength = arguments.length; // no value to return if no initial value and an empty array | ||
assertIsFunction(callBack); | ||
var iterable = splitIfBoxedBug(object); | ||
var length = toLength(iterable.length); | ||
var argsLength = arguments.length; // no value to return if no initial value and an empty array | ||
if (length === 0 && argsLength < 3) { | ||
throw new TypeError('Reduce of empty array with no initial value'); | ||
} | ||
if (length === 0 && argsLength < 3) { | ||
throw new TypeError('Reduce of empty array with no initial value'); | ||
} | ||
var i = 0; | ||
var result; | ||
var i = 0; | ||
var result; | ||
if (argsLength > 2) { | ||
/* eslint-disable-next-line prefer-rest-params,prefer-destructuring */ | ||
result = arguments[2]; | ||
} else { | ||
do { | ||
if (i in iterable) { | ||
result = iterable[i]; | ||
i += 1; | ||
break; | ||
} // if array contains no values, no initial value to return | ||
if (argsLength > 2) { | ||
/* eslint-disable-next-line prefer-rest-params,prefer-destructuring */ | ||
result = arguments[2]; | ||
} else { | ||
do { | ||
if (i in iterable) { | ||
result = iterable[i]; | ||
i += 1; | ||
break; | ||
} // if array contains no values, no initial value to return | ||
if (i >= length) { | ||
throw new TypeError('Reduce of empty array with no initial value'); | ||
} | ||
} while (true); | ||
/* eslint-disable-line no-constant-condition */ | ||
} | ||
i += 1; | ||
while (i < length) { | ||
if (i in iterable) { | ||
result = callBack(result, iterable[i], i, object); | ||
if (i >= length) { | ||
throw new TypeError('Reduce of empty array with no initial value'); | ||
} | ||
} while (true); | ||
/* eslint-disable-line no-constant-condition */ | ||
i += 1; | ||
} | ||
while (i < length) { | ||
if (i in iterable) { | ||
result = callBack(result, iterable[i], i, object); | ||
} | ||
return result; | ||
}; | ||
i += 1; | ||
} | ||
return result; | ||
}; | ||
@@ -167,6 +166,5 @@ /* | ||
var $reduce = isWorking ? patchedReduce() : implementation(); | ||
var $reduce = isWorking ? patchedReduce : implementation; | ||
export default $reduce; | ||
//# sourceMappingURL=array-reduce-x.esm.js.map |
@@ -5,9 +5,9 @@ /*! | ||
"copywrite": "Copyright (c) 2017", | ||
"date": "2019-07-31T22:49:03.969Z", | ||
"date": "2019-08-05T18:46:36.891Z", | ||
"describe": "", | ||
"description": "Reduce an array (from left to right) to a single value.", | ||
"file": "array-reduce-x.js", | ||
"hash": "4fe35686f3dfb15a40a4", | ||
"hash": "520a35cb0542eeda7615", | ||
"license": "MIT", | ||
"version": "3.0.16" | ||
"version": "3.0.17" | ||
} | ||
@@ -1633,2 +1633,3 @@ */ | ||
// CONCATENATED MODULE: ./dist/array-reduce-x.esm.js | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "implementation", function() { return implementation; }); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -1644,3 +1645,2 @@ | ||
var natRed = [].reduce; | ||
var array_reduce_x_esm_castObject = {}.constructor; | ||
var nativeReduce = typeof natRed === 'function' && natRed; | ||
@@ -1655,3 +1655,3 @@ | ||
var array_reduce_x_esm_test2 = function test2() { | ||
var res = attempt_x_esm.call(array_reduce_x_esm_castObject('abc'), nativeReduce, function attemptee(acc, c) { | ||
var res = attempt_x_esm.call(to_object_x_esm('abc'), nativeReduce, function attemptee(acc, c) { | ||
return acc + c; | ||
@@ -1692,6 +1692,9 @@ }, 'x'); | ||
fragment.appendChild(div); | ||
var res = attempt_x_esm.call(fragment.childNodes, nativeReduce, function attempte(acc, node) { | ||
var atemptee = function attempte(acc, node) { | ||
acc[acc.length] = node; | ||
return acc; | ||
}, []); | ||
}; | ||
var res = attempt_x_esm.call(fragment.childNodes, nativeReduce, atemptee, []); | ||
return res.threw === false && res.value.length === 1 && res.value[0] === div; | ||
@@ -1704,4 +1707,5 @@ } | ||
var array_reduce_x_esm_test6 = function test6() { | ||
var res = attempt_x_esm.call('ab', nativeReduce, function attempte(_, __, ___, list) { | ||
return list; | ||
var res = attempt_x_esm.call('ab', nativeReduce, function attempte() { | ||
/* eslint-disable-next-line prefer-rest-params */ | ||
return arguments[3]; | ||
}); | ||
@@ -1716,68 +1720,64 @@ return res.threw === false && _typeof(res.value) === 'object'; | ||
var array_reduce_x_esm_patchedReduce = function patchedReduce() { | ||
return function reduce(array, callBack | ||
/* , initialValue */ | ||
) { | ||
require_object_coercible_x_esm(array); | ||
var args = [assert_is_function_x_esm(callBack)]; | ||
var patchedReduce = function reduce(array, callBack | ||
/* , initialValue */ | ||
) { | ||
require_object_coercible_x_esm(array); | ||
var args = [assert_is_function_x_esm(callBack)]; | ||
if (arguments.length > 2) { | ||
/* eslint-disable-next-line prefer-rest-params,prefer-destructuring */ | ||
args[1] = arguments[2]; | ||
} | ||
if (arguments.length > 2) { | ||
/* eslint-disable-next-line prefer-rest-params,prefer-destructuring */ | ||
args[1] = arguments[2]; | ||
} | ||
return nativeReduce.apply(array, args); | ||
}; | ||
return nativeReduce.apply(array, args); | ||
}; | ||
var array_reduce_x_esm_implementation = function implementation() { | ||
return function reduce(array, callBack | ||
/* , initialValue */ | ||
) { | ||
var object = to_object_x_esm(array); // If no callback function or if callback is not a callable function | ||
var implementation = function reduce(array, callBack | ||
/* , initialValue */ | ||
) { | ||
var object = to_object_x_esm(array); // If no callback function or if callback is not a callable function | ||
assert_is_function_x_esm(callBack); | ||
var iterable = split_if_boxed_bug_x_esm(object); | ||
var length = to_length_x_esm(iterable.length); | ||
var argsLength = arguments.length; // no value to return if no initial value and an empty array | ||
assert_is_function_x_esm(callBack); | ||
var iterable = split_if_boxed_bug_x_esm(object); | ||
var length = to_length_x_esm(iterable.length); | ||
var argsLength = arguments.length; // no value to return if no initial value and an empty array | ||
if (length === 0 && argsLength < 3) { | ||
throw new TypeError('Reduce of empty array with no initial value'); | ||
} | ||
if (length === 0 && argsLength < 3) { | ||
throw new TypeError('Reduce of empty array with no initial value'); | ||
} | ||
var i = 0; | ||
var result; | ||
var i = 0; | ||
var result; | ||
if (argsLength > 2) { | ||
/* eslint-disable-next-line prefer-rest-params,prefer-destructuring */ | ||
result = arguments[2]; | ||
} else { | ||
do { | ||
if (i in iterable) { | ||
result = iterable[i]; | ||
i += 1; | ||
break; | ||
} // if array contains no values, no initial value to return | ||
if (argsLength > 2) { | ||
/* eslint-disable-next-line prefer-rest-params,prefer-destructuring */ | ||
result = arguments[2]; | ||
} else { | ||
do { | ||
if (i in iterable) { | ||
result = iterable[i]; | ||
i += 1; | ||
break; | ||
} // if array contains no values, no initial value to return | ||
if (i >= length) { | ||
throw new TypeError('Reduce of empty array with no initial value'); | ||
} | ||
} while (true); | ||
/* eslint-disable-line no-constant-condition */ | ||
} | ||
i += 1; | ||
while (i < length) { | ||
if (i in iterable) { | ||
result = callBack(result, iterable[i], i, object); | ||
if (i >= length) { | ||
throw new TypeError('Reduce of empty array with no initial value'); | ||
} | ||
} while (true); | ||
/* eslint-disable-line no-constant-condition */ | ||
i += 1; | ||
} | ||
while (i < length) { | ||
if (i in iterable) { | ||
result = callBack(result, iterable[i], i, object); | ||
} | ||
return result; | ||
}; | ||
i += 1; | ||
} | ||
return result; | ||
}; | ||
@@ -1800,4 +1800,3 @@ /* | ||
var $reduce = isWorking ? array_reduce_x_esm_patchedReduce() : array_reduce_x_esm_implementation(); | ||
var $reduce = isWorking ? patchedReduce : implementation; | ||
/* harmony default export */ var array_reduce_x_esm = __webpack_exports__["default"] = ($reduce); | ||
@@ -1804,0 +1803,0 @@ |
@@ -5,9 +5,9 @@ /*! | ||
"copywrite": "Copyright (c) 2017", | ||
"date": "2019-07-31T22:49:03.969Z", | ||
"date": "2019-08-05T18:46:36.891Z", | ||
"describe": "", | ||
"description": "Reduce an array (from left to right) to a single value.", | ||
"file": "array-reduce-x.min.js", | ||
"hash": "0d58098be196dc049259", | ||
"hash": "4d1e87d224659cbc8769", | ||
"license": "MIT", | ||
"version": "3.0.16" | ||
"version": "3.0.17" | ||
} | ||
@@ -21,3 +21,3 @@ */ | ||
* Released under the MIT License. | ||
*/e.exports=function(e){return"object"==typeof e?null===e:"function"!=typeof e}},function(e,t,n){"use strict";var r=String.prototype.valueOf,o=Object.prototype.toString,i="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;e.exports=function(e){return"string"==typeof e||"object"==typeof e&&(i?function(e){try{return r.call(e),!0}catch(e){return!1}}(e):"[object String]"===o.call(e))}},function(e,t,n){"use strict";var r=Date.prototype.getDay,o=Object.prototype.toString,i="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;e.exports=function(e){return"object"==typeof e&&null!==e&&(i?function(e){try{return r.call(e),!0}catch(e){return!1}}(e):"[object Date]"===o.call(e))}},function(e,t,n){"use strict";(function(t){var r=t.Symbol,o=n(6);e.exports=function(){return"function"==typeof r&&("function"==typeof Symbol&&("symbol"==typeof r("foo")&&("symbol"==typeof Symbol("bar")&&o())))}}).call(this,n(5))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),n=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},function(e,t,n){"use strict";n.r(t);var r=function(e){try{for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return{threw:!1,value:e.apply(this,n)}}catch(e){return{threw:!0,value:e}}},o={}.constructor("a"),i="a"===o[0]&&0 in o,c=n(2),u="".split,s=!1===i&&"function"==typeof u&&n.n(c).a,a=function(e){return s&&s(e)?u.call(e,""):e},f=n(0),l=n.n(f);for(var p=r(function(){return function(e,t){if(e!==t)throw new TypeError("Cannot instantiate an arrow function")}(this,void 0),"function"==typeof Symbol&&l()(Symbol(""))}.bind(void 0)),y=!1===p.threw&&!0===p.value,d=n(1),b=n.n(d),g=n(3),m=n.n(g),v=function(e){return!!e},h={}.toString,w=function(e){return null===e?"[object Null]":void 0===e?"[object Undefined]":h.call(e)},S=y&&l()(Symbol.toStringTag),j=function(e){return null==e},O=function(e){if(j(e))throw new TypeError("Cannot call method on ".concat(e));return e},x="Cannot convert a Symbol value to a string",T=x.constructor,E=function(e){if(l()(e))throw new TypeError(x);return T(e)},P=function(e){return E(O(e))},F=[{code:9,description:"Tab",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\t"},{code:10,description:"Line Feed",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\n"},{code:11,description:"Vertical Tab",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\v"},{code:12,description:"Form Feed",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\f"},{code:13,description:"Carriage Return",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\r"},{code:32,description:"Space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:160,description:"No-break space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:5760,description:"Ogham space mark",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:6158,description:"Mongolian vowel separator",es5:!0,es2015:!0,es2016:!0,es2017:!1,es2018:!1,string:""},{code:8192,description:"En quad",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8193,description:"Em quad",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8194,description:"En space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8195,description:"Em space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8196,description:"Three-per-em space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8197,description:"Four-per-em space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8198,description:"Six-per-em space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8199,description:"Figure space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8200,description:"Punctuation space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8201,description:"Thin space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8202,description:"Hair space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8232,description:"Line separator",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\u2028"},{code:8233,description:"Paragraph separator",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\u2029"},{code:8239,description:"Narrow no-break space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8287,description:"Medium mathematical space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:12288,description:"Ideographic space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:65279,description:"Byte Order Mark",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\ufeff"}],N="",M=F.length,k=0;k<M;k+=1)F[k].es2016&&F[k].string,F[k].es2018&&(N+=F[k].string);var C=N,D=new(0,/none/.constructor)("^[".concat(C,"]+")),$="".replace,_=function(e){return $.call(P(e),D,"")},R=new(0,/none/.constructor)("[".concat(C,"]+$")),A="".replace,I=function(e){return A.call(P(e),R,"")},X=function(e){return _(I(e))},q=new(0,/none/.constructor)("[".concat(C,"]+"),"g"),L=" ".replace,B=function(e){return L.call(X(e),q," ")},G=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,H="".replace,U=function(e,t){return H.call(P(e),G,arguments.length>1?E(t):"")},V=r.constructor,z=r.toString,J=/^class /,K=J.test,Q=!1===r(function(){return V('"use strict"; return class My {};')()}).threw,W=function(e){return K.call(J,B(U(z.call(e)," ")))},Y=function(e){var t=r(W,e);return!1===t.threw&&t.value},Z=function(e,t){return!b()(e)&&(S?function(e,t){return!(Q&&!1===t&&Y(e)||!1!==r.call(e,z).threw)}(e,v(t)):(!Q||!1!==v(t)||!Y(e))&&function(e){var t=w(e);return"[object Function]"===t||"[object GeneratorFunction]"===t||"[object AsyncFunction]"===t}(e))},ee="string".constructor,te=(0).constructor,ne=y&&Symbol.toPrimitive,re=y&&Symbol.prototype.valueOf,oe=["toString","valueOf"],ie=["valueOf","toString"],ce=function(e,t){O(e),function(e){if("string"!=typeof e||"number"!==e&&"string"!==e)throw new TypeError('hint must be "string" or "number"')}(t);for(var n,r,o="string"===t?oe:ie,i=0;i<2;i+=1)if(n=e[o[i]],Z(n)&&(r=n.call(e),b()(r)))return r;throw new TypeError("No default value")},ue=function(e,t){if(t){if(e===ee)return"string";if(e===te)return"number"}return"default"},se=function(e){if(y){if(ne)return function(e,t){var n=e[t];if(!1===j(n)){if(!1===Z(n))throw new TypeError("".concat(n," returned for property ").concat(t," of object ").concat(e," is not a function"));return n}}(e,ne);if(l()(e))return re}},ae=function(e){var t=e.exoticToPrim,n=e.input,r=e.hint,o=t.call(n,r);if(b()(o))return o;throw new TypeError("unable to convert exotic object to primitive")},fe=function(e,t){var n="default"===t&&(m()(e)||l()(e))?"string":t;return ce(e,"default"===n?"number":n)},le=function(e,t){if(b()(e))return e;var n=ue(t,arguments.length>1),r=se(e);return void 0===r?fe(e,n):ae({exoticToPrim:r,input:e,hint:n})},pe=parseInt,ye=(0).constructor,de="".charAt,be=/^[-+]?0[xX]/,ge=be.test,me=function(e,t){var n=_(E(e));return""===de.call(n,0)?NaN:pe(n,ye(t)||(ge.call(be,n)?16:10))},ve=2..constructor,he="Cannot convert a Symbol value to a number".slice,we=/^0b[01]+$/i,Se=we.test,je=/^0o[0-7]+$/i,Oe=new(0,we.constructor)("[ ]","g"),xe=/^[-+]0x[0-9a-f]+$/i,Te=function(e,t){return me(he.call(e,2),t)},Ee=function(e,t){return function(e){return Se.call(we,e)}(t)?e(Te(t,2)):function(e){return Se.call(je,e)}(t)?e(Te(t,8)):null},Pe=function(e,t){var n=Ee(e,t);if(null!==n)return n;if(function(e){return Se.call(Oe,e)}(t)||function(e){return Se.call(xe,e)}(t))return NaN;var r=X(t);return r!==t?e(r):null},Fe=function e(t){var n=function(e){if(l()(e))throw new TypeError("Cannot convert a Symbol value to a number");return e}(le(t,ve));if("string"==typeof n){var r=Pe(e,n);if(null!==r)return r}return ve(n)},Ne=function(e){return e!=e},Me=function(e){return"number"==typeof e&&!1===Ne(e)&&e!==1/0&&e!==-1/0},ke=function(e){var t=Fe(e);return 0===t||Ne(t)?t:t>0?1:-1},Ce=Math.abs,De=Math.floor,$e=function(e){var t=Fe(e);return Ne(t)?0:0===t||!1===Me(t)?t:ke(t)*De(Ce(t))},_e=function(e){var t=$e(e);return t<=0?0:t>9007199254740991?9007199254740991:t},Re={}.constructor,Ae=function(e){return Re(O(e))},Ie=y&&Symbol.prototype.toString,Xe="function"==typeof Ie&&l.a,qe="".constructor,Le=function(e){return Xe&&Xe(e)?Ie.call(e):qe(e)},Be=function(e){if(!1===Z(e)){var t=b()(e)?Le(e):"#<Object>";throw new TypeError("".concat(t," is not a function"))}return e};function Ge(e){return(Ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var He,Ue=[].reduce,Ve={}.constructor,ze="function"==typeof Ue&&Ue,Je=v(ze)&&r.call([],ze,function(e){return e}).threw&&(!1===(He=r.call(Ve("abc"),ze,function(e,t){return e+t},"x")).threw&&"xabc"===He.value)&&function(){var e=r.call(function(){return arguments}(1,2,3),ze,function(e,t){return e+t},1);return!1===e.threw&&7===e.value}()&&function(){var e=r.call({0:1,1:2,3:3,4:4,length:4},ze,function(e,t){return e+t},2);return!1===e.threw&&8===e.value}()&&function(){var e="undefined"!=typeof document&&document;if(e){var t=e.createDocumentFragment(),n=e.createElement("div");t.appendChild(n);var o=r.call(t.childNodes,ze,function(e,t){return e[e.length]=t,e},[]);return!1===o.threw&&1===o.value.length&&o.value[0]===n}return!0}()&&function(){var e=r.call("ab",ze,function(e,t,n,r){return r});return!1===e.threw&&"object"===Ge(e.value)}()?function(e,t){O(e);var n=[Be(t)];return arguments.length>2&&(n[1]=arguments[2]),ze.apply(e,n)}:function(e,t){var n=Ae(e);Be(t);var r=a(n),o=_e(r.length),i=arguments.length;if(0===o&&i<3)throw new TypeError("Reduce of empty array with no initial value");var c,u=0;if(i>2)c=arguments[2];else for(;;){if(u in r){c=r[u],u+=1;break}if((u+=1)>=o)throw new TypeError("Reduce of empty array with no initial value")}for(;u<o;)u in r&&(c=t(c,r[u],u,n)),u+=1;return c};t.default=Je}])}); | ||
*/e.exports=function(e){return"object"==typeof e?null===e:"function"!=typeof e}},function(e,t,n){"use strict";var r=String.prototype.valueOf,o=Object.prototype.toString,i="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;e.exports=function(e){return"string"==typeof e||"object"==typeof e&&(i?function(e){try{return r.call(e),!0}catch(e){return!1}}(e):"[object String]"===o.call(e))}},function(e,t,n){"use strict";var r=Date.prototype.getDay,o=Object.prototype.toString,i="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;e.exports=function(e){return"object"==typeof e&&null!==e&&(i?function(e){try{return r.call(e),!0}catch(e){return!1}}(e):"[object Date]"===o.call(e))}},function(e,t,n){"use strict";(function(t){var r=t.Symbol,o=n(6);e.exports=function(){return"function"==typeof r&&("function"==typeof Symbol&&("symbol"==typeof r("foo")&&("symbol"==typeof Symbol("bar")&&o())))}}).call(this,n(5))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),n=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},function(e,t,n){"use strict";n.r(t);var r=function(e){try{for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return{threw:!1,value:e.apply(this,n)}}catch(e){return{threw:!0,value:e}}},o={}.constructor("a"),i="a"===o[0]&&0 in o,c=n(2),u="".split,s=!1===i&&"function"==typeof u&&n.n(c).a,a=function(e){return s&&s(e)?u.call(e,""):e},f=n(0),l=n.n(f);for(var p=r(function(){return function(e,t){if(e!==t)throw new TypeError("Cannot instantiate an arrow function")}(this,void 0),"function"==typeof Symbol&&l()(Symbol(""))}.bind(void 0)),y=!1===p.threw&&!0===p.value,d=n(1),b=n.n(d),g=n(3),m=n.n(g),v=function(e){return!!e},h={}.toString,w=function(e){return null===e?"[object Null]":void 0===e?"[object Undefined]":h.call(e)},S=y&&l()(Symbol.toStringTag),j=function(e){return null==e},O=function(e){if(j(e))throw new TypeError("Cannot call method on ".concat(e));return e},x="Cannot convert a Symbol value to a string",T=x.constructor,E=function(e){if(l()(e))throw new TypeError(x);return T(e)},P=function(e){return E(O(e))},F=[{code:9,description:"Tab",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\t"},{code:10,description:"Line Feed",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\n"},{code:11,description:"Vertical Tab",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\v"},{code:12,description:"Form Feed",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\f"},{code:13,description:"Carriage Return",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\r"},{code:32,description:"Space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:160,description:"No-break space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:5760,description:"Ogham space mark",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:6158,description:"Mongolian vowel separator",es5:!0,es2015:!0,es2016:!0,es2017:!1,es2018:!1,string:""},{code:8192,description:"En quad",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8193,description:"Em quad",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8194,description:"En space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8195,description:"Em space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8196,description:"Three-per-em space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8197,description:"Four-per-em space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8198,description:"Six-per-em space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8199,description:"Figure space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8200,description:"Punctuation space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8201,description:"Thin space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8202,description:"Hair space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8232,description:"Line separator",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\u2028"},{code:8233,description:"Paragraph separator",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\u2029"},{code:8239,description:"Narrow no-break space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:8287,description:"Medium mathematical space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:12288,description:"Ideographic space",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:" "},{code:65279,description:"Byte Order Mark",es5:!0,es2015:!0,es2016:!0,es2017:!0,es2018:!0,string:"\ufeff"}],N="",M=F.length,k=0;k<M;k+=1)F[k].es2016&&F[k].string,F[k].es2018&&(N+=F[k].string);var C=N,D=new(0,/none/.constructor)("^[".concat(C,"]+")),$="".replace,_=function(e){return $.call(P(e),D,"")},R=new(0,/none/.constructor)("[".concat(C,"]+$")),A="".replace,I=function(e){return A.call(P(e),R,"")},X=function(e){return _(I(e))},q=new(0,/none/.constructor)("[".concat(C,"]+"),"g"),L=" ".replace,B=function(e){return L.call(X(e),q," ")},G=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,H="".replace,U=function(e,t){return H.call(P(e),G,arguments.length>1?E(t):"")},V=r.constructor,z=r.toString,J=/^class /,K=J.test,Q=!1===r(function(){return V('"use strict"; return class My {};')()}).threw,W=function(e){return K.call(J,B(U(z.call(e)," ")))},Y=function(e){var t=r(W,e);return!1===t.threw&&t.value},Z=function(e,t){return!b()(e)&&(S?function(e,t){return!(Q&&!1===t&&Y(e)||!1!==r.call(e,z).threw)}(e,v(t)):(!Q||!1!==v(t)||!Y(e))&&function(e){var t=w(e);return"[object Function]"===t||"[object GeneratorFunction]"===t||"[object AsyncFunction]"===t}(e))},ee="string".constructor,te=(0).constructor,ne=y&&Symbol.toPrimitive,re=y&&Symbol.prototype.valueOf,oe=["toString","valueOf"],ie=["valueOf","toString"],ce=function(e,t){O(e),function(e){if("string"!=typeof e||"number"!==e&&"string"!==e)throw new TypeError('hint must be "string" or "number"')}(t);for(var n,r,o="string"===t?oe:ie,i=0;i<2;i+=1)if(n=e[o[i]],Z(n)&&(r=n.call(e),b()(r)))return r;throw new TypeError("No default value")},ue=function(e,t){if(t){if(e===ee)return"string";if(e===te)return"number"}return"default"},se=function(e){if(y){if(ne)return function(e,t){var n=e[t];if(!1===j(n)){if(!1===Z(n))throw new TypeError("".concat(n," returned for property ").concat(t," of object ").concat(e," is not a function"));return n}}(e,ne);if(l()(e))return re}},ae=function(e){var t=e.exoticToPrim,n=e.input,r=e.hint,o=t.call(n,r);if(b()(o))return o;throw new TypeError("unable to convert exotic object to primitive")},fe=function(e,t){var n="default"===t&&(m()(e)||l()(e))?"string":t;return ce(e,"default"===n?"number":n)},le=function(e,t){if(b()(e))return e;var n=ue(t,arguments.length>1),r=se(e);return void 0===r?fe(e,n):ae({exoticToPrim:r,input:e,hint:n})},pe=parseInt,ye=(0).constructor,de="".charAt,be=/^[-+]?0[xX]/,ge=be.test,me=function(e,t){var n=_(E(e));return""===de.call(n,0)?NaN:pe(n,ye(t)||(ge.call(be,n)?16:10))},ve=2..constructor,he="Cannot convert a Symbol value to a number".slice,we=/^0b[01]+$/i,Se=we.test,je=/^0o[0-7]+$/i,Oe=new(0,we.constructor)("[ ]","g"),xe=/^[-+]0x[0-9a-f]+$/i,Te=function(e,t){return me(he.call(e,2),t)},Ee=function(e,t){return function(e){return Se.call(we,e)}(t)?e(Te(t,2)):function(e){return Se.call(je,e)}(t)?e(Te(t,8)):null},Pe=function(e,t){var n=Ee(e,t);if(null!==n)return n;if(function(e){return Se.call(Oe,e)}(t)||function(e){return Se.call(xe,e)}(t))return NaN;var r=X(t);return r!==t?e(r):null},Fe=function e(t){var n=function(e){if(l()(e))throw new TypeError("Cannot convert a Symbol value to a number");return e}(le(t,ve));if("string"==typeof n){var r=Pe(e,n);if(null!==r)return r}return ve(n)},Ne=function(e){return e!=e},Me=function(e){return"number"==typeof e&&!1===Ne(e)&&e!==1/0&&e!==-1/0},ke=function(e){var t=Fe(e);return 0===t||Ne(t)?t:t>0?1:-1},Ce=Math.abs,De=Math.floor,$e=function(e){var t=Fe(e);return Ne(t)?0:0===t||!1===Me(t)?t:ke(t)*De(Ce(t))},_e=function(e){var t=$e(e);return t<=0?0:t>9007199254740991?9007199254740991:t},Re={}.constructor,Ae=function(e){return Re(O(e))},Ie=y&&Symbol.prototype.toString,Xe="function"==typeof Ie&&l.a,qe="".constructor,Le=function(e){return Xe&&Xe(e)?Ie.call(e):qe(e)},Be=function(e){if(!1===Z(e)){var t=b()(e)?Le(e):"#<Object>";throw new TypeError("".concat(t," is not a function"))}return e};function Ge(e){return(Ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}n.d(t,"implementation",function(){return Je});var He,Ue=[].reduce,Ve="function"==typeof Ue&&Ue,ze=v(Ve)&&r.call([],Ve,function(e){return e}).threw&&(!1===(He=r.call(Ae("abc"),Ve,function(e,t){return e+t},"x")).threw&&"xabc"===He.value)&&function(){var e=r.call(function(){return arguments}(1,2,3),Ve,function(e,t){return e+t},1);return!1===e.threw&&7===e.value}()&&function(){var e=r.call({0:1,1:2,3:3,4:4,length:4},Ve,function(e,t){return e+t},2);return!1===e.threw&&8===e.value}()&&function(){var e="undefined"!=typeof document&&document;if(e){var t=e.createDocumentFragment(),n=e.createElement("div");t.appendChild(n);var o=r.call(t.childNodes,Ve,function(e,t){return e[e.length]=t,e},[]);return!1===o.threw&&1===o.value.length&&o.value[0]===n}return!0}()&&function(){var e=r.call("ab",Ve,function(){return arguments[3]});return!1===e.threw&&"object"===Ge(e.value)}(),Je=function(e,t){var n=Ae(e);Be(t);var r=a(n),o=_e(r.length),i=arguments.length;if(0===o&&i<3)throw new TypeError("Reduce of empty array with no initial value");var c,u=0;if(i>2)c=arguments[2];else for(;;){if(u in r){c=r[u],u+=1;break}if((u+=1)>=o)throw new TypeError("Reduce of empty array with no initial value")}for(;u<o;)u in r&&(c=t(c,r[u],u,n)),u+=1;return c},Ke=ze?function(e,t){O(e);var n=[Be(t)];return arguments.length>2&&(n[1]=arguments[2]),Ve.apply(e,n)}:Je;t.default=Ke}])}); | ||
//# sourceMappingURL=array-reduce-x.min.js.map |
{ | ||
"name": "array-reduce-x", | ||
"version": "3.0.16", | ||
"version": "3.0.17", | ||
"description": "Reduce an array (from left to right) to a single value.", | ||
@@ -70,3 +70,3 @@ "homepage": "https://github.com/Xotic750/array-reduce-x", | ||
"@types/jest": "^24.0.16", | ||
"@types/node": "^12.6.8", | ||
"@types/node": "^12.6.9", | ||
"@xotic750/eslint-config-recommended": "^1.0.5", | ||
@@ -112,3 +112,3 @@ "babel-core": "^7.0.0-0", | ||
"typescript": "^3.5.3", | ||
"webpack": "^4.38.0", | ||
"webpack": "^4.39.1", | ||
"webpack-bundle-analyzer": "^3.4.1", | ||
@@ -115,0 +115,0 @@ "webpack-cli": "^3.3.6", |
@@ -10,3 +10,2 @@ import attempt from 'attempt-x'; | ||
const natRed = [].reduce; | ||
const castObject = {}.constructor; | ||
const nativeReduce = typeof natRed === 'function' && natRed; | ||
@@ -22,3 +21,3 @@ | ||
const res = attempt.call( | ||
castObject('abc'), | ||
toObject('abc'), | ||
nativeReduce, | ||
@@ -52,9 +51,3 @@ function attemptee(acc, c) { | ||
const res = attempt.call( | ||
{ | ||
0: 1, | ||
1: 2, | ||
3: 3, | ||
4: 4, | ||
length: 4, | ||
}, | ||
{0: 1, 1: 2, 3: 3, 4: 4, length: 4}, | ||
nativeReduce, | ||
@@ -77,13 +70,11 @@ function attempte(acc, arg) { | ||
fragment.appendChild(div); | ||
const res = attempt.call( | ||
fragment.childNodes, | ||
nativeReduce, | ||
function attempte(acc, node) { | ||
acc[acc.length] = node; | ||
return acc; | ||
}, | ||
[], | ||
); | ||
const atemptee = function attempte(acc, node) { | ||
acc[acc.length] = node; | ||
return acc; | ||
}; | ||
const res = attempt.call(fragment.childNodes, nativeReduce, atemptee, []); | ||
return res.threw === false && res.value.length === 1 && res.value[0] === div; | ||
@@ -96,4 +87,5 @@ } | ||
const test6 = function test6() { | ||
const res = attempt.call('ab', nativeReduce, function attempte(_, __, ___, list) { | ||
return list; | ||
const res = attempt.call('ab', nativeReduce, function attempte() { | ||
/* eslint-disable-next-line prefer-rest-params */ | ||
return arguments[3]; | ||
}); | ||
@@ -109,63 +101,59 @@ | ||
const patchedReduce = function patchedReduce() { | ||
return function reduce(array, callBack /* , initialValue */) { | ||
requireObjectCoercible(array); | ||
const args = [assertIsFunction(callBack)]; | ||
const patchedReduce = function reduce(array, callBack /* , initialValue */) { | ||
requireObjectCoercible(array); | ||
const args = [assertIsFunction(callBack)]; | ||
if (arguments.length > 2) { | ||
/* eslint-disable-next-line prefer-rest-params,prefer-destructuring */ | ||
args[1] = arguments[2]; | ||
} | ||
if (arguments.length > 2) { | ||
/* eslint-disable-next-line prefer-rest-params,prefer-destructuring */ | ||
args[1] = arguments[2]; | ||
} | ||
return nativeReduce.apply(array, args); | ||
}; | ||
return nativeReduce.apply(array, args); | ||
}; | ||
const implementation = function implementation() { | ||
return function reduce(array, callBack /* , initialValue */) { | ||
const object = toObject(array); | ||
// If no callback function or if callback is not a callable function | ||
assertIsFunction(callBack); | ||
const iterable = splitIfBoxedBug(object); | ||
const length = toLength(iterable.length); | ||
const argsLength = arguments.length; | ||
export const implementation = function reduce(array, callBack /* , initialValue */) { | ||
const object = toObject(array); | ||
// If no callback function or if callback is not a callable function | ||
assertIsFunction(callBack); | ||
const iterable = splitIfBoxedBug(object); | ||
const length = toLength(iterable.length); | ||
const argsLength = arguments.length; | ||
// no value to return if no initial value and an empty array | ||
if (length === 0 && argsLength < 3) { | ||
throw new TypeError('Reduce of empty array with no initial value'); | ||
} | ||
// no value to return if no initial value and an empty array | ||
if (length === 0 && argsLength < 3) { | ||
throw new TypeError('Reduce of empty array with no initial value'); | ||
} | ||
let i = 0; | ||
let result; | ||
let i = 0; | ||
let result; | ||
if (argsLength > 2) { | ||
/* eslint-disable-next-line prefer-rest-params,prefer-destructuring */ | ||
result = arguments[2]; | ||
} else { | ||
do { | ||
if (i in iterable) { | ||
result = iterable[i]; | ||
i += 1; | ||
break; | ||
} | ||
// if array contains no values, no initial value to return | ||
if (argsLength > 2) { | ||
/* eslint-disable-next-line prefer-rest-params,prefer-destructuring */ | ||
result = arguments[2]; | ||
} else { | ||
do { | ||
if (i in iterable) { | ||
result = iterable[i]; | ||
i += 1; | ||
break; | ||
} | ||
if (i >= length) { | ||
throw new TypeError('Reduce of empty array with no initial value'); | ||
} | ||
} while (true); /* eslint-disable-line no-constant-condition */ | ||
} | ||
// if array contains no values, no initial value to return | ||
i += 1; | ||
while (i < length) { | ||
if (i in iterable) { | ||
result = callBack(result, iterable[i], i, object); | ||
if (i >= length) { | ||
throw new TypeError('Reduce of empty array with no initial value'); | ||
} | ||
} while (true); /* eslint-disable-line no-constant-condition */ | ||
} | ||
i += 1; | ||
while (i < length) { | ||
if (i in iterable) { | ||
result = callBack(result, iterable[i], i, object); | ||
} | ||
return result; | ||
}; | ||
i += 1; | ||
} | ||
return result; | ||
}; | ||
@@ -188,4 +176,4 @@ | ||
*/ | ||
const $reduce = isWorking ? patchedReduce() : implementation(); | ||
const $reduce = isWorking ? patchedReduce : implementation; | ||
export default $reduce; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
230232
-0.51%1781
-1.06%