@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 2.61 kB
JavaScript
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
import r from"./define-nonenumerable-read-only-property.js";import t from"./copy.js";import e from"./../assert/is-array.js";import o from"./../constants/math/float64-max.js";import n from"./../assert/is-plain-object.js";import i from"./../assert/has-own-property.js";import a from"./../assert/is-boolean.js";import p from"./../assert/is-nonnegative-integer.js";import s from"./../assert/is-positive-integer-array.js";var u=o,m={copy:!1,depth:u},f=n,y=i,v=a.isPrimitive,c=p.isPrimitive;function l(r,t){return f(t)?y(t,"depth")&&(r.depth=t.depth,!c(r.depth))?new TypeError("invalid option. `depth` option must be a nonnegative integer. Option: `"+r.depth+"`."):y(t,"copy")&&(r.copy=t.copy,!v(r.copy))?new TypeError("invalid option. `copy` option must be a boolean primitive. Option: `"+r.copy+"`."):null:new TypeError("invalid argument. Options argument must be an object. Value: `"+t+"`.")}var h=e;function d(r,t,e){var o,n;for(n=0;n<t.length;n++)o=t[n],e&&h(o)?d(r,o,e-1):r.push(o);return r}var g=t,w=e,b=m,j=l,E=d;function T(r,t){var e,o,n;if(!w(r))throw new TypeError("invalid argument. First argument must be an array. Value: `"+r+"`.");if(e={copy:b.copy,depth:b.depth},arguments.length>1&&(o=j(e,t)))throw o;return n=0===e.depth?r:E([],r,e.depth),e.copy?g(n):n}function V(r){var t,e,o,n;for(o="return function flattenArray(x){",e=(t=r.length)-1,o+="var o=[];var ",n=0;n<t;n++)o+="i"+n,o+=n<e?",":";";for(n=0;n<t;n++)o+="for(i"+n+"=0;i"+n+"<"+r[n]+";i"+n+"++){";for(o+="o.push(x",n=0;n<t;n++)o+="[i"+n+"]";for(o+=");",n=0;n<t;n++)o+="}";return o+="return o;",o+="}",o+="//# sourceURL=flatten_array.gen_fcn.js",new Function(o)()}var O=e;function x(r){return function(t){if(!O(t))throw new TypeError("invalid argument. Must provide an array. Value: `"+t+"`.");return r(t)}}var F=e,P=t;function M(r){return function(t){if(!F(t))throw new TypeError("invalid argument. Must provide an array. Value: `"+t+"`.");return P(r(t))}}var _=s.primitives,A=n,L=i,R=a.isPrimitive,U=m,k=V,q=x,z=M;function B(r,t){var e,o;if(!_(r))throw new TypeError("invalid argument. First argument must be an array of positive integers. Value: `"+r+"`.");if(e=U.copy,arguments.length>1){if(!A(t))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+t+"`.");if(L(t,"copy")&&(e=t.copy,!R(e)))throw new TypeError("invalid option. `copy` option must be a boolean primitive. Option: `"+e+"`.")}return o=k(r),e?z(o):q(o)}var C=r,D=T,G=B;C(D,"factory",G);export default D;
//# sourceMappingURL=flatten-array.js.map