UNPKG

@stdlib/esm

Version:

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

3 lines 1.55 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 t from"./../assert/is-positive-integer.js";import n from"./../assert/is-iterator-like.js";import o from"./../assert/has-own-property.js";import a from"./../symbol/iterator.js";var i=e,u=r,l=t.isPrimitive,s=n,m=o,v=a;function f(e,r,t){var n,o,a,p,d,g,c,h,j;if(!s(e))throw new TypeError("invalid argument. First argument must an iterator protocol-compliant object. Value: `"+e+"`.");if(!u(c=arguments[arguments.length-1]))throw new TypeError("invalid argument. Last argument must be a function. Value: `"+c+"`.");if(arguments.length>2){if(!l(r))throw new TypeError("invalid argument. Second argument must be a positive integer. Value: `"+r+"`.");h=r}else h=1;return d=NaN,n=0,j=-1,i(p={},"next",w),i(p,"return",y),v&&u(e[v])&&i(p,v,b),p;function w(){var r,t;if(g)return{done:!0};if(t=e.next(),j+=1,t.done)return g=!0,r={},m(t,"value")&&c(t.value,o,a,j,d)!==d&&(r.value=t.value),r.done=!0,r;if((r=c(t.value,o,a,j,d))===d){if(o=t.value,(n+=1)>h){for(;r===d;){if(t=e.next(),j+=1,t.done)return g=!0,r={},m(t,"value")&&c(t.value,o,a,j,d)!==d&&(r.value=t.value),r.done=!0,r;r=c(t.value,o,a,j,d),o=t.value}d=r,n=1}a=o}else o=t.value,a=o,d=r,n=1;return{value:a,done:!1}}function y(e){return g=!0,arguments.length?{value:e,done:!0}:{done:!0}}function b(){return f(e[v](),h,c)}}var p=f;export default p; //# sourceMappingURL=dedupe-by.js.map