array-reduce-right-x
Version:
Reduce an array (from right to left) to a single value.
15 lines • 16.6 kB
JavaScript
/*!
{
"author": "Graham Fairweather",
"copywrite": "Copyright (c) 2017",
"date": "2019-08-28T17:47:16.546Z",
"describe": "",
"description": "Reduce an array (from right to left) to a single value.",
"file": "array-reduce-right-x.min.js",
"hash": "36f8b8f2331e402186ba",
"license": "MIT",
"version": "3.1.2"
}
*/
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.arrayReduceRightX=n():t.arrayReduceRightX=n()}(function(){"use strict";var t,n={}.constructor,e=n.prototype,r=n.defineProperty,o=function(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0},i=function(){return this};try{return r?r(e,"$$globalThis$$",{get:i,configurable:!0}):e.__defineGetter__("$$globalThis$$",i),t="undefined"==typeof $$globalThis$$?o():$$globalThis$$,delete e.$$globalThis$$,t}catch(t){return o()}}(),function(){return function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=6)}([function(t,n,e){"use strict";var r=Object.prototype.toString;if(e(3)()){var o=Symbol.prototype.toString,i=/^Symbol\(.*\)$/;t.exports=function(t){if("symbol"==typeof t)return!0;if("[object Symbol]"!==r.call(t))return!1;try{return function(t){return"symbol"==typeof t.valueOf()&&i.test(o.call(t))}(t)}catch(t){return!1}}}else t.exports=function(t){return!1}},function(t,n,e){"use strict";var r=String.prototype.valueOf,o=Object.prototype.toString,i="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){return"string"==typeof t||"object"==typeof t&&(i?function(t){try{return r.call(t),!0}catch(t){return!1}}(t):"[object String]"===o.call(t))}},function(t,n,e){"use strict";var r=Date.prototype.getDay,o=Object.prototype.toString,i="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){return"object"==typeof t&&null!==t&&(i?function(t){try{return r.call(t),!0}catch(t){return!1}}(t):"[object Date]"===o.call(t))}},function(t,n,e){"use strict";(function(n){var r=n.Symbol,o=e(5);t.exports=function(){return"function"==typeof r&&("function"==typeof Symbol&&("symbol"==typeof r("foo")&&("symbol"==typeof Symbol("bar")&&o())))}}).call(this,e(4))},function(t,n){var e;e=function(){return this}();try{e=e||new Function("return this")()}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,n,e){"use strict";t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},n=Symbol("test"),e=Object(n);if("string"==typeof n)return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;for(n in t[n]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var r=Object.getOwnPropertySymbols(t);if(1!==r.length||r[0]!==n)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,n))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(t,n);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},function(t,n,e){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}e.r(n);var o=function(t){return"object"===r(t)?null===t:"function"!=typeof t},i=e(1),u=e.n(i),c={}.constructor("a"),s="a"===c[0]&&0 in c,f=function(){}.bind,a="function"==typeof f&&function(){var t=null,n=null,e=null,r=[];try{var o=f.apply(function(r,o){return e=this,t=r,n=o,arguments},[r,1]),i=o(2);return 1===o.length&&2===i.length&&1===t&&2===n&&e===r}catch(t){return!1}}()&&function(){var t=null,n=null,e=null,r=[1,2,3],o=function(o,i){return t=o,n=i,e=this,r};try{var i=f.apply(o,[null]),u=new i(1,2);return i.length===o.length&&u===r&&1===t&&2===n&&e!==r}catch(t){return!1}}(),l="".split,p=Math.max,y=o.bind,b=o.call,d=a?y.call(b,l):function(t,n){return l.call(t,n)},g=function(t){return u()(t)?d(t,""):t},h=function(t,n){var e=arguments.length>2?arguments[2]:[];if("string"!=typeof t&&o(t))return e;for(var r=s?t:g(t),i=r.length,u=p(0,n)||0;u<i;u+=1)e[e.length]=t[u];return e};function v(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var e=[],r=!0,o=!1,i=void 0;try{for(var u,c=t[Symbol.iterator]();!(r=(u=c.next()).done)&&(e.push(u.value),!n||e.length!==n);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return e}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var m=h.bind,w=h.call,S={},j=S.constructor,O=S.toString,T=function(t,n){return t>=n?t:n},x=function(t){if("function"!=typeof t&&"[object Function]"!==O.apply(t))throw new TypeError("bind called on incompatible "+t)},$=[function(t){return function(){return t.apply(this,h(arguments))}},function(t,n){return function(e){return t.apply(this,h(arguments,n,[e]))}},function(t,n){return function(e,r){return t.apply(this,h(arguments,n,[e,r]))}},function(t,n){return function(e,r,o){return t.apply(this,h(arguments,n,[e,r,o]))}},function(t,n){return function(e,r,o,i){return t.apply(this,h(arguments,n,[e,r,o,i]))}},function(t,n){return function(e,r,o,i,u){return t.apply(this,h(arguments,n,[e,r,o,i,u]))}},function(t,n){return function(e,r,o,i,u,c){return t.apply(this,h(arguments,n,[e,r,o,i,u,c]))}},function(t,n){return function(e,r,o,i,u,c,s){return t.apply(this,h(arguments,n,[e,r,o,i,u,c,s]))}},function(t,n){return function(e,r,o,i,u,c,s,f){return t.apply(this,h(arguments,n,[e,r,o,i,u,c,s,f]))}}],E=function(t){var n=v(t,3),e=n[0],r=n[1],o=n[2],i=T(0,r.length-T(0,o.length-2)),u=$[i],c=u?u(e,i):$[0](e);if(r.prototype){var s=function(){};s.prototype=r.prototype,c.prototype=new s,s.prototype=null}return c},P=function(t,n){var e=t.apply(this,n);return j(e)===e?e:this},F=a?w.bind(m):function(t,n){x(t);var e,r=arguments,o=function(){var o=h(arguments,0,h(r,2));return this instanceof e?P.apply(this,[t,o]):t.apply(n,o)};return e=E([o,t,r])},M=TypeError,N=F.apply,_=F(F.call,N),C=F(N,{}.toString),R=function(t){if("function"!=typeof t&&"[object Function]"!==C(t))throw new M(t+" is not a function");return t},k=function(t,n){return _(R(t),n,h(arguments[2]))},D=function(t){try{return{threw:!1,value:k(t,this,h(arguments,1))}}catch(t){return{threw:!0,value:t}}},A={}.toString,I=function(t){return function(t){if("function"!=typeof t&&"[object Function]"!==k(A,t))throw new TypeError("methodize called on incompatible "+t)}(t),function(){return k(t,arguments[0],h(arguments,1))}},X=I("".split),q=function(t){return t},G=s?q:function(t){return u()(t)?X(t,""):q(t)},L=e(0),z=e.n(L);for(var B=D(function(){return function(t,n){if(t!==n)throw new TypeError("Cannot instantiate an arrow function")}(this,void 0),"function"==typeof Symbol&&z()(Symbol(""))}.bind(void 0)),H=!1===B.threw&&!0===B.value,U=e(2),V=e.n(U),J=function(t){return!!t},K=I({}.toString),Q=function(t){return null===t?"[object Null]":void 0===t?"[object Undefined]":K(t)},W=H&&z()(Symbol.toStringTag),Y=function(t){return null==t},Z=function(t){if(Y(t))throw new TypeError("Cannot call method on ".concat(t));return t},tt="Cannot convert a Symbol value to a string".constructor,nt=function(t){if(z()(t))throw new TypeError("Cannot convert a Symbol value to a string");return tt(t)},et=function(t){return nt(Z(t))},rt=[{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"}],ot="",it=rt.length,ut=0;ut<it;ut+=1)rt[ut].es2016&&rt[ut].string,rt[ut].es2018&&(ot+=rt[ut].string);var ct=ot,st=new(0,/none/.constructor)("^[".concat(ct,"]+")),ft=I("".replace),at=function(t){return ft(et(t),st,"")},lt=new(0,/none/.constructor)("[".concat(ct,"]+$")),pt=I("".replace),yt=function(t){return pt(et(t),lt,"")},bt=function(t){return at(yt(t))},dt=new(0,/none/.constructor)("[".concat(ct,"]+"),"g"),gt=I(" ".replace),ht=function(t){return gt(bt(t),dt," ")},vt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,mt=I("".replace),wt=function(t,n){return mt(et(t),vt,arguments.length>1?nt(n):"")},St=D.constructor,jt=I(D.toString),Ot=/^class /,Tt=I(Ot.test),xt=!1===D(function(){return St('"use strict"; return class My {};')()}).threw,$t=function(t){return Tt(Ot,ht(wt(jt(t)," ")))},Et=function(t){var n=D($t,t);return!1===n.threw&&n.value},Pt=function(t,n){return!o(t)&&(W?function(t,n){return!(xt&&!1===n&&Et(t)||!1!==D(function(){return jt(t)}).threw)}(t,J(n)):(!xt||!1!==J(n)||!Et(t))&&function(t){var n=Q(t);return"[object Function]"===n||"[object GeneratorFunction]"===n||"[object AsyncFunction]"===n}(t))},Ft="string".constructor,Mt=(0).constructor,Nt=H&&Symbol.toPrimitive,_t=H&&Symbol.prototype.valueOf,Ct=["toString","valueOf"],Rt=["valueOf","toString"],kt=function(t,n){Z(t),function(t){if("string"!=typeof t||"number"!==t&&"string"!==t)throw new TypeError('hint must be "string" or "number"')}(n);for(var e="string"===n?Ct:Rt,r=0;r<2;r+=1){var i=t[e[r]];if(Pt(i)){var u=k(i,t);if(o(u))return u}}throw new TypeError("No default value")},Dt=function(t,n){if(n){if(t===Ft)return"string";if(t===Mt)return"number"}return"default"},At=function(t){if(H){if(Nt)return function(t,n){var e=t[n];if(!1===Y(e)){if(!1===Pt(e))throw new TypeError("".concat(e," returned for property ").concat(n," of object ").concat(t," is not a function"));return e}}(t,Nt);if(z()(t))return _t}},It=function(t){var n=t.exoticToPrim,e=t.input,r=t.hint,i=k(n,e,[r]);if(o(i))return i;throw new TypeError("unable to convert exotic object to primitive")},Xt=function(t,n){var e="default"===n&&(V()(t)||z()(t))?"string":n;return kt(t,"default"===e?"number":e)},qt=function(t,n){if(o(t))return t;var e=Dt(n,arguments.length>1),r=At(t);return void 0===r?Xt(t,e):It({exoticToPrim:r,input:t,hint:e})},Gt=parseInt,Lt=(0).constructor,zt=I("".charAt),Bt=/^[-+]?0[xX]/,Ht=I(Bt.test),Ut=function(t,n){var e=at(nt(t));return""===zt(e,0)?NaN:Gt(e,Lt(n)||(Ht(Bt,e)?16:10))},Vt=2..constructor,Jt=I("Cannot convert a Symbol value to a number".slice),Kt=/^0b[01]+$/i,Qt=Kt.constructor,Wt=I(Kt.test),Yt=/^0o[0-7]+$/i,Zt=new Qt("[
]","g"),tn=/^[-+]0x[0-9a-f]+$/i,nn=function(t,n){return Ut(Jt(t,2),n)},en=function(t,n){return function(t){return Wt(Kt,t)}(n)?t(nn(n,2)):function(t){return Wt(Yt,t)}(n)?t(nn(n,8)):null},rn=function(t,n){var e=en(t,n);if(null!==e)return e;if(function(t){return Wt(Zt,t)}(n)||function(t){return Wt(tn,t)}(n))return NaN;var r=bt(n);return r!==n?t(r):null},on=function t(n){var e=function(t){if(z()(t))throw new TypeError("Cannot convert a Symbol value to a number");return t}(qt(n,Vt));if("string"==typeof e){var r=rn(t,e);if(null!==r)return r}return Vt(e)},un=function(t){return t!=t},cn=function(t){return"number"==typeof t&&!1===un(t)&&t!==1/0&&t!==-1/0},sn=function(t){var n=on(t);return 0===n||un(n)?n:n>0?1:-1},fn=Math.abs,an=Math.floor,ln=function(t){var n=on(t);return un(n)?0:0===n||!1===cn(n)?n:sn(n)*an(fn(n))},pn=function(t){var n=ln(t);return n<=0?0:n>9007199254740991?9007199254740991:n},yn={}.constructor,bn=function(t){return yn(Z(t))},dn=H&&Symbol.prototype.toString,gn="function"==typeof dn&&z.a,hn="".constructor,vn=function(t){return gn&&gn(t)?dn.call(t):hn(t)},mn=function(t,n){if(!1===Pt(t)){var e=arguments.length>1?vn(n):"".concat(o(t)?vn(t):"#<Object>"," is not a function");throw new TypeError(e)}return t};function wn(t){return(wn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}e.d(n,"implementation",function(){return En});var Sn,jn=[].reduceRight,On="function"==typeof jn&&I(jn),Tn="undefined"!=typeof document&&document,xn=function(t,n){return t[t.length]=n,t},$n=J(On)&&D(function(){return On([],function(t){return t})}).threw&&(!1===(Sn=D(function(){return On(bn("abc"),function(t,n){return t+n},"x")})).threw&&"xcba"===Sn.value)&&function(){var t=D(function(){var t=function(){return arguments}(1,2,3);return On(t,function(t,n){return t+n},1)});return!1===t.threw&&7===t.value}()&&function(){var t=D(function(){return On({0:1,1:2,3:3,4:4,length:4},function(t,n){return t+n},2)});return!1===t.threw&&8===t.value}()&&function(){if(Tn){var t=Tn.createDocumentFragment(),n=Tn.createElement("div");t.appendChild(n);var e=D(function(){return On(t.childNodes,xn,[])});return!1===e.threw&&1===e.value.length&&e.value[0]===n}return!0}()&&function(){var t=D(function(){return On("ab",function(){return arguments[3]})});return!1===t.threw&&"object"===wn(t.value)}(),En=function(t,n){var e=bn(t);mn(n);var r,o=G(e),i=pn(o.length),u=arguments.length;if(0===i&&u<3)throw new TypeError("Reduce of empty array with no initial value");var c=i-1;if(u>2)r=arguments[2];else for(;;){if(c in o){r=o[c],c-=1;break}if((c-=1)<0)throw new TypeError("Reduce of empty array with no initial value")}for(;c>=0;)c in o&&(r=n(r,o[c],c,e)),c-=1;return r},Pn=$n?function(t,n){return Z(t),mn(n),arguments.length>2?On(t,n,arguments[2]):On(t,n)}:En;n.default=Pn}])});
//# sourceMappingURL=array-reduce-right-x.min.js.map