UNPKG

@stdlib/esm

Version:

ES module distribution for Stdlib, a standard library for JavaScript and Node.js.

3 lines 1.96 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import e from"./../assert/is-function.js";import r from"./../assert/is-array-like-object.js";import t from"./../assert/is-iterator-like.js";import n from"./../assert/is-integer.js";import a from"./../assert/has-own-property.js";var i=e,o=r,l=t,u=n.isPrimitive,s=a;function m(e,r){var t,n,a,m,f,g,h;if(!l(e))throw new TypeError("invalid argument. First argument must be an iterator protocol-compliant object. Value: `"+e+"`.");if(!o(r))throw new TypeError("invalid argument. Second argument must be an array-like object. Value: `"+r+"`.");if(2===(n=arguments.length))a=0,m=r.length;else if(3===n)i(arguments[2])?(a=0,f=arguments[2]):a=arguments[2],m=r.length;else if(4===n)i(arguments[2])?(a=0,m=r.length,f=arguments[2],t=arguments[3]):i(arguments[3])?(a=arguments[2],m=r.length,f=arguments[3]):(a=arguments[2],m=arguments[3]);else if(5===n){if(a=arguments[2],i(arguments[3]))m=r.length,f=arguments[3],t=arguments[4];else if(m=arguments[3],!i(f=arguments[4]))throw new TypeError("invalid argument. Fifth argument must be a callback function. Value: `"+f+"`.")}else{if(a=arguments[2],m=arguments[3],!i(f=arguments[4]))throw new TypeError("invalid argument. Fifth argument must be a callback function. Value: `"+f+"`.");t=arguments[5]}if(!u(a))throw new TypeError("invalid argument. Third argument must be either an integer (starting index) or a callback function. Value: `"+a+"`.");if(!u(m))throw new TypeError("invalid argument. Fourth argument must be either an integer (ending index) or a callback function. Value: `"+m+"`.");if(m<0?(m=r.length+m)<0&&(m=0):m>r.length&&(m=r.length),a<0&&(a=r.length+a)<0&&(a=0),g=a-1,f){for(;g<m-1&&(g+=1,h=e.next(),s(h,"value")&&(r[g]=f.call(t,h.value,g,g-a)),!h.done););return r}for(;g<m-1&&(g+=1,h=e.next(),s(h,"value")&&(r[g]=h.value),!h.done););return r}var f=m;export default f; //# sourceMappingURL=to-array-view.js.map