ndarray-methods
Version:
Convenient methods for JavaScript built-in multi-dimensional arrays.
2 lines • 7.71 kB
JavaScript
!function(){"use strict";var n={608:function(n,e){var t=this&&this.__spreadArray||function(n,e,t){if(t||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return n.concat(r||Array.prototype.slice.call(e))};function r(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.call.apply(n,e)}}Object.defineProperty(e,"__esModule",{value:!0}),e.nestedEveryFromLast=e.nestedEvery=e.nestedSomeFromLast=e.nestedSome=e.nestedFindLastIndex=e.nestedFindIndex=e.nestedFindLast=e.nestedFind=e.nestedLastIndexOf=e.nestedIndexOf=e.nestedIncludesFromLast=e.nestedIncludes=e.nestedFillMap=e.nestedFill=e.nestedJoin=e.nestedSplit=e.nestedForEach=e.nestedMap=e.shapeAtOrigin=e.shape=e.buildShape=void 0;var i=r(Object.prototype.hasOwnProperty),o=Array.prototype,u=r(o.forEach),a=r(o.map),l=r(o.reduce);function c(n){return!!Array.isArray(n)||!(!n||"object"!=typeof n||!i(n,"length")||"number"!=typeof n.length)&&(!n.length||n.length>0&&i(n,n.length-1))}function f(n){if(!n.length)throw new RangeError("The length of the array must not be zero")}function d(n){if(n<1)throw new RangeError("maxDepth argument must be at least 1");return Math.floor(n)}function v(n,e){return void 0===n||n===-1/0?0:n>=0?~~n:Math.max(e.length+~~n,0)}function s(n,e){return void 0===n||n===1/0?e.length-1:n>=0?Math.min(~~n,e.length-1):e.length+~~n}function h(n,e){return void 0===n||n===1/0?e.length:n>=0?Math.min(~~n,e.length):e.length+~~n}e.buildShape=function(n,e,r){return f(n),function(n){try{return u([],n),!0}catch(n){return!1}}(e)?function n(e,i){var o=e[0],u=e.slice(1);return Array.from({length:o},u.length?function(e,r){return n(u,(function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return i.apply(void 0,t([r],n,!1))}))}:function(n,e){return i.call(r,e)})}(n,e):function n(e,t){var r=e[0],i=e.slice(1);return Array.from({length:r},i.length?function(){return n(i,t)}:function(){return t})}(n,e)},e.shape=function(n,e){return void 0===e&&(e=1/0),e=d(e),function n(t,r){return l(t,(function(t,i){if(c(i)&&r.length<e){var o=n(i,r.concat(i.length));if(o.length>t.length||o[r.length]>t[r.length])return o}return t}),r)}(n,[n.length])},e.shapeAtOrigin=function(n,e){return void 0===e&&(e=1/0),e=d(e),function n(t,r){var i=t[0];return c(i)&&r.length<e?n(i,r.concat(i.length)):r}(n,[n.length])},e.nestedMap=function(n,e,t,r){return void 0===t&&(t=1/0),t=d(t),function i(o,u){return a(o,(function(a,l){var f=u.concat(l);return c(a)&&f.length<t?i(a,f):e.call(r,a,f,n,o)}))}(n,[])},e.nestedForEach=function(n,e,t,r){void 0===t&&(t=1/0),t=d(t),function i(o,a){u(o,(function(u,l){var f=a.concat(l);c(u)&&f.length<t?i(u,f):e.call(r,u,f,n,o)}))}(n,[])},e.nestedSplit=function(n,e){return f(n),function n(e,t){var r=e[0],i=e.slice(1);return i.length?a(t.split(r),(function(e){return n(i,e)})):t.split(r)}(n,e+"")},e.nestedJoin=function(n,e,t){return void 0===t&&(t=1/0),t=d(t),function e(r,i){return a(r,(function(n){return c(n)&&i+1<t?e(n,i+1):n})).join(n[i])}(e,0)},e.nestedFill=function(n,e,t,r,i){return void 0===t&&(t=[]),void 0===r&&(r=[]),void 0===i&&(i=1/0),i=d(i),function n(o,u){for(var a=v(t[u],o);a<h(r[u],o);a++){var l=o[a];c(l)&&u+1<i?n(l,u+1):o[a]=e}}(n,0),n},e.nestedFillMap=function(n,e,t,r,i,o){return void 0===t&&(t=[]),void 0===r&&(r=[]),void 0===i&&(i=1/0),i=d(i),function u(a,l){for(var f=v(t[l.length],a);f<h(r[l.length],a);f++){var d=a[f],s=l.concat(f);c(d)&&s.length<i?u(d,s):a[f]=e.call(o,d,s,n,a)}}(n,[]),n},e.nestedIncludes=function(n,e,t,r){return void 0===t&&(t=[]),void 0===r&&(r=1/0),r=d(r),function n(i,o){for(var u=v(t[o],i);u<i.length;u++){var a=i[u];if(c(a)&&o+1<r){if(n(a,o+1))return!0}else if(a===e)return!0}return!1}(n,0)},e.nestedIncludesFromLast=function(n,e,t,r){return void 0===t&&(t=[]),void 0===r&&(r=1/0),r=d(r),function n(i,o){for(var u=s(t[o],i);u>=0;u--){var a=i[u];if(c(a)&&o+1<r){if(n(a,o+1))return!0}else if(a===e)return!0}return!1}(n,0)},e.nestedIndexOf=function(n,e,t,r){return void 0===t&&(t=[]),void 0===r&&(r=1/0),r=d(r),function n(i,o){for(var u=v(t[o.length],i);u<i.length;u++){var a=i[u],l=o.concat(u);if(c(a)&&l.length<r){var f=n(a,l);if(f[0])return f}else if(a===e)return[!0,l]}return[!1]}(n,[])[1]},e.nestedLastIndexOf=function(n,e,t,r){return void 0===t&&(t=[]),void 0===r&&(r=1/0),r=d(r),function n(i,o){for(var u=s(t[o.length],i);u>=0;u--){var a=i[u],l=o.concat(u);if(c(a)&&l.length<r){var f=n(a,l);if(f[0])return f}else if(a===e)return[!0,l]}return[!1]}(n,[])[1]},e.nestedFind=function(n,e,t,r,i){return void 0===t&&(t=[]),void 0===r&&(r=1/0),r=d(r),function o(u,a){for(var l=v(t[a.length],u);l<u.length;l++){var f=u[l],d=a.concat(l);if(c(f)&&d.length<r){var s=o(f,d);if(s[0])return s}else if(e.call(i,f,d,n,u))return[!0,f]}return[!1]}(n,[])[1]},e.nestedFindLast=function(n,e,t,r,i){return void 0===t&&(t=[]),void 0===r&&(r=1/0),r=d(r),function o(u,a){for(var l=s(t[a.length],u);l>=0;l--){var f=u[l],d=a.concat(l);if(c(f)&&d.length<r){var v=o(f,d);if(v[0])return v}else if(e.call(i,f,d,n,u))return[!0,f]}return[!1]}(n,[])[1]},e.nestedFindIndex=function(n,e,t,r,i){return void 0===t&&(t=[]),void 0===r&&(r=1/0),r=d(r),function o(u,a){for(var l=v(t[a.length],u);l<u.length;l++){var f=u[l],d=a.concat(l);if(c(f)&&d.length<r){var s=o(f,d);if(s[0])return s}else if(e.call(i,f,d,n,u))return[!0,d]}return[!1]}(n,[])[1]},e.nestedFindLastIndex=function(n,e,t,r,i){return void 0===t&&(t=[]),void 0===r&&(r=1/0),r=d(r),function o(u,a){for(var l=s(t[a.length],u);l>=0;l--){var f=u[l],d=a.concat(l);if(c(f)&&d.length<r){var v=o(f,d);if(v[0])return v}else if(e.call(i,f,d,n,u))return[!0,d]}return[!1]}(n,[])[1]},e.nestedSome=function(n,e,t,r,i){return void 0===t&&(t=[]),void 0===r&&(r=1/0),r=d(r),function o(u,a){for(var l=v(t[a.length],u);l<u.length;l++){var f=u[l],d=a.concat(l);if(c(f)&&d.length<r){if(o(f,d))return!0}else if(e.call(i,f,d,n,u))return!0}return!1}(n,[])},e.nestedSomeFromLast=function(n,e,t,r,i){return void 0===t&&(t=[]),void 0===r&&(r=1/0),r=d(r),function o(u,a){for(var l=s(t[a.length],u);l>=0;l--){var f=u[l],d=a.concat(l);if(c(f)&&d.length<r){if(o(f,d))return!0}else if(e.call(i,f,d,n,u))return!0}return!1}(n,[])},e.nestedEvery=function(n,e,t,r,i){return void 0===t&&(t=[]),void 0===r&&(r=1/0),r=d(r),function o(u,a){for(var l=v(t[a.length],u);l<u.length;l++){var f=u[l],d=a.concat(l);if(c(f)&&d.length<r){if(!o(f,d))return!1}else if(!e.call(i,f,d,n,u))return!1}return!0}(n,[])},e.nestedEveryFromLast=function(n,e,t,r,i){return void 0===t&&(t=[]),void 0===r&&(r=1/0),r=d(r),function o(u,a){for(var l=s(t[a.length],u);l>=0;l--){var f=u[l],d=a.concat(l);if(c(f)&&d.length<r){if(!o(f,d))return!1}else if(!e.call(i,f,d,n,u))return!1}return!0}(n,[])}},498:function(n,e,t){var r=this&&this.__spreadArray||function(n,e,t){if(t||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return n.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0});var i=t(608),o=t(608);Object.entries(i).forEach((function(n){var e=n[0],t=n[1];e in Array.prototype||Object.defineProperty(Array.prototype,e,{value:function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t.apply(void 0,r([this],n,!1))},writable:!0,enumerable:!1,configurable:!0})})),Object.entries({fromShape:o.buildShape,nestedSplit:o.nestedSplit,nestedJoin:o.nestedJoin}).forEach((function(n){var e=n[0],t=n[1];e in Array||Object.defineProperty(Array,e,{value:t,writable:!0,enumerable:!1,configurable:!0})}))}},e={};(function t(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={exports:{}};return n[r].call(o.exports,o,o.exports,t),o.exports})(498)}();
//# sourceMappingURL=polyfill.js.map