@thi.ng/associative
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -38,3 +38,11 @@ import type { Fn3, Pair } from "@thi.ng/api"; | ||
equiv(o: any): boolean; | ||
forEach(fn: Fn3<Readonly<T>, Readonly<T>, Set<T>, void>, thisArg?: any): void; | ||
/** | ||
* The value args given to the callback `fn` MUST be treated as | ||
* readonly/immutable. This could be enforced via TS, but would | ||
* break ES6 Set interface contract. | ||
* | ||
* @param fn | ||
* @param thisArg | ||
*/ | ||
forEach(fn: Fn3<T, T, Set<T>, void>, thisArg?: any): void; | ||
entries(): IterableIterator<Pair<T, T>>; | ||
@@ -41,0 +49,0 @@ keys(): IterableIterator<T>; |
@@ -104,2 +104,10 @@ import { __decorate } from "tslib"; | ||
} | ||
/** | ||
* The value args given to the callback `fn` MUST be treated as | ||
* readonly/immutable. This could be enforced via TS, but would | ||
* break ES6 Set interface contract. | ||
* | ||
* @param fn | ||
* @param thisArg | ||
*/ | ||
forEach(fn, thisArg) { | ||
@@ -106,0 +114,0 @@ const vals = __vals(this); |
@@ -6,2 +6,14 @@ # Change Log | ||
# [4.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@4.1.0...@thi.ng/associative@4.2.0) (2020-06-20) | ||
### Features | ||
* **associative:** add null checks for merge* fns ([7baa3ba](https://github.com/thi-ng/umbrella/commit/7baa3ba29edf5f66d66423b9a33cac6b1ddfec8f)) | ||
* **associative:** update Trie to allow custom value sets ([777829c](https://github.com/thi-ng/umbrella/commit/777829c0e3bbdf0c5149a9366d22d16a32941310)) | ||
# [4.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@4.0.11...@thi.ng/associative@4.1.0) (2020-06-14) | ||
@@ -8,0 +20,0 @@ |
@@ -24,3 +24,11 @@ import type { Fn3, ICopy, IEmpty, IEquiv, IObjectOf, Pair } from "@thi.ng/api"; | ||
dissoc(keys: Iterable<K>): this; | ||
forEach(fn: Fn3<V, Readonly<K>, Map<K, V>, void>, thisArg?: any): void; | ||
/** | ||
* The key & value args given the callback `fn` MUST be treated as | ||
* readonly/immutable. This could be enforced via TS, but would | ||
* break ES6 Map interface contract. | ||
* | ||
* @param fn | ||
* @param thisArg | ||
*/ | ||
forEach(fn: Fn3<V, K, Map<K, V>, void>, thisArg?: any): void; | ||
get(key: K, notFound?: V): V | undefined; | ||
@@ -27,0 +35,0 @@ has(key: K): boolean; |
@@ -83,2 +83,10 @@ import { __decorate } from "tslib"; | ||
} | ||
/** | ||
* The key & value args given the callback `fn` MUST be treated as | ||
* readonly/immutable. This could be enforced via TS, but would | ||
* break ES6 Map interface contract. | ||
* | ||
* @param fn | ||
* @param thisArg | ||
*/ | ||
forEach(fn, thisArg) { | ||
@@ -85,0 +93,0 @@ for (let pair of __map(this)) { |
@@ -40,3 +40,11 @@ import type { Fn, Fn3, ICopy, IEmpty, IEquiv, Pair, Predicate2, IObjectOf } from "@thi.ng/api"; | ||
values(): IterableIterator<V>; | ||
forEach(fn: Fn3<V, Readonly<K>, Map<K, V>, void>, thisArg?: any): void; | ||
/** | ||
* The key & value args given the callback `fn` MUST be treated as | ||
* readonly/immutable. This could be enforced via TS, but would | ||
* break ES6 Map interface contract. | ||
* | ||
* @param fn | ||
* @param thisArg | ||
*/ | ||
forEach(fn: Fn3<V, K, Map<K, V>, void>, thisArg?: any): void; | ||
clear(): void; | ||
@@ -43,0 +51,0 @@ empty(): HashMap<K, V>; |
@@ -81,2 +81,10 @@ import { __decorate } from "tslib"; | ||
} | ||
/** | ||
* The key & value args given the callback `fn` MUST be treated as | ||
* readonly/immutable. This could be enforced via TS, but would | ||
* break ES6 Map interface contract. | ||
* | ||
* @param fn | ||
* @param thisArg | ||
*/ | ||
forEach(fn, thisArg) { | ||
@@ -83,0 +91,0 @@ for (let pair of __private.get(this).bins) { |
@@ -609,4 +609,6 @@ 'use strict'; | ||
for (let x of xs) { | ||
for (let pair of x) { | ||
dest.set(pair[0], pair[1]); | ||
if (x != null) { | ||
for (let pair of x) { | ||
dest.set(pair[0], pair[1]); | ||
} | ||
} | ||
@@ -820,4 +822,6 @@ } | ||
for (let x of xs) { | ||
for (let [k, v] of x) { | ||
res.set(k, res.has(k) ? f(res.get(k), v) : v); | ||
if (x != null) { | ||
for (let [k, v] of x) { | ||
res.set(k, res.has(k) ? f(res.get(k), v) : v); | ||
} | ||
} | ||
@@ -830,5 +834,7 @@ } | ||
for (let x of xs) { | ||
for (let k in x) { | ||
const v = x[k]; | ||
res[k] = res.hasOwnProperty(k) ? f(dest[k], v) : v; | ||
if (x != null) { | ||
for (let k in x) { | ||
const v = x[k]; | ||
res[k] = res.hasOwnProperty(k) ? f(dest[k], v) : v; | ||
} | ||
} | ||
@@ -1451,6 +1457,6 @@ } | ||
const next = node.next[k]; | ||
node = !next ? (node.n++, (node.next[k] = new Trie())) : next; | ||
node = !next ? (node.n++, (node.next[k] = this.makeChild())) : next; | ||
} | ||
if (!node.vals) | ||
node.vals = new Set(); | ||
node.vals = this.makeValueSet(); | ||
node.vals.add(val); | ||
@@ -1492,2 +1498,8 @@ } | ||
} | ||
makeChild() { | ||
return new Trie(); | ||
} | ||
makeValueSet() { | ||
return new Set(); | ||
} | ||
queueChildren(queue, prefix, sep = "") { | ||
@@ -1494,0 +1506,0 @@ prefix = prefix.length ? prefix + sep : prefix; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tslib"),require("@thi.ng/api"),require("@thi.ng/equiv"),require("@thi.ng/checks"),require("@thi.ng/transducers"),require("@thi.ng/binary"),require("@thi.ng/dcons"),require("@thi.ng/compare"),require("@thi.ng/errors")):"function"==typeof define&&define.amd?define(["exports","tslib","@thi.ng/api","@thi.ng/equiv","@thi.ng/checks","@thi.ng/transducers","@thi.ng/binary","@thi.ng/dcons","@thi.ng/compare","@thi.ng/errors"],t):t(((e=e||self).thi=e.thi||{},e.thi.ng=e.thi.ng||{},e.thi.ng.associative={}),e.thi.ng[""],e.thi.ng.api,e.thi.ng.equiv,e.thi.ng.checks,e.thi.ng.transducers,e.thi.ng.binary,e.thi.ng.dcons,e.thi.ng.compare,e.thi.ng.errors)}(this,(function(e,t,s,r,n,i,o,a,h,u){"use strict";function l(e,t){for(let s of t)e.delete(s);return e}const c=(e,t)=>{if(e===t)return!0;if(!(t instanceof Map)||e.size!==t.size)return!1;for(let s of e.entries())if(!r.equiv(t.get(s[0]),s[1]))return!1;return!0},p=(e,t)=>{if(e===t)return!0;if(!(t instanceof Set)||e.size!==t.size)return!1;for(let s of e.keys())if(!t.has(s))return!1;return!0},g=n.isNode()?require("util").inspect:null,f=(e,t)=>[...i.map(e=>g(e,t),e)].join(", "),d=(e,t)=>[...i.map(([e,s])=>`${g(e,t)} => ${g(s,t)}`,e)].join(", "),y=s.mixin({[Symbol.for("nodejs.util.inspect.custom")](e,t){const s=this[Symbol.toStringTag],r=Object.assign(Object.assign({},t),{depth:null===t.depth?null:t.depth-1});return e>=0?[`${s}(${this.size||0}) {`,g?this instanceof Set?f(this,r):this instanceof Map?d(this,r):"":"","}"].join(" "):t.stylize(`[${s}]`,"special")}});function m(e,t){if(n.isMap(e))for(let s of t)e.set(s[0],s[1]);else for(let s of t)e.add(s);return e}const v=new WeakMap,S=e=>v.get(e).vals;let b=(()=>{var e;let n=e=class extends Set{constructor(e,t={}){super(),v.set(this,{equiv:t.equiv||r.equiv,vals:[]}),e&&this.into(e)}*[Symbol.iterator](){yield*S(this)}get[Symbol.species](){return e}get[Symbol.toStringTag](){return"ArraySet"}get size(){return S(this).length}copy(){const t=v.get(this),s=new e(null,{equiv:t.equiv});return v.get(s).vals=t.vals.slice(),s}empty(){return new e(null,this.opts())}clear(){S(this).length=0}first(){if(this.size)return S(this)[0]}add(e){return!this.has(e)&&S(this).push(e),this}into(e){return m(this,e)}has(e){return this.get(e,s.SEMAPHORE)!==s.SEMAPHORE}get(e,t){const s=v.get(this),r=s.equiv,n=s.vals;for(let t=n.length;--t>=0;)if(r(n[t],e))return n[t];return t}delete(e){const t=v.get(this),s=t.equiv,r=t.vals;for(let t=r.length;--t>=0;)if(s(r[t],e))return r.splice(t,1),!0;return!1}disj(e){return l(this,e)}equiv(e){return p(this,e)}forEach(e,t){const s=S(this);for(let r=s.length;--r>=0;){const n=s[r];e.call(t,n,n,this)}}*entries(){for(let e of S(this))yield[e,e]}*keys(){yield*S(this)}*values(){yield*S(this)}opts(){return{equiv:v.get(this).equiv}}};return n=e=t.__decorate([y],n),n})();const w=(e,t,s=[])=>{for(let r in e)t.hasOwnProperty(r)&&s.push(r);return s},k=(e,t)=>n.implementsFunction(e,"empty")?e.empty():new(e[Symbol.species]||t),x=(e,t)=>n.implementsFunction(e,"copy")?e.copy():new(e[Symbol.species]||t)(e),M=e=>e[Symbol.iterator]().next().value,O=e=>n.isSet(e)?e:new Set(e),q=(e,t,s)=>s?i.reduce(e(),s):[()=>null,e=>e||new Set,(e,s)=>e?t(e,O(s)):O(s)],z=(e,t,s)=>{if(e===t)return s||k(e,Set);s=s?m(s,e):x(e,Set);for(let e of t)s.delete(e);return s};const j=new WeakMap,E=e=>j.get(e).map;let A=(()=>{var e;let n=e=class extends Map{constructor(e,t){super();const s=Object.assign({equiv:r.equiv,keys:b},t);j.set(this,{keys:new s.keys(null,{equiv:s.equiv}),map:new Map,opts:s}),e&&this.into(e)}[Symbol.iterator](){return this.entries()}get[Symbol.species](){return e}get[Symbol.toStringTag](){return"EquivMap"}get size(){return j.get(this).keys.size}clear(){const e=j.get(this);e.keys.clear(),e.map.clear()}empty(){return new e(null,j.get(this).opts)}copy(){const t=j.get(this),s=new e;return j.set(s,{keys:t.keys.copy(),map:new Map(t.map),opts:t.opts}),s}equiv(e){return c(this,e)}delete(e){const t=j.get(this);return(e=t.keys.get(e,s.SEMAPHORE))!==s.SEMAPHORE&&(t.map.delete(e),t.keys.delete(e),!0)}dissoc(e){return l(this,e)}forEach(e,t){for(let s of E(this))e.call(t,s[1],s[0],this)}get(e,t){const r=j.get(this);return(e=r.keys.get(e,s.SEMAPHORE))!==s.SEMAPHORE?r.map.get(e):t}has(e){return j.get(this).keys.has(e)}set(e,t){const r=j.get(this),n=r.keys.get(e,s.SEMAPHORE);return n!==s.SEMAPHORE?r.map.set(n,t):(r.keys.add(e),r.map.set(e,t)),this}into(e){return m(this,e)}entries(){return E(this).entries()}keys(){return E(this).keys()}values(){return E(this).values()}opts(){return j.get(this).opts}};return n=e=t.__decorate([y],n),n})();const P=new WeakMap,_=(e,t)=>function*(){for(let s of P.get(e).bins)s&&(yield s[t])};let T=(()=>{var e;let s=e=class extends Map{constructor(e,t){super();const s=o.ceilPow2(Math.min(t.cap||16,4))-1;P.set(this,{hash:t.hash,equiv:t.equiv||r.equiv,load:t.load||.75,mask:s,bins:new Array(s+1),size:0}),e&&this.into(e)}get[Symbol.species](){return e}get[Symbol.toStringTag](){return"HashMap"}get size(){return P.get(this).size}[Symbol.iterator](){return this.entries()}*entries(){for(let e of P.get(this).bins)e&&(yield[e[0],e[1]])}keys(){return _(this,0)()}values(){return _(this,1)()}forEach(e,t){for(let s of P.get(this).bins)e.call(t,s[1],s[0],this)}clear(){const e=P.get(this);e.bins=new Array(16),e.mask=15,e.size=0}empty(){return new e(null,this.opts({cap:16}))}copy(){const t=P.get(this),s=new e(null,this.opts({cap:4}));return Object.assign(P.get(s),{bins:t.bins.slice(),mask:t.mask,size:t.size}),s}equiv(e){return c(this,e)}has(e){const t=P.get(this),s=this.find(e,t);return s>=0&&null!=t.bins[s]}get(e,t){const s=P.get(this),r=this.find(e,s);return r>=0&&s.bins[r]?s.bins[r][1]:t}set(e,t){const s=P.get(this);let r=this.find(e,s);return r>=0&&s.bins[r]?(s.bins[r][1]=t,this):(s.size>s.mask*s.load&&(this.resize(s),r=this.find(e,s)),s.bins[r]=[e,t],s.size++,this)}delete(e){const t=P.get(this);let s=this.find(e,t);const r=t.bins;if(s>=0&&!r[s])return!1;t.size--;const n=t.mask;let i,o=s;for(;;){delete r[s];do{if(o=o+1&n,!r[o])return!0;i=t.hash(r[o][0])&n}while(s<=o?s<i&&i<=o:s<i||i<=o);r[s]=r[o],s=o}}into(e){return m(this,e)}dissoc(e){return l(this,e)}opts(e){const t=P.get(this);return Object.assign({hash:t.hash,equiv:t.equiv,load:t.load,cap:t.mask+1},e)}find(e,t){const s=t.mask,r=t.bins,n=t.equiv;let i=s,o=t.hash(e)&s;for(;r[o]&&!n(r[o][0],e);){if(i--,i<0)return-1;o=o+1&t.mask}return o}resize(e){const t=e.bins,s=2*(e.mask+1);e.bins=new Array(s),e.mask=s-1,e.size=0;for(let e of t)e&&this.set(e[0],e[1])}};return s=e=t.__decorate([y],s),s})();const H=(e,t)=>{const s={};for(let r of t)e.hasOwnProperty(r)&&(s[r]=e[r]);return s},R=(e,t)=>{const s=new A;let r,n,i;for(r of e)n=H(r,t),i=s.get(n),!i&&s.set(n,i=k(e,Set)),i.add(r);return s},L=(e,t,s)=>{if(s=s||k(e,Set),e===t)return m(s,e);if(t.size<e.size)return L(t,e,s);for(let r of t)e.has(r)&&s.add(r);return s};const U=(e,t={})=>{for(let s in e)t[e[s]]=s;return t},F=(e,...t)=>Object.assign(e,...t),W=(e,t,s={})=>{for(let r in e)s[t.hasOwnProperty(r)?t[r]:r]=e[r];return s},C=(e,t,s)=>{if(e.size&&t.size){let r,n,i;e.size<=t.size?(r=e,n=t,i=U(s)):(r=t,n=e,i=s);const o=R(r,(e=>{const t=[];for(let s in e)e.hasOwnProperty(s)&&t.push(e[s]);return t})(i)),a=Object.keys(i),h=k(e,Set);for(let e of n){const t=o.get(W(H(e,a),i));if(t)for(let s of t)h.add(F(Object.assign({},s),e))}return h}return k(e,Set)};C(new Set([{a:1,b:2}]),new Set([{id:1,c:2}]),{a:"id"});const D=new WeakMap,K=e=>D.get(e).vals;let $=(()=>{var e;let n=e=class extends Set{constructor(e,t={}){super(),D.set(this,{equiv:t.equiv||r.equiv,vals:new a.DCons}),e&&this.into(e)}*[Symbol.iterator](){yield*K(this)}get[Symbol.species](){return e}get[Symbol.toStringTag](){return"LLSet"}get size(){return K(this).length}copy(){const t=D.get(this),s=new e(null,this.opts());return D.get(s).vals=t.vals.copy(),s}empty(){return new e(null,this.opts())}clear(){K(this).clear()}first(){if(this.size)return K(this).head.value}add(e){return!this.has(e)&&K(this).push(e),this}into(e){return m(this,e)}has(e){return this.get(e,s.SEMAPHORE)!==s.SEMAPHORE}get(e,t){const s=D.get(this),r=s.equiv;let n=s.vals.head;for(;n;){if(r(n.value,e))return n.value;n=n.next}return t}delete(e){const t=D.get(this),s=t.equiv;let r=t.vals.head;for(;r;){if(s(r.value,e))return t.vals.splice(r,1),!0;r=r.next}return!1}disj(e){return l(this,e)}equiv(e){return p(this,e)}forEach(e,t){let s=K(this).head;for(;s;)e.call(t,s.value,s.value,this),s=s.next}*entries(){for(let e of K(this))yield[e,e]}*keys(){yield*K(this)}*values(){yield*K(this)}opts(){return{equiv:D.get(this).equiv}}};return n=e=t.__decorate([y],n),n})();const N=(e,t,...s)=>{const r=Object.assign({},t);for(let n of s)for(let s in n){const i=n[s];r[s]=r.hasOwnProperty(s)?e(t[s],i):i}return r},B=(e,...t)=>N((e,t)=>n.isPlainObject(e)&&n.isPlainObject(t)?B(e,t):t,e,...t);class G{constructor(e,t,s){this.k=e,this.v=t,this.next=new Array(s+1)}}const I=new WeakMap;let J=(()=>{var e;let r=e=class extends Map{constructor(t,s={}){super();const r=s.capacity||e.DEFAULT_CAP,n=Math.ceil(Math.log2(r));I.set(this,{head:new G(null,null,0),cap:Math.pow(2,n),cmp:s.compare||h.compare,p:s.probability||e.DEFAULT_P,maxh:n,length:0,h:0}),t&&this.into(t)}get[Symbol.species](){return e}*[Symbol.iterator](){let e=I.get(this).head;for(;e=e.next[0];)yield[e.k,e.v]}*entries(e,t=!1){const s=I.get(this);let r=s.head;const n=s.cmp;let i;if(t){for(;r=r.next[0];)if((void 0===e||(i=n(r.k,e))<=0)&&(yield[r.k,r.v],0===i))return}else for(;r=r.next[0];)(void 0===e||(i=n(r.k,e))>=0)&&(yield[r.k,r.v])}keys(e,t=!1){return i.map(e=>e[0],this.entries(e,t))}values(e,t=!1){return i.map(e=>e[1],this.entries(e,t))}get size(){return I.get(this).length}clear(){const e=I.get(this);e.head=new G(null,null,0),e.length=0,e.h=0}empty(){return new e(null,Object.assign(Object.assign({},this.opts()),{capacity:e.DEFAULT_CAP}))}copy(){return new e(this,this.opts())}compare(e){const t=this.size,s=e.size;if(t<s)return-1;if(t>s)return 1;const r=this.entries(),n=e.entries();let i,o,a;for(;i=r.next(),o=n.next(),!i.done&&!o.done;)if(0!==(a=h.compare(i.value[0],o.value[0]))||0!==(a=h.compare(i.value[1],o.value[1])))return a;return 0}equiv(e){return c(this,e)}first(){const e=I.get(this).head.next[0];return e?[e.k,e.v]:void 0}get(e,t){const s=this.findPredNode(e).next[0];return s&&0===I.get(this).cmp(s.k,e)?s.v:t}has(e){return this.get(e,s.SEMAPHORE)!==s.SEMAPHORE}set(e,t){const s=I.get(this);let r=s.head,n=s.h,i=new Array(n);const o=s.cmp;let a;for(;n>=0;){for(;r.next[n]&&(a=o(r.next[n].k,e))<0;)r=r.next[n];if(r.next[n]&&0===a){do{r.next[n].v=t}while(--n>=0);return this}i[n--]=r}const h=this.pickHeight(s.maxh,s.h,s.p);for(r=new G(e,t,h);s.h<h;)i[++s.h]=s.head;for(let e=0;e<=h;e++)r.next[e]=i[e].next[e],i[e].next[e]=r;return s.length++,s.length>=s.cap&&(s.cap*=2,s.maxh++),this}delete(e){const t=I.get(this);let s=t.head,r=t.h,n=!1;const i=t.cmp;let o;for(;r>=0;){for(;s.next[r]&&(o=i(s.next[r].k,e))<0;)s=s.next[r];s.next[r]&&0===o&&(n=!0,s.next[r]=s.next[r].next[r],s!=t.head||s.next[r]||(t.h=Math.max(0,t.h-1))),r--}return n&&t.length--,n}into(e){return m(this,e)}dissoc(e){return l(this,e)}forEach(e,t){for(let s of this)e.call(t,s[1],s[0],this)}$reduce(e,t){let s=I.get(this).head;for(;(s=s.next[0])&&!i.isReduced(t);)t=e(t,[s.k,s.v]);return t}opts(){const e=I.get(this);return{capacity:e.cap,compare:e.cmp,probability:e.p}}findPredNode(e){const t=I.get(this),s=t.cmp;let r=t.head,n=t.h;for(;n>=0;){for(;r.next[n]&&s(r.next[n].k,e)<0;)r=r.next[n];n--}return r}pickHeight(e,t,s){const r=Math.min(e,t+1);let n=0;for(;Math.random()<s&&n<r;)n++;return n}};return r.DEFAULT_CAP=8,r.DEFAULT_P=1/Math.E,r=e=t.__decorate([y],r),r})();const Q=new WeakMap;let V=(()=>{var e;let s=e=class extends Set{constructor(e,t){super(),Q.set(this,new J(e?i.map(e=>[e,e],e):null,t))}[Symbol.iterator](){return this.keys()}get[Symbol.species](){return e}get[Symbol.toStringTag](){return"SortedSet"}get size(){return Q.get(this).size}copy(){return new e(this.keys(),this.opts())}empty(){return new e(null,Object.assign(Object.assign({},this.opts()),{capacity:J.DEFAULT_CAP}))}compare(e){const t=this.size,s=e.size;if(t<s)return-1;if(t>s)return 1;const r=this.entries(),n=e.entries();let i,o,a;for(;i=r.next(),o=n.next(),!i.done&&!o.done;)if(0!==(a=h.compare(i.value[0],o.value[0])))return a;return 0}equiv(e){return p(this,e)}$reduce(e,t){return Q.get(this).$reduce((t,s)=>e(t,s[0]),t)}entries(e,t=!1){return Q.get(this).entries(e,t)}keys(e,t=!1){return Q.get(this).keys(e,t)}values(e,t=!1){return Q.get(this).values(e,t)}add(e){return Q.get(this).set(e,e),this}into(e){return m(this,e)}clear(){Q.get(this).clear()}first(){const e=Q.get(this).first();return e?e[0]:void 0}delete(e){return Q.get(this).delete(e)}disj(e){return l(this,e)}forEach(e,t){for(let s of this)e.call(t,s,s,this)}has(e){return Q.get(this).has(e)}get(e,t){return Q.get(this).get(e,t)}opts(){return Q.get(this).opts()}};return s=e=t.__decorate([y],s),s})();const X=new WeakMap,Y=()=>u.illegalArgs("dense & sparse arrays must be of same size");let Z=(()=>{let e=class extends Set{constructor(e,t){super(),X.set(this,{dense:e,sparse:t,n:0})}[Symbol.iterator](){return this.keys()}get size(){return X.get(this).n}get capacity(){return X.get(this).dense.length}clear(){X.get(this).n=0}equiv(e){if(this===e)return!0;if(!(e instanceof Set)||this.size!==e.size)return!1;const t=X.get(this),s=t.dense;for(let r=t.n;--r>=0;)if(!e.has(s[r]))return!1;return!0}add(e){const t=X.get(this),s=t.dense,r=t.sparse,n=s.length,i=r[e],o=t.n;return e<n&&o<n&&!(i<o&&s[i]===e)&&(s[o]=e,r[e]=o,t.n++),this}delete(e){const t=X.get(this),s=t.dense,r=t.sparse,n=r[e];if(n<t.n&&s[n]===e){const e=s[--t.n];return s[n]=e,r[e]=n,!0}return!1}has(e){const t=X.get(this),s=t.sparse[e];return s<t.n&&t.dense[s]===e}get(e,t=-1){return this.has(e)?e:t}first(){const e=X.get(this);return e.n?e.dense[0]:void 0}into(e){return m(this,e)}disj(e){return l(this,e)}forEach(e,t){const s=X.get(this),r=s.dense,n=s.n;for(let s=0;s<n;s++){const n=r[s];e.call(t,n,n,this)}}*entries(){const e=X.get(this),t=e.dense,s=e.n;for(let e=0;e<s;e++)yield[t[e],t[e]]}*keys(){const e=X.get(this),t=e.dense,s=e.n;for(let e=0;e<s;e++)yield t[e]}values(){return this.keys()}__copyTo(e){const t=X.get(this),s=X.get(e);return s.dense=t.dense.slice(),s.sparse=t.sparse.slice(),s.n=t.n,e}};return e=t.__decorate([y],e),e})();class ee extends Z{constructor(e,t){n.isNumber(e)?super(new Uint8Array(e),new Uint8Array(e)):e.length===t.length?super(e,t):Y()}get[Symbol.species](){return ee}get[Symbol.toStringTag](){return"SparseSet8"}copy(){return this.__copyTo(new ee(0))}empty(){return new ee(this.capacity)}}class te extends Z{constructor(e,t){n.isNumber(e)?super(new Uint16Array(e),new Uint16Array(e)):e.length===t.length?super(e,t):Y()}get[Symbol.species](){return te}get[Symbol.toStringTag](){return"SparseSet16"}copy(){return this.__copyTo(new te(0))}empty(){return new te(this.capacity)}}class se extends Z{constructor(e,t){n.isNumber(e)?super(new Uint32Array(e),new Uint32Array(e)):e.length===t.length?super(e,t):Y()}get[Symbol.species](){return se}get[Symbol.toStringTag](){return"SparseSet32"}copy(){return this.__copyTo(new se(0))}empty(){return new se(this.capacity)}}class re{constructor(){this.next={},this.n=0}*[Symbol.iterator](){const e=[["",this]];for(;e.length;){const[t,s]=e.pop();s.vals?yield*i.map(e=>[t,e],s.vals):s.queueChildren(e,t)}}*keys(e="",t=""){const s=[[t,this]];for(;s.length;){const[t,r]=s.pop();r.vals?yield t:r.queueChildren(s,t,e)}}*values(){const e=[this];for(;e.length;){const t=e.pop();t.vals?yield*t.vals:e.push(...i.vals(t.next))}}clear(){this.next={},this.n=0,this.vals=void 0}has(e){return!!this.get(e)}hasPrefix(e){return!!this.find(e)}*suffixes(e,t=!1){const s=this.find(e);s&&(yield*s.keys("",t?e.toString():""))}get(e){const t=this.find(e);return t?t.vals:void 0}find(e){let t=this;for(let s=0,r=e.length;s<r;s++)if(t=t.next[e[s].toString()],!t)return;return t}add(e,t){let s=this;for(let t=0,r=e.length;t<r;t++){const r=e[t].toString(),n=s.next[r];s=n||(s.n++,s.next[r]=new re)}s.vals||(s.vals=new Set),s.vals.add(t)}delete(e,t){const s=e.length;if(s<1)return!1;const r=[],n=[];let i=0,o=this;for(;i<s;i++){const t=e[i].toString();if(n.push(t),r.push(o),o=o.next[t],!o)return!1}if(void 0!==t){const e=o.vals;if(!e||!e.has(t))return!1;if(e.delete(t),e.size>0)return!0}for(;(o=r[--i])&&(delete o.next[n[i]],!--o.n););return!0}queueChildren(e,t,s=""){t=t.length?t+s:t,e.push(...i.map(e=>[t+e,this.next[e]],Object.keys(this.next)))}}const ne=(e,t,s)=>{if(e.size<t.size){const s=e;e=t,t=s}return s=s?m(s,e):x(e,Set),e===t?s:m(s,t)};e.ASparseSet=Z,e.ArraySet=b,e.EquivMap=A,e.HashMap=T,e.LLSet=$,e.SortedMap=J,e.SortedSet=V,e.SparseSet16=te,e.SparseSet32=se,e.SparseSet8=ee,e.Trie=re,e.commonKeysMap=(e,t,s=[])=>{for(let r of e.keys())t.has(r)&&s.push(r);return s},e.commonKeysObj=w,e.defArraySet=(e,t)=>new b(e,t),e.defEquivMap=function(e,t){return new A(n.isPlainObject(e)?i.pairs(e):e,t)},e.defHashMap=function(e,t){if(n.isPlainObject(e)){const s=Object.keys(e);return new T(i.map(t=>[t,e[t]],s),Object.assign({cap:s.length/(t.load||.75)},t))}return new T(e,t)},e.defLLSet=(e,t)=>new $(e,t),e.defSortedMap=function(e,t){if(n.isPlainObject(e)){const s=Object.keys(e);return new J(i.map(t=>[t,e[t]],s),Object.assign({capacity:s.length},t))}return new J(e,t)},e.defSortedSet=(e,t)=>new V(e,t),e.defSparseSet=e=>e<=256?new ee(e):e<=65536?new te(e):new se(e),e.difference=z,e.differenceR=function e(t){return q(e,z,t)},e.dissoc=l,e.dissocObj=(e,t)=>{for(let s of t)delete e[s];return e},e.indexed=R,e.intersection=L,e.intersectionR=function e(t){return q(e,L,t)},e.into=m,e.invertMap=(e,t)=>{t=t||new Map;for(let s of e)t.set(s[1],s[0]);return t},e.invertObj=U,e.join=(e,t)=>{if(e.size&&t.size){const s=w(M(e)||{},M(t)||{});let r,n;e.size<=t.size?(r=e,n=t):(r=t,n=e);const i=R(r,s),o=k(e,Set);for(let e of n){const t=i.get(H(e,s));if(t)for(let s of t)o.add(F(Object.assign({},s),e))}return o}return k(e,Set)},e.joinWith=C,e.mergeApplyMap=(e,t)=>{const s=x(e,Map);for(let[e,r]of t)s.set(e,n.isFunction(r)?r(s.get(e)):r);return s},e.mergeApplyObj=(e,t)=>{const s=Object.assign({},e);for(let e in t){const r=t[e];s[e]=n.isFunction(r)?r(s[e]):r}return s},e.mergeDeepObj=B,e.mergeMap=(e,...t)=>{for(let s of t)for(let t of s)e.set(t[0],t[1]);return e},e.mergeMapWith=(e,t,...s)=>{const r=x(t,Map);for(let t of s)for(let[s,n]of t)r.set(s,r.has(s)?e(r.get(s),n):n);return r},e.mergeObj=F,e.mergeObjWith=N,e.renameKeysMap=(e,t,s)=>{s=s||k(e,Map);for(let[r,n]of e)s.set(t.has(r)?t.get(r):r,n);return s},e.renameKeysObj=W,e.selectKeysMap=(e,t)=>{const s=k(e,Map);for(let r of t)e.has(r)&&s.set(r,e.get(r));return s},e.selectKeysObj=H,e.union=ne,e.unionR=function e(t){return q(e,ne,t)},e.withoutKeysMap=(e,t)=>{const s=O(t),r=k(e,Map);for(let t of e.entries()){const e=t[0];!s.has(e)&&r.set(e,t[1])}return r},e.withoutKeysObj=(e,t)=>{const s=O(t),r={};for(let t in e)e.hasOwnProperty(t)&&!s.has(t)&&(r[t]=e[t]);return r},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tslib"),require("@thi.ng/api"),require("@thi.ng/equiv"),require("@thi.ng/checks"),require("@thi.ng/transducers"),require("@thi.ng/binary"),require("@thi.ng/dcons"),require("@thi.ng/compare"),require("@thi.ng/errors")):"function"==typeof define&&define.amd?define(["exports","tslib","@thi.ng/api","@thi.ng/equiv","@thi.ng/checks","@thi.ng/transducers","@thi.ng/binary","@thi.ng/dcons","@thi.ng/compare","@thi.ng/errors"],t):t(((e=e||self).thi=e.thi||{},e.thi.ng=e.thi.ng||{},e.thi.ng.associative={}),e.thi.ng[""],e.thi.ng.api,e.thi.ng.equiv,e.thi.ng.checks,e.thi.ng.transducers,e.thi.ng.binary,e.thi.ng.dcons,e.thi.ng.compare,e.thi.ng.errors)}(this,(function(e,t,s,r,n,i,o,a,u,h){"use strict";function l(e,t){for(let s of t)e.delete(s);return e}const c=(e,t)=>{if(e===t)return!0;if(!(t instanceof Map)||e.size!==t.size)return!1;for(let s of e.entries())if(!r.equiv(t.get(s[0]),s[1]))return!1;return!0},p=(e,t)=>{if(e===t)return!0;if(!(t instanceof Set)||e.size!==t.size)return!1;for(let s of e.keys())if(!t.has(s))return!1;return!0},g=n.isNode()?require("util").inspect:null,f=(e,t)=>[...i.map(e=>g(e,t),e)].join(", "),d=(e,t)=>[...i.map(([e,s])=>`${g(e,t)} => ${g(s,t)}`,e)].join(", "),y=s.mixin({[Symbol.for("nodejs.util.inspect.custom")](e,t){const s=this[Symbol.toStringTag],r=Object.assign(Object.assign({},t),{depth:null===t.depth?null:t.depth-1});return e>=0?[`${s}(${this.size||0}) {`,g?this instanceof Set?f(this,r):this instanceof Map?d(this,r):"":"","}"].join(" "):t.stylize(`[${s}]`,"special")}});function m(e,t){if(n.isMap(e))for(let s of t)e.set(s[0],s[1]);else for(let s of t)e.add(s);return e}const v=new WeakMap,S=e=>v.get(e).vals;let b=(()=>{var e;let n=e=class extends Set{constructor(e,t={}){super(),v.set(this,{equiv:t.equiv||r.equiv,vals:[]}),e&&this.into(e)}*[Symbol.iterator](){yield*S(this)}get[Symbol.species](){return e}get[Symbol.toStringTag](){return"ArraySet"}get size(){return S(this).length}copy(){const t=v.get(this),s=new e(null,{equiv:t.equiv});return v.get(s).vals=t.vals.slice(),s}empty(){return new e(null,this.opts())}clear(){S(this).length=0}first(){if(this.size)return S(this)[0]}add(e){return!this.has(e)&&S(this).push(e),this}into(e){return m(this,e)}has(e){return this.get(e,s.SEMAPHORE)!==s.SEMAPHORE}get(e,t){const s=v.get(this),r=s.equiv,n=s.vals;for(let t=n.length;--t>=0;)if(r(n[t],e))return n[t];return t}delete(e){const t=v.get(this),s=t.equiv,r=t.vals;for(let t=r.length;--t>=0;)if(s(r[t],e))return r.splice(t,1),!0;return!1}disj(e){return l(this,e)}equiv(e){return p(this,e)}forEach(e,t){const s=S(this);for(let r=s.length;--r>=0;){const n=s[r];e.call(t,n,n,this)}}*entries(){for(let e of S(this))yield[e,e]}*keys(){yield*S(this)}*values(){yield*S(this)}opts(){return{equiv:v.get(this).equiv}}};return n=e=t.__decorate([y],n),n})();const w=(e,t,s=[])=>{for(let r in e)t.hasOwnProperty(r)&&s.push(r);return s},k=(e,t)=>n.implementsFunction(e,"empty")?e.empty():new(e[Symbol.species]||t),x=(e,t)=>n.implementsFunction(e,"copy")?e.copy():new(e[Symbol.species]||t)(e),M=e=>e[Symbol.iterator]().next().value,O=e=>n.isSet(e)?e:new Set(e),q=(e,t,s)=>s?i.reduce(e(),s):[()=>null,e=>e||new Set,(e,s)=>e?t(e,O(s)):O(s)],z=(e,t,s)=>{if(e===t)return s||k(e,Set);s=s?m(s,e):x(e,Set);for(let e of t)s.delete(e);return s};const j=new WeakMap,E=e=>j.get(e).map;let A=(()=>{var e;let n=e=class extends Map{constructor(e,t){super();const s=Object.assign({equiv:r.equiv,keys:b},t);j.set(this,{keys:new s.keys(null,{equiv:s.equiv}),map:new Map,opts:s}),e&&this.into(e)}[Symbol.iterator](){return this.entries()}get[Symbol.species](){return e}get[Symbol.toStringTag](){return"EquivMap"}get size(){return j.get(this).keys.size}clear(){const e=j.get(this);e.keys.clear(),e.map.clear()}empty(){return new e(null,j.get(this).opts)}copy(){const t=j.get(this),s=new e;return j.set(s,{keys:t.keys.copy(),map:new Map(t.map),opts:t.opts}),s}equiv(e){return c(this,e)}delete(e){const t=j.get(this);return(e=t.keys.get(e,s.SEMAPHORE))!==s.SEMAPHORE&&(t.map.delete(e),t.keys.delete(e),!0)}dissoc(e){return l(this,e)}forEach(e,t){for(let s of E(this))e.call(t,s[1],s[0],this)}get(e,t){const r=j.get(this);return(e=r.keys.get(e,s.SEMAPHORE))!==s.SEMAPHORE?r.map.get(e):t}has(e){return j.get(this).keys.has(e)}set(e,t){const r=j.get(this),n=r.keys.get(e,s.SEMAPHORE);return n!==s.SEMAPHORE?r.map.set(n,t):(r.keys.add(e),r.map.set(e,t)),this}into(e){return m(this,e)}entries(){return E(this).entries()}keys(){return E(this).keys()}values(){return E(this).values()}opts(){return j.get(this).opts}};return n=e=t.__decorate([y],n),n})();const P=new WeakMap,_=(e,t)=>function*(){for(let s of P.get(e).bins)s&&(yield s[t])};let T=(()=>{var e;let s=e=class extends Map{constructor(e,t){super();const s=o.ceilPow2(Math.min(t.cap||16,4))-1;P.set(this,{hash:t.hash,equiv:t.equiv||r.equiv,load:t.load||.75,mask:s,bins:new Array(s+1),size:0}),e&&this.into(e)}get[Symbol.species](){return e}get[Symbol.toStringTag](){return"HashMap"}get size(){return P.get(this).size}[Symbol.iterator](){return this.entries()}*entries(){for(let e of P.get(this).bins)e&&(yield[e[0],e[1]])}keys(){return _(this,0)()}values(){return _(this,1)()}forEach(e,t){for(let s of P.get(this).bins)e.call(t,s[1],s[0],this)}clear(){const e=P.get(this);e.bins=new Array(16),e.mask=15,e.size=0}empty(){return new e(null,this.opts({cap:16}))}copy(){const t=P.get(this),s=new e(null,this.opts({cap:4}));return Object.assign(P.get(s),{bins:t.bins.slice(),mask:t.mask,size:t.size}),s}equiv(e){return c(this,e)}has(e){const t=P.get(this),s=this.find(e,t);return s>=0&&null!=t.bins[s]}get(e,t){const s=P.get(this),r=this.find(e,s);return r>=0&&s.bins[r]?s.bins[r][1]:t}set(e,t){const s=P.get(this);let r=this.find(e,s);return r>=0&&s.bins[r]?(s.bins[r][1]=t,this):(s.size>s.mask*s.load&&(this.resize(s),r=this.find(e,s)),s.bins[r]=[e,t],s.size++,this)}delete(e){const t=P.get(this);let s=this.find(e,t);const r=t.bins;if(s>=0&&!r[s])return!1;t.size--;const n=t.mask;let i,o=s;for(;;){delete r[s];do{if(o=o+1&n,!r[o])return!0;i=t.hash(r[o][0])&n}while(s<=o?s<i&&i<=o:s<i||i<=o);r[s]=r[o],s=o}}into(e){return m(this,e)}dissoc(e){return l(this,e)}opts(e){const t=P.get(this);return Object.assign({hash:t.hash,equiv:t.equiv,load:t.load,cap:t.mask+1},e)}find(e,t){const s=t.mask,r=t.bins,n=t.equiv;let i=s,o=t.hash(e)&s;for(;r[o]&&!n(r[o][0],e);){if(i--,i<0)return-1;o=o+1&t.mask}return o}resize(e){const t=e.bins,s=2*(e.mask+1);e.bins=new Array(s),e.mask=s-1,e.size=0;for(let e of t)e&&this.set(e[0],e[1])}};return s=e=t.__decorate([y],s),s})();const H=(e,t)=>{const s={};for(let r of t)e.hasOwnProperty(r)&&(s[r]=e[r]);return s},R=(e,t)=>{const s=new A;let r,n,i;for(r of e)n=H(r,t),i=s.get(n),!i&&s.set(n,i=k(e,Set)),i.add(r);return s},L=(e,t,s)=>{if(s=s||k(e,Set),e===t)return m(s,e);if(t.size<e.size)return L(t,e,s);for(let r of t)e.has(r)&&s.add(r);return s};const U=(e,t={})=>{for(let s in e)t[e[s]]=s;return t},C=(e,...t)=>Object.assign(e,...t),F=(e,t,s={})=>{for(let r in e)s[t.hasOwnProperty(r)?t[r]:r]=e[r];return s},W=(e,t,s)=>{if(e.size&&t.size){let r,n,i;e.size<=t.size?(r=e,n=t,i=U(s)):(r=t,n=e,i=s);const o=R(r,(e=>{const t=[];for(let s in e)e.hasOwnProperty(s)&&t.push(e[s]);return t})(i)),a=Object.keys(i),u=k(e,Set);for(let e of n){const t=o.get(F(H(e,a),i));if(t)for(let s of t)u.add(C(Object.assign({},s),e))}return u}return k(e,Set)};W(new Set([{a:1,b:2}]),new Set([{id:1,c:2}]),{a:"id"});const D=new WeakMap,K=e=>D.get(e).vals;let $=(()=>{var e;let n=e=class extends Set{constructor(e,t={}){super(),D.set(this,{equiv:t.equiv||r.equiv,vals:new a.DCons}),e&&this.into(e)}*[Symbol.iterator](){yield*K(this)}get[Symbol.species](){return e}get[Symbol.toStringTag](){return"LLSet"}get size(){return K(this).length}copy(){const t=D.get(this),s=new e(null,this.opts());return D.get(s).vals=t.vals.copy(),s}empty(){return new e(null,this.opts())}clear(){K(this).clear()}first(){if(this.size)return K(this).head.value}add(e){return!this.has(e)&&K(this).push(e),this}into(e){return m(this,e)}has(e){return this.get(e,s.SEMAPHORE)!==s.SEMAPHORE}get(e,t){const s=D.get(this),r=s.equiv;let n=s.vals.head;for(;n;){if(r(n.value,e))return n.value;n=n.next}return t}delete(e){const t=D.get(this),s=t.equiv;let r=t.vals.head;for(;r;){if(s(r.value,e))return t.vals.splice(r,1),!0;r=r.next}return!1}disj(e){return l(this,e)}equiv(e){return p(this,e)}forEach(e,t){let s=K(this).head;for(;s;)e.call(t,s.value,s.value,this),s=s.next}*entries(){for(let e of K(this))yield[e,e]}*keys(){yield*K(this)}*values(){yield*K(this)}opts(){return{equiv:D.get(this).equiv}}};return n=e=t.__decorate([y],n),n})();const N=(e,t,...s)=>{const r=Object.assign({},t);for(let n of s)if(null!=n)for(let s in n){const i=n[s];r[s]=r.hasOwnProperty(s)?e(t[s],i):i}return r},V=(e,...t)=>N((e,t)=>n.isPlainObject(e)&&n.isPlainObject(t)?V(e,t):t,e,...t);class B{constructor(e,t,s){this.k=e,this.v=t,this.next=new Array(s+1)}}const G=new WeakMap;let I=(()=>{var e;let r=e=class extends Map{constructor(t,s={}){super();const r=s.capacity||e.DEFAULT_CAP,n=Math.ceil(Math.log2(r));G.set(this,{head:new B(null,null,0),cap:Math.pow(2,n),cmp:s.compare||u.compare,p:s.probability||e.DEFAULT_P,maxh:n,length:0,h:0}),t&&this.into(t)}get[Symbol.species](){return e}*[Symbol.iterator](){let e=G.get(this).head;for(;e=e.next[0];)yield[e.k,e.v]}*entries(e,t=!1){const s=G.get(this);let r=s.head;const n=s.cmp;let i;if(t){for(;r=r.next[0];)if((void 0===e||(i=n(r.k,e))<=0)&&(yield[r.k,r.v],0===i))return}else for(;r=r.next[0];)(void 0===e||(i=n(r.k,e))>=0)&&(yield[r.k,r.v])}keys(e,t=!1){return i.map(e=>e[0],this.entries(e,t))}values(e,t=!1){return i.map(e=>e[1],this.entries(e,t))}get size(){return G.get(this).length}clear(){const e=G.get(this);e.head=new B(null,null,0),e.length=0,e.h=0}empty(){return new e(null,Object.assign(Object.assign({},this.opts()),{capacity:e.DEFAULT_CAP}))}copy(){return new e(this,this.opts())}compare(e){const t=this.size,s=e.size;if(t<s)return-1;if(t>s)return 1;const r=this.entries(),n=e.entries();let i,o,a;for(;i=r.next(),o=n.next(),!i.done&&!o.done;)if(0!==(a=u.compare(i.value[0],o.value[0]))||0!==(a=u.compare(i.value[1],o.value[1])))return a;return 0}equiv(e){return c(this,e)}first(){const e=G.get(this).head.next[0];return e?[e.k,e.v]:void 0}get(e,t){const s=this.findPredNode(e).next[0];return s&&0===G.get(this).cmp(s.k,e)?s.v:t}has(e){return this.get(e,s.SEMAPHORE)!==s.SEMAPHORE}set(e,t){const s=G.get(this);let r=s.head,n=s.h,i=new Array(n);const o=s.cmp;let a;for(;n>=0;){for(;r.next[n]&&(a=o(r.next[n].k,e))<0;)r=r.next[n];if(r.next[n]&&0===a){do{r.next[n].v=t}while(--n>=0);return this}i[n--]=r}const u=this.pickHeight(s.maxh,s.h,s.p);for(r=new B(e,t,u);s.h<u;)i[++s.h]=s.head;for(let e=0;e<=u;e++)r.next[e]=i[e].next[e],i[e].next[e]=r;return s.length++,s.length>=s.cap&&(s.cap*=2,s.maxh++),this}delete(e){const t=G.get(this);let s=t.head,r=t.h,n=!1;const i=t.cmp;let o;for(;r>=0;){for(;s.next[r]&&(o=i(s.next[r].k,e))<0;)s=s.next[r];s.next[r]&&0===o&&(n=!0,s.next[r]=s.next[r].next[r],s!=t.head||s.next[r]||(t.h=Math.max(0,t.h-1))),r--}return n&&t.length--,n}into(e){return m(this,e)}dissoc(e){return l(this,e)}forEach(e,t){for(let s of this)e.call(t,s[1],s[0],this)}$reduce(e,t){let s=G.get(this).head;for(;(s=s.next[0])&&!i.isReduced(t);)t=e(t,[s.k,s.v]);return t}opts(){const e=G.get(this);return{capacity:e.cap,compare:e.cmp,probability:e.p}}findPredNode(e){const t=G.get(this),s=t.cmp;let r=t.head,n=t.h;for(;n>=0;){for(;r.next[n]&&s(r.next[n].k,e)<0;)r=r.next[n];n--}return r}pickHeight(e,t,s){const r=Math.min(e,t+1);let n=0;for(;Math.random()<s&&n<r;)n++;return n}};return r.DEFAULT_CAP=8,r.DEFAULT_P=1/Math.E,r=e=t.__decorate([y],r),r})();const J=new WeakMap;let Q=(()=>{var e;let s=e=class extends Set{constructor(e,t){super(),J.set(this,new I(e?i.map(e=>[e,e],e):null,t))}[Symbol.iterator](){return this.keys()}get[Symbol.species](){return e}get[Symbol.toStringTag](){return"SortedSet"}get size(){return J.get(this).size}copy(){return new e(this.keys(),this.opts())}empty(){return new e(null,Object.assign(Object.assign({},this.opts()),{capacity:I.DEFAULT_CAP}))}compare(e){const t=this.size,s=e.size;if(t<s)return-1;if(t>s)return 1;const r=this.entries(),n=e.entries();let i,o,a;for(;i=r.next(),o=n.next(),!i.done&&!o.done;)if(0!==(a=u.compare(i.value[0],o.value[0])))return a;return 0}equiv(e){return p(this,e)}$reduce(e,t){return J.get(this).$reduce((t,s)=>e(t,s[0]),t)}entries(e,t=!1){return J.get(this).entries(e,t)}keys(e,t=!1){return J.get(this).keys(e,t)}values(e,t=!1){return J.get(this).values(e,t)}add(e){return J.get(this).set(e,e),this}into(e){return m(this,e)}clear(){J.get(this).clear()}first(){const e=J.get(this).first();return e?e[0]:void 0}delete(e){return J.get(this).delete(e)}disj(e){return l(this,e)}forEach(e,t){for(let s of this)e.call(t,s,s,this)}has(e){return J.get(this).has(e)}get(e,t){return J.get(this).get(e,t)}opts(){return J.get(this).opts()}};return s=e=t.__decorate([y],s),s})();const X=new WeakMap,Y=()=>h.illegalArgs("dense & sparse arrays must be of same size");let Z=(()=>{let e=class extends Set{constructor(e,t){super(),X.set(this,{dense:e,sparse:t,n:0})}[Symbol.iterator](){return this.keys()}get size(){return X.get(this).n}get capacity(){return X.get(this).dense.length}clear(){X.get(this).n=0}equiv(e){if(this===e)return!0;if(!(e instanceof Set)||this.size!==e.size)return!1;const t=X.get(this),s=t.dense;for(let r=t.n;--r>=0;)if(!e.has(s[r]))return!1;return!0}add(e){const t=X.get(this),s=t.dense,r=t.sparse,n=s.length,i=r[e],o=t.n;return e<n&&o<n&&!(i<o&&s[i]===e)&&(s[o]=e,r[e]=o,t.n++),this}delete(e){const t=X.get(this),s=t.dense,r=t.sparse,n=r[e];if(n<t.n&&s[n]===e){const e=s[--t.n];return s[n]=e,r[e]=n,!0}return!1}has(e){const t=X.get(this),s=t.sparse[e];return s<t.n&&t.dense[s]===e}get(e,t=-1){return this.has(e)?e:t}first(){const e=X.get(this);return e.n?e.dense[0]:void 0}into(e){return m(this,e)}disj(e){return l(this,e)}forEach(e,t){const s=X.get(this),r=s.dense,n=s.n;for(let s=0;s<n;s++){const n=r[s];e.call(t,n,n,this)}}*entries(){const e=X.get(this),t=e.dense,s=e.n;for(let e=0;e<s;e++)yield[t[e],t[e]]}*keys(){const e=X.get(this),t=e.dense,s=e.n;for(let e=0;e<s;e++)yield t[e]}values(){return this.keys()}__copyTo(e){const t=X.get(this),s=X.get(e);return s.dense=t.dense.slice(),s.sparse=t.sparse.slice(),s.n=t.n,e}};return e=t.__decorate([y],e),e})();class ee extends Z{constructor(e,t){n.isNumber(e)?super(new Uint8Array(e),new Uint8Array(e)):e.length===t.length?super(e,t):Y()}get[Symbol.species](){return ee}get[Symbol.toStringTag](){return"SparseSet8"}copy(){return this.__copyTo(new ee(0))}empty(){return new ee(this.capacity)}}class te extends Z{constructor(e,t){n.isNumber(e)?super(new Uint16Array(e),new Uint16Array(e)):e.length===t.length?super(e,t):Y()}get[Symbol.species](){return te}get[Symbol.toStringTag](){return"SparseSet16"}copy(){return this.__copyTo(new te(0))}empty(){return new te(this.capacity)}}class se extends Z{constructor(e,t){n.isNumber(e)?super(new Uint32Array(e),new Uint32Array(e)):e.length===t.length?super(e,t):Y()}get[Symbol.species](){return se}get[Symbol.toStringTag](){return"SparseSet32"}copy(){return this.__copyTo(new se(0))}empty(){return new se(this.capacity)}}class re{constructor(){this.next={},this.n=0}*[Symbol.iterator](){const e=[["",this]];for(;e.length;){const[t,s]=e.pop();s.vals?yield*i.map(e=>[t,e],s.vals):s.queueChildren(e,t)}}*keys(e="",t=""){const s=[[t,this]];for(;s.length;){const[t,r]=s.pop();r.vals?yield t:r.queueChildren(s,t,e)}}*values(){const e=[this];for(;e.length;){const t=e.pop();t.vals?yield*t.vals:e.push(...i.vals(t.next))}}clear(){this.next={},this.n=0,this.vals=void 0}has(e){return!!this.get(e)}hasPrefix(e){return!!this.find(e)}*suffixes(e,t=!1){const s=this.find(e);s&&(yield*s.keys("",t?e.toString():""))}get(e){const t=this.find(e);return t?t.vals:void 0}find(e){let t=this;for(let s=0,r=e.length;s<r;s++)if(t=t.next[e[s].toString()],!t)return;return t}add(e,t){let s=this;for(let t=0,r=e.length;t<r;t++){const r=e[t].toString(),n=s.next[r];s=n||(s.n++,s.next[r]=this.makeChild())}s.vals||(s.vals=this.makeValueSet()),s.vals.add(t)}delete(e,t){const s=e.length;if(s<1)return!1;const r=[],n=[];let i=0,o=this;for(;i<s;i++){const t=e[i].toString();if(n.push(t),r.push(o),o=o.next[t],!o)return!1}if(void 0!==t){const e=o.vals;if(!e||!e.has(t))return!1;if(e.delete(t),e.size>0)return!0}for(;(o=r[--i])&&(delete o.next[n[i]],!--o.n););return!0}makeChild(){return new re}makeValueSet(){return new Set}queueChildren(e,t,s=""){t=t.length?t+s:t,e.push(...i.map(e=>[t+e,this.next[e]],Object.keys(this.next)))}}const ne=(e,t,s)=>{if(e.size<t.size){const s=e;e=t,t=s}return s=s?m(s,e):x(e,Set),e===t?s:m(s,t)};e.ASparseSet=Z,e.ArraySet=b,e.EquivMap=A,e.HashMap=T,e.LLSet=$,e.SortedMap=I,e.SortedSet=Q,e.SparseSet16=te,e.SparseSet32=se,e.SparseSet8=ee,e.Trie=re,e.commonKeysMap=(e,t,s=[])=>{for(let r of e.keys())t.has(r)&&s.push(r);return s},e.commonKeysObj=w,e.defArraySet=(e,t)=>new b(e,t),e.defEquivMap=function(e,t){return new A(n.isPlainObject(e)?i.pairs(e):e,t)},e.defHashMap=function(e,t){if(n.isPlainObject(e)){const s=Object.keys(e);return new T(i.map(t=>[t,e[t]],s),Object.assign({cap:s.length/(t.load||.75)},t))}return new T(e,t)},e.defLLSet=(e,t)=>new $(e,t),e.defSortedMap=function(e,t){if(n.isPlainObject(e)){const s=Object.keys(e);return new I(i.map(t=>[t,e[t]],s),Object.assign({capacity:s.length},t))}return new I(e,t)},e.defSortedSet=(e,t)=>new Q(e,t),e.defSparseSet=e=>e<=256?new ee(e):e<=65536?new te(e):new se(e),e.difference=z,e.differenceR=function e(t){return q(e,z,t)},e.dissoc=l,e.dissocObj=(e,t)=>{for(let s of t)delete e[s];return e},e.indexed=R,e.intersection=L,e.intersectionR=function e(t){return q(e,L,t)},e.into=m,e.invertMap=(e,t)=>{t=t||new Map;for(let s of e)t.set(s[1],s[0]);return t},e.invertObj=U,e.join=(e,t)=>{if(e.size&&t.size){const s=w(M(e)||{},M(t)||{});let r,n;e.size<=t.size?(r=e,n=t):(r=t,n=e);const i=R(r,s),o=k(e,Set);for(let e of n){const t=i.get(H(e,s));if(t)for(let s of t)o.add(C(Object.assign({},s),e))}return o}return k(e,Set)},e.joinWith=W,e.mergeApplyMap=(e,t)=>{const s=x(e,Map);for(let[e,r]of t)s.set(e,n.isFunction(r)?r(s.get(e)):r);return s},e.mergeApplyObj=(e,t)=>{const s=Object.assign({},e);for(let e in t){const r=t[e];s[e]=n.isFunction(r)?r(s[e]):r}return s},e.mergeDeepObj=V,e.mergeMap=(e,...t)=>{for(let s of t)if(null!=s)for(let t of s)e.set(t[0],t[1]);return e},e.mergeMapWith=(e,t,...s)=>{const r=x(t,Map);for(let t of s)if(null!=t)for(let[s,n]of t)r.set(s,r.has(s)?e(r.get(s),n):n);return r},e.mergeObj=C,e.mergeObjWith=N,e.renameKeysMap=(e,t,s)=>{s=s||k(e,Map);for(let[r,n]of e)s.set(t.has(r)?t.get(r):r,n);return s},e.renameKeysObj=F,e.selectKeysMap=(e,t)=>{const s=k(e,Map);for(let r of t)e.has(r)&&s.set(r,e.get(r));return s},e.selectKeysObj=H,e.union=ne,e.unionR=function e(t){return q(e,ne,t)},e.withoutKeysMap=(e,t)=>{const s=O(t),r=k(e,Map);for(let t of e.entries()){const e=t[0];!s.has(e)&&r.set(e,t[1])}return r},e.withoutKeysObj=(e,t)=>{const s=O(t),r={};for(let t in e)e.hasOwnProperty(t)&&!s.has(t)&&(r[t]=e[t]);return r},Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -38,3 +38,11 @@ import type { Fn3, Pair } from "@thi.ng/api"; | ||
equiv(o: any): boolean; | ||
forEach(fn: Fn3<Readonly<T>, Readonly<T>, Set<T>, void>, thisArg?: any): void; | ||
/** | ||
* The value args given to the callback `fn` MUST be treated as | ||
* readonly/immutable. This could be enforced via TS, but would | ||
* break ES6 Set interface contract. | ||
* | ||
* @param fn | ||
* @param thisArg | ||
*/ | ||
forEach(fn: Fn3<T, T, Set<T>, void>, thisArg?: any): void; | ||
entries(): IterableIterator<Pair<T, T>>; | ||
@@ -41,0 +49,0 @@ keys(): IterableIterator<T>; |
@@ -110,2 +110,10 @@ import { __decorate } from "tslib"; | ||
} | ||
/** | ||
* The value args given to the callback `fn` MUST be treated as | ||
* readonly/immutable. This could be enforced via TS, but would | ||
* break ES6 Set interface contract. | ||
* | ||
* @param fn | ||
* @param thisArg | ||
*/ | ||
forEach(fn, thisArg) { | ||
@@ -112,0 +120,0 @@ let i = __vals(this).head; |
@@ -1,3 +0,3 @@ | ||
import type { IObjectOf } from "@thi.ng/api"; | ||
export declare const mergeDeepObj: (dest: IObjectOf<any>, ...xs: IObjectOf<any>[]) => any; | ||
import type { IObjectOf, Nullable } from "@thi.ng/api"; | ||
export declare const mergeDeepObj: (dest: IObjectOf<any>, ...xs: Nullable<IObjectOf<any>>[]) => any; | ||
//# sourceMappingURL=merge-deep.d.ts.map |
@@ -1,4 +0,4 @@ | ||
import type { Fn2, IObjectOf } from "@thi.ng/api"; | ||
export declare const mergeMapWith: <K, V>(f: Fn2<V, V, V>, dest: Map<K, V>, ...xs: Map<K, V>[]) => Map<K, V>; | ||
export declare const mergeObjWith: <T>(f: Fn2<T, T, T>, dest: IObjectOf<T>, ...xs: IObjectOf<T>[]) => IObjectOf<T>; | ||
import type { Fn2, IObjectOf, Nullable } from "@thi.ng/api"; | ||
export declare const mergeMapWith: <K, V>(f: Fn2<V, V, V>, dest: Map<K, V>, ...xs: Nullable<Map<K, V>>[]) => Map<K, V>; | ||
export declare const mergeObjWith: <T>(f: Fn2<T, T, T>, dest: IObjectOf<T>, ...xs: Nullable<IObjectOf<T>>[]) => IObjectOf<T>; | ||
//# sourceMappingURL=merge-with.d.ts.map |
@@ -5,4 +5,6 @@ import { copy } from "./utils"; | ||
for (let x of xs) { | ||
for (let [k, v] of x) { | ||
res.set(k, res.has(k) ? f(res.get(k), v) : v); | ||
if (x != null) { | ||
for (let [k, v] of x) { | ||
res.set(k, res.has(k) ? f(res.get(k), v) : v); | ||
} | ||
} | ||
@@ -15,5 +17,7 @@ } | ||
for (let x of xs) { | ||
for (let k in x) { | ||
const v = x[k]; | ||
res[k] = res.hasOwnProperty(k) ? f(dest[k], v) : v; | ||
if (x != null) { | ||
for (let k in x) { | ||
const v = x[k]; | ||
res[k] = res.hasOwnProperty(k) ? f(dest[k], v) : v; | ||
} | ||
} | ||
@@ -20,0 +24,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import type { IObjectOf } from "@thi.ng/api"; | ||
import type { IObjectOf, Nullable } from "@thi.ng/api"; | ||
/** | ||
@@ -9,3 +9,3 @@ * Merges all given maps in left-to-right order into `dest`. | ||
*/ | ||
export declare const mergeMap: <K, V>(dest: Map<K, V>, ...xs: Map<K, V>[]) => Map<K, V>; | ||
export declare const mergeMap: <K, V>(dest: Map<K, V>, ...xs: Nullable<Map<K, V>>[]) => Map<K, V>; | ||
/** | ||
@@ -18,3 +18,3 @@ * Merges all given objects in left-to-right order into `dest`. | ||
*/ | ||
export declare const mergeObj: <T>(dest: IObjectOf<T>, ...xs: IObjectOf<T>[]) => IObjectOf<T>; | ||
export declare const mergeObj: <T>(dest: IObjectOf<T>, ...xs: Nullable<IObjectOf<T>>[]) => IObjectOf<T>; | ||
//# sourceMappingURL=merge.d.ts.map |
@@ -10,4 +10,6 @@ /** | ||
for (let x of xs) { | ||
for (let pair of x) { | ||
dest.set(pair[0], pair[1]); | ||
if (x != null) { | ||
for (let pair of x) { | ||
dest.set(pair[0], pair[1]); | ||
} | ||
} | ||
@@ -14,0 +16,0 @@ } |
{ | ||
"name": "@thi.ng/associative", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "Alternative Map and Set implementations with customizable equality semantics & supporting operations", | ||
@@ -14,6 +14,12 @@ "module": "./index.js", | ||
"homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/associative#readme", | ||
"funding": { | ||
"type": "patreon", | ||
"url": "https://patreon.com/thing_umbrella" | ||
}, | ||
"funding": [ | ||
{ | ||
"type": "github", | ||
"url": "https://github.com/sponsors/postspectacular" | ||
}, | ||
{ | ||
"type": "patreon", | ||
"url": "https://patreon.com/thing_umbrella" | ||
} | ||
], | ||
"author": "Karsten Schmidt <k+npm@thi.ng>", | ||
@@ -47,10 +53,10 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@thi.ng/api": "^6.11.1", | ||
"@thi.ng/binary": "^2.0.8", | ||
"@thi.ng/checks": "^2.7.1", | ||
"@thi.ng/compare": "^1.3.8", | ||
"@thi.ng/dcons": "^2.2.20", | ||
"@thi.ng/equiv": "^1.0.23", | ||
"@thi.ng/errors": "^1.2.14", | ||
"@thi.ng/transducers": "^7.1.0", | ||
"@thi.ng/api": "^6.11.2", | ||
"@thi.ng/binary": "^2.0.9", | ||
"@thi.ng/checks": "^2.7.2", | ||
"@thi.ng/compare": "^1.3.9", | ||
"@thi.ng/dcons": "^2.2.21", | ||
"@thi.ng/equiv": "^1.0.24", | ||
"@thi.ng/errors": "^1.2.15", | ||
"@thi.ng/transducers": "^7.1.1", | ||
"tslib": "^1.12.0" | ||
@@ -93,3 +99,3 @@ }, | ||
}, | ||
"gitHead": "ddf9b8b67d3d60bcca88143528ee33b843cc089e" | ||
"gitHead": "71008cd78a3288d0f740c3e4b379b353f5c926b9" | ||
} |
@@ -175,3 +175,3 @@ <!-- This file is generated - DO NOT EDIT! --> | ||
Package sizes (gzipped, pre-treeshake): ESM: 5.62 KB / CJS: 5.82 KB / UMD: 5.64 KB | ||
Package sizes (gzipped, pre-treeshake): ESM: 5.66 KB / CJS: 5.86 KB / UMD: 5.67 KB | ||
@@ -178,0 +178,0 @@ ## Dependencies |
@@ -39,3 +39,11 @@ import type { Fn3, IObjectOf, Pair } from "@thi.ng/api"; | ||
dissoc(keys: Iterable<K>): this; | ||
forEach(fn: Fn3<V, Readonly<K>, Map<K, V>, void>, thisArg?: any): void; | ||
/** | ||
* The key & value args given the callback `fn` MUST be treated as | ||
* readonly/immutable. This could be enforced via TS, but would | ||
* break ES6 Map interface contract. | ||
* | ||
* @param fn | ||
* @param thisArg | ||
*/ | ||
forEach(fn: Fn3<V, K, Map<K, V>, void>, thisArg?: any): void; | ||
$reduce(rfn: ReductionFn<any, Pair<K, V>>, acc: any): any; | ||
@@ -42,0 +50,0 @@ opts(): SortedMapOpts<K>; |
@@ -201,2 +201,10 @@ import { __decorate } from "tslib"; | ||
} | ||
/** | ||
* The key & value args given the callback `fn` MUST be treated as | ||
* readonly/immutable. This could be enforced via TS, but would | ||
* break ES6 Map interface contract. | ||
* | ||
* @param fn | ||
* @param thisArg | ||
*/ | ||
forEach(fn, thisArg) { | ||
@@ -203,0 +211,0 @@ for (let p of this) { |
@@ -17,4 +17,6 @@ import type { IObjectOf } from "@thi.ng/api"; | ||
delete(prefix: K, val?: T): boolean; | ||
protected makeChild(): Trie<K, T>; | ||
protected makeValueSet(): Set<T>; | ||
protected queueChildren(queue: [string, Trie<any, any>][], prefix: string, sep?: string): void; | ||
} | ||
//# sourceMappingURL=trie.d.ts.map |
10
trie.js
@@ -78,6 +78,6 @@ import { map, vals } from "@thi.ng/transducers"; | ||
const next = node.next[k]; | ||
node = !next ? (node.n++, (node.next[k] = new Trie())) : next; | ||
node = !next ? (node.n++, (node.next[k] = this.makeChild())) : next; | ||
} | ||
if (!node.vals) | ||
node.vals = new Set(); | ||
node.vals = this.makeValueSet(); | ||
node.vals.add(val); | ||
@@ -122,2 +122,8 @@ } | ||
} | ||
makeChild() { | ||
return new Trie(); | ||
} | ||
makeValueSet() { | ||
return new Set(); | ||
} | ||
queueChildren(queue, prefix, sep = "") { | ||
@@ -124,0 +130,0 @@ prefix = prefix.length ? prefix + sep : prefix; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
312060
4430
Updated@thi.ng/api@^6.11.2
Updated@thi.ng/binary@^2.0.9
Updated@thi.ng/checks@^2.7.2
Updated@thi.ng/compare@^1.3.9
Updated@thi.ng/dcons@^2.2.21
Updated@thi.ng/equiv@^1.0.24
Updated@thi.ng/errors@^1.2.15
Updated@thi.ng/transducers@^7.1.1