UNPKG

@stdlib/esm

Version:

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

3 lines 1 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import e from"./../utils/define-nonenumerable-read-only-property.js";import r from"./../assert/is-function.js";import n from"./../assert/is-array-like-object.js";import t from"./../symbol/iterator.js";var o=e,a=r,u=n,i=t;function l(e){var r,n,t,f,m;if(!u(e))throw new TypeError("invalid argument. First argument must be an array-like object. Value: `"+e+"`.");if(arguments.length>1){if(!a(f=arguments[1]))throw new TypeError("invalid argument. Second argument must be a function. Value: `"+f+"`.");r=arguments[2]}return m=-1,o(n={},"next",f?s:d),o(n,"return",c),i&&o(n,i,p),n;function s(){return m+=1,t||m>=e.length?{done:!0}:{value:f.call(r,e[m],m,e),done:!1}}function d(){return m+=1,t||m>=e.length?{done:!0}:{value:e[m],done:!1}}function c(e){return t=!0,arguments.length?{value:e,done:!0}:{done:!0}}function p(){return f?l(e,f,r):l(e)}}var f=l;export default f; //# sourceMappingURL=to-iterator.js.map