@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 2.19 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"./../utils/define-nonenumerable-read-only-property.js";import e from"./../assert/is-function.js";import t from"./../assert/is-iterator-like.js";import n from"./../assert/has-own-property.js";import o from"./../symbol/iterator.js";import u from"./../utils/linked-list.js";var i=r,a=e,l=t,f=n,s=o,v=u;function p(r,e){for(var t=r.first();t;){if(t.value[0]===e)return t;t=t.next}return null}function m(r,e){for(var t=r.first();t;)t.value[2]<e&&r.remove(t),t=t.next;return r}function h(r,e,t){var n,o,u,i,a,l;for(n=new v,o=r[0];;){if((i=o.next()).done){f(i,"value")&&null===(a=p(n,u=e.call(t,i.value)))&&n.push([u,i.value,1]);break}null===(a=p(n,u=e.call(t,i.value)))&&n.push([u,i.value,1])}if(0===n.length)return n;for(l=1;l<r.length;l++){for(o=r[l];;){if((i=o.next()).done){f(i,"value")&&(a=p(n,u=e.call(t,i.value)))&&a.value[2]===l&&(a.value[2]+=1);break}(a=p(n,u=e.call(t,i.value)))&&a.value[2]===l&&(a.value[2]+=1)}if(m(n,l+1),0===n.length)return n}return n}function c(){var r,e,t,n,o,u,f,v;for(r=[],v=0;v<arguments.length&&l(arguments[v]);v++)r.push(arguments[v]);if((o=r.length)<2)throw new Error("insufficient input arguments. Must provide two or more iterators.");if(o===arguments.length)throw new Error("insufficient input arguments. Must provide a hash function.");if(arguments.length>o+2)throw new TypeError("invalid argument. Iterator arguments must be iterator protocol-compliant objects.");if(!a(t=arguments[v]))throw new TypeError("invalid argument. Hash function argument must be a function. Value: `"+t+"`.");if(n=arguments[v+1],i(u={},"next",p),i(u,"return",m),s){for(v=0;v<o;v++)if(!a(r[v][s])){f=!0;break}f||i(u,s,d)}return f=!1,u;function p(){var o,u;if(f)return{done:!0};if(void 0===e){if(0===(o=h(r,t,n)).length)return f=!0,{done:!0};e=o.iterator()}return(u=e.next()).done?(f=!0,u):{value:u.value[1],done:!1}}function m(r){return f=!0,arguments.length?{value:r,done:!0}:{done:!0}}function d(){var e,u;for(e=[],u=0;u<o;u++)e.push(r[u][s]());return e.push(t),e.push(n),c.apply(null,e)}}var d=c;export default d;
//# sourceMappingURL=intersection-by-hash.js.map