@thi.ng/associative
Advanced tools
Comparing version 5.0.8 to 5.0.9
@@ -6,2 +6,10 @@ # Change Log | ||
## [5.0.9](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@5.0.8...@thi.ng/associative@5.0.9) (2020-11-24) | ||
**Note:** Version bump only for package @thi.ng/associative | ||
## [5.0.8](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@5.0.7...@thi.ng/associative@5.0.8) (2020-10-19) | ||
@@ -8,0 +16,0 @@ |
@@ -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="undefined"!=typeof globalThis?globalThis: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,n,r,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(!n.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},f=r.isNode()?require("util").inspect:null,g=(e,t)=>[...i.map(e=>f(e,t),e)].join(", "),d=(e,t)=>[...i.map(([e,s])=>`${f(e,t)} => ${f(s,t)}`,e)].join(", "),y=s.mixin({[Symbol.for("nodejs.util.inspect.custom")](e,t){const s=this[Symbol.toStringTag],n=Object.assign(Object.assign({},t),{depth:null===t.depth?null:t.depth-1});return e>=0?[`${s}(${this.size||0}) {`,f?this instanceof Set?g(this,n):this instanceof Map?d(this,n):"":"","}"].join(" "):t.stylize(`[${s}]`,"special")}});function S(e,t){if(r.isMap(e))for(let s of t)e.set(s[0],s[1]);else for(let s of t)e.add(s);return e}var v;const m=new WeakMap,b=e=>m.get(e).vals;e.ArraySet=v=class extends Set{constructor(e,t={}){super(),m.set(this,{equiv:t.equiv||n.equiv,vals:[]}),e&&this.into(e)}*[Symbol.iterator](){yield*b(this)}get[Symbol.species](){return v}get[Symbol.toStringTag](){return"ArraySet"}get size(){return b(this).length}copy(){const e=m.get(this),t=new v(null,{equiv:e.equiv});return m.get(t).vals=e.vals.slice(),t}empty(){return new v(null,this.opts())}clear(){b(this).length=0}first(){if(this.size)return b(this)[0]}add(e){return!this.has(e)&&b(this).push(e),this}into(e){return S(this,e)}has(e){return this.get(e,s.SEMAPHORE)!==s.SEMAPHORE}get(e,t){const s=m.get(this),n=s.equiv,r=s.vals;for(let t=r.length;--t>=0;)if(n(r[t],e))return r[t];return t}delete(e){const t=m.get(this),s=t.equiv,n=t.vals;for(let t=n.length;--t>=0;)if(s(n[t],e))return n.splice(t,1),!0;return!1}disj(e){return l(this,e)}equiv(e){return p(this,e)}forEach(e,t){const s=b(this);for(let n=s.length;--n>=0;){const r=s[n];e.call(t,r,r,this)}}*entries(){for(let e of b(this))yield[e,e]}*keys(){yield*b(this)}*values(){yield*b(this)}opts(){return{equiv:m.get(this).equiv}}},e.ArraySet=v=t.__decorate([y],e.ArraySet);const w=(e,t,s=[])=>{for(let n in e)t.hasOwnProperty(n)&&s.push(n);return s},x=(e,t)=>r.implementsFunction(e,"empty")?e.empty():new(e[Symbol.species]||t),k=(e,t)=>r.implementsFunction(e,"copy")?e.copy():new(e[Symbol.species]||t)(e),M=e=>e[Symbol.iterator]().next().value,q=e=>r.isSet(e)?e:new Set(e),O=(e,t,s)=>s?i.reduce(e(),s):[()=>null,e=>e||new Set,(e,s)=>e?t(e,q(s)):q(s)],j=(e,t,s)=>{if(e===t)return s||x(e,Set);s=s?S(s,e):k(e,Set);for(let e of t)s.delete(e);return s};var A;const z=new WeakMap,E=e=>z.get(e).map;var P;e.EquivMap=A=class extends Map{constructor(t,s){super();const r=Object.assign({equiv:n.equiv,keys:e.ArraySet},s);z.set(this,{keys:new r.keys(null,{equiv:r.equiv}),map:new Map,opts:r}),t&&this.into(t)}[Symbol.iterator](){return this.entries()}get[Symbol.species](){return A}get[Symbol.toStringTag](){return"EquivMap"}get size(){return z.get(this).keys.size}clear(){const e=z.get(this);e.keys.clear(),e.map.clear()}empty(){return new A(null,z.get(this).opts)}copy(){const e=z.get(this),t=new A;return z.set(t,{keys:e.keys.copy(),map:new Map(e.map),opts:e.opts}),t}equiv(e){return c(this,e)}delete(e){const t=z.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 n=z.get(this);return(e=n.keys.get(e,s.SEMAPHORE))!==s.SEMAPHORE?n.map.get(e):t}has(e){return z.get(this).keys.has(e)}set(e,t){const n=z.get(this),r=n.keys.get(e,s.SEMAPHORE);return r!==s.SEMAPHORE?n.map.set(r,t):(n.keys.add(e),n.map.set(e,t)),this}into(e){return S(this,e)}entries(){return E(this).entries()}keys(){return E(this).keys()}values(){return E(this).values()}opts(){return z.get(this).opts}},e.EquivMap=A=t.__decorate([y],e.EquivMap);const _=new WeakMap,T=(e,t)=>function*(){for(let s of _.get(e).bins)s&&(yield s[t])};e.HashMap=P=class extends Map{constructor(e,t){super();const s=o.ceilPow2(Math.min(t.cap||16,4))-1;_.set(this,{hash:t.hash,equiv:t.equiv||n.equiv,load:t.load||.75,mask:s,bins:new Array(s+1),size:0}),e&&this.into(e)}get[Symbol.species](){return P}get[Symbol.toStringTag](){return"HashMap"}get size(){return _.get(this).size}[Symbol.iterator](){return this.entries()}*entries(){for(let e of _.get(this).bins)e&&(yield[e[0],e[1]])}keys(){return T(this,0)()}values(){return T(this,1)()}forEach(e,t){for(let s of _.get(this).bins)e.call(t,s[1],s[0],this)}clear(){const e=_.get(this);e.bins=new Array(16),e.mask=15,e.size=0}empty(){return new P(null,this.opts({cap:16}))}copy(){const e=_.get(this),t=new P(null,this.opts({cap:4}));return Object.assign(_.get(t),{bins:e.bins.slice(),mask:e.mask,size:e.size}),t}equiv(e){return c(this,e)}has(e){const t=_.get(this),s=this.find(e,t);return s>=0&&null!=t.bins[s]}get(e,t){const s=_.get(this),n=this.find(e,s);return n>=0&&s.bins[n]?s.bins[n][1]:t}set(e,t){const s=_.get(this);let n=this.find(e,s);return n>=0&&s.bins[n]?(s.bins[n][1]=t,this):(s.size>s.mask*s.load&&(this.resize(s),n=this.find(e,s)),s.bins[n]=[e,t],s.size++,this)}delete(e){const t=_.get(this);let s=this.find(e,t);const n=t.bins;if(s>=0&&!n[s])return!1;t.size--;const r=t.mask;let i,o=s;for(;;){delete n[s];do{if(o=o+1&r,!n[o])return!0;i=t.hash(n[o][0])&r}while(s<=o?s<i&&i<=o:s<i||i<=o);n[s]=n[o],s=o}}into(e){return S(this,e)}dissoc(e){return l(this,e)}opts(e){const t=_.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,n=t.bins,r=t.equiv;let i=s,o=t.hash(e)&s;for(;n[o]&&!r(n[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])}},e.HashMap=P=t.__decorate([y],e.HashMap);const H=(e,t)=>{const s={};for(let n of t)e.hasOwnProperty(n)&&(s[n]=e[n]);return s},L=(t,s)=>{const n=new e.EquivMap;let r,i,o;for(r of t)i=H(r,s),o=n.get(i),!o&&n.set(i,o=x(t,Set)),o.add(r);return n},R=(e,t,s)=>{if(s=s||x(e,Set),e===t)return S(s,e);if(t.size<e.size)return R(t,e,s);for(let n of t)e.has(n)&&s.add(n);return s};const U=(e,t={})=>{for(let s in e)t[e[s]]=s;return t},C=(e,...t)=>Object.assign(e,...t),W=(e,t,s={})=>{for(let n in e)s[t.hasOwnProperty(n)?t[n]:n]=e[n];return s},F=(e,t,s)=>{if(e.size&&t.size){let n,r,i;e.size<=t.size?(n=e,r=t,i=U(s)):(n=t,r=e,i=s);const o=L(n,(e=>{const t=[];for(let s in e)e.hasOwnProperty(s)&&t.push(e[s]);return t})(i)),a=Object.keys(i),h=x(e,Set);for(let e of r){const t=o.get(W(H(e,a),i));if(t)for(let s of t)h.add(C(Object.assign({},s),e))}return h}return x(e,Set)};var K;F(new Set([{a:1,b:2}]),new Set([{id:1,c:2}]),{a:"id"});const D=new WeakMap,$=e=>D.get(e).vals;e.LLSet=K=class extends Set{constructor(e,t={}){super(),D.set(this,{equiv:t.equiv||n.equiv,vals:new a.DCons}),e&&this.into(e)}*[Symbol.iterator](){yield*$(this)}get[Symbol.species](){return K}get[Symbol.toStringTag](){return"LLSet"}get size(){return $(this).length}copy(){const e=D.get(this),t=new K(null,this.opts());return D.get(t).vals=e.vals.copy(),t}empty(){return new K(null,this.opts())}clear(){$(this).clear()}first(){if(this.size)return $(this).head.value}add(e){return!this.has(e)&&$(this).push(e),this}into(e){return S(this,e)}has(e){return this.get(e,s.SEMAPHORE)!==s.SEMAPHORE}get(e,t){const s=D.get(this),n=s.equiv;let r=s.vals.head;for(;r;){if(n(r.value,e))return r.value;r=r.next}return t}delete(e){const t=D.get(this),s=t.equiv;let n=t.vals.head;for(;n;){if(s(n.value,e))return t.vals.splice(n,1),!0;n=n.next}return!1}disj(e){return l(this,e)}equiv(e){return p(this,e)}forEach(e,t){let s=$(this).head;for(;s;)e.call(t,s.value,s.value,this),s=s.next}*entries(){for(let e of $(this))yield[e,e]}*keys(){yield*$(this)}*values(){yield*$(this)}opts(){return{equiv:D.get(this).equiv}}},e.LLSet=K=t.__decorate([y],e.LLSet);const N=(e,t)=>{for(let s in t){if("__proto__"===s)continue;const n=t[s];e[s]=r.isFunction(n)?n(e[s]):n}return e},B=(e,t,...s)=>G(e,Object.assign({},t),...s),G=(e,t,...s)=>{for(let n of s)if(null!=n)for(let s in n){if("__proto__"===s)continue;const r=n[s];t[s]=t.hasOwnProperty(s)?e(t[s],r):r}return t},I=(e,...t)=>B((e,t)=>r.isPlainObject(e)&&r.isPlainObject(t)?I(e,t):t,e,...t),J=(e,...t)=>G((e,t)=>r.isPlainObject(e)&&r.isPlainObject(t)?J(e,t):t,e,...t);class Q{constructor(e,t){this.opts=t,this.next={},this.n=0,e&&this.into(e)}*[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,n]=s.pop();n.vals?yield t:n.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))}}*suffixes(e,t=!1,s=""){const n=this.find(e);n&&(yield*n.keys(s,t?r.isArray(e)?e.join(s):e.toString():""))}clear(){this.next={},this.n=0,this.vals=void 0}has(e){return!!this.get(e)}hasPrefix(e){return!!this.find(e)}get(e){const t=this.find(e);return t?t.vals:void 0}find(e){let t=this;for(let s=0,n=e.length;s<n;s++)if(t=t.next[e[s].toString()],!t)return;return t}knownPrefix(e){let t=this;const s=[];for(let n=0,r=e.length;n<r;n++){const r=e[n].toString(),i=t.next[r];if(!i)break;s.push(r),t=i}return s}hasKnownPrefix(e){return this.knownPrefix(e).length>0}add(e,t){var s;let n=this;for(let t=0,s=e.length;t<s;t++){const s=e[t].toString(),r=n.next[s];n=r||(n.n++,n.next[s]=new Q(null,this.opts))}if(!n.vals){const e=null===(s=this.opts)||void 0===s?void 0:s.vals;n.vals=e?e():new Set}n.vals.add(t)}into(e){for(let[t,s]of e)this.add(t,s)}delete(e,t){const s=e.length;if(s<1)return!1;const n=[],r=[];let i=0,o=this;for(;i<s;i++){const t=e[i].toString();if(r.push(t),n.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=n[--i])&&(delete o.next[r[i]],!--o.n););return!0}queueChildren(e,t,s=""){t=t.length?t+s:t,e.push(...Object.keys(this.next).map(e=>[t+e,this.next[e]]))}}var V;class X{constructor(e,t,s){this.k=e,this.v=t,this.next=new Array(s+1)}}const Y=new WeakMap;var Z;e.SortedMap=V=class extends Map{constructor(e,t={}){super();const s=t.capacity||V.DEFAULT_CAP,n=Math.ceil(Math.log2(s));Y.set(this,{head:new X(null,null,0),cap:Math.pow(2,n),cmp:t.compare||h.compare,p:t.probability||V.DEFAULT_P,maxh:n,length:0,h:0}),e&&this.into(e)}get[Symbol.species](){return V}*[Symbol.iterator](){let e=Y.get(this).head;for(;e=e.next[0];)yield[e.k,e.v]}*entries(e,t=!1){const s=Y.get(this);let n=s.head;const r=s.cmp;let i;if(t){for(;n=n.next[0];)if((void 0===e||(i=r(n.k,e))<=0)&&(yield[n.k,n.v],0===i))return}else for(;n=n.next[0];)(void 0===e||(i=r(n.k,e))>=0)&&(yield[n.k,n.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 Y.get(this).length}clear(){const e=Y.get(this);e.head=new X(null,null,0),e.length=0,e.h=0}empty(){return new V(null,Object.assign(Object.assign({},this.opts()),{capacity:V.DEFAULT_CAP}))}copy(){return new V(this,this.opts())}compare(e){const t=this.size,s=e.size;if(t<s)return-1;if(t>s)return 1;const n=this.entries(),r=e.entries();let i,o,a;for(;i=n.next(),o=r.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=Y.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===Y.get(this).cmp(s.k,e)?s.v:t}has(e){return this.get(e,s.SEMAPHORE)!==s.SEMAPHORE}set(e,t){const s=Y.get(this);let n=s.head,r=s.h,i=new Array(r);const o=s.cmp;let a;for(;r>=0;){for(;n.next[r]&&(a=o(n.next[r].k,e))<0;)n=n.next[r];if(n.next[r]&&0===a){do{n.next[r].v=t}while(--r>=0);return this}i[r--]=n}const h=this.pickHeight(s.maxh,s.h,s.p);for(n=new X(e,t,h);s.h<h;)i[++s.h]=s.head;for(let e=0;e<=h;e++)n.next[e]=i[e].next[e],i[e].next[e]=n;return s.length++,s.length>=s.cap&&(s.cap*=2,s.maxh++),this}delete(e){const t=Y.get(this);let s=t.head,n=t.h,r=!1;const i=t.cmp;let o;for(;n>=0;){for(;s.next[n]&&(o=i(s.next[n].k,e))<0;)s=s.next[n];s.next[n]&&0===o&&(r=!0,s.next[n]=s.next[n].next[n],s!=t.head||s.next[n]||(t.h=Math.max(0,t.h-1))),n--}return r&&t.length--,r}into(e){return S(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=Y.get(this).head;for(;(s=s.next[0])&&!i.isReduced(t);)t=e(t,[s.k,s.v]);return t}opts(){const e=Y.get(this);return{capacity:e.cap,compare:e.cmp,probability:e.p}}findPredNode(e){const t=Y.get(this),s=t.cmp;let n=t.head,r=t.h;for(;r>=0;){for(;n.next[r]&&s(n.next[r].k,e)<0;)n=n.next[r];r--}return n}pickHeight(e,t,s){const n=Math.min(e,t+1);let r=0;for(;Math.random()<s&&r<n;)r++;return r}},e.SortedMap.DEFAULT_CAP=8,e.SortedMap.DEFAULT_P=1/Math.E,e.SortedMap=V=t.__decorate([y],e.SortedMap);const ee=new WeakMap;e.SortedSet=Z=class extends Set{constructor(t,s){super(),ee.set(this,new e.SortedMap(t?i.map(e=>[e,e],t):null,s))}[Symbol.iterator](){return this.keys()}get[Symbol.species](){return Z}get[Symbol.toStringTag](){return"SortedSet"}get size(){return ee.get(this).size}copy(){return new Z(this.keys(),this.opts())}empty(){return new Z(null,Object.assign(Object.assign({},this.opts()),{capacity:e.SortedMap.DEFAULT_CAP}))}compare(e){const t=this.size,s=e.size;if(t<s)return-1;if(t>s)return 1;const n=this.entries(),r=e.entries();let i,o,a;for(;i=n.next(),o=r.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 ee.get(this).$reduce((t,s)=>e(t,s[0]),t)}entries(e,t=!1){return ee.get(this).entries(e,t)}keys(e,t=!1){return ee.get(this).keys(e,t)}values(e,t=!1){return ee.get(this).values(e,t)}add(e){return ee.get(this).set(e,e),this}into(e){return S(this,e)}clear(){ee.get(this).clear()}first(){const e=ee.get(this).first();return e?e[0]:void 0}delete(e){return ee.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 ee.get(this).has(e)}get(e,t){return ee.get(this).get(e,t)}opts(){return ee.get(this).opts()}},e.SortedSet=Z=t.__decorate([y],e.SortedSet);const te=new WeakMap,se=()=>u.illegalArgs("dense & sparse arrays must be of same size");e.ASparseSet=class extends Set{constructor(e,t){super(),te.set(this,{dense:e,sparse:t,n:0})}[Symbol.iterator](){return this.keys()}get size(){return te.get(this).n}get capacity(){return te.get(this).dense.length}clear(){te.get(this).n=0}equiv(e){if(this===e)return!0;if(!(e instanceof Set)||this.size!==e.size)return!1;const t=te.get(this),s=t.dense;for(let n=t.n;--n>=0;)if(!e.has(s[n]))return!1;return!0}add(e){const t=te.get(this),s=t.dense,n=t.sparse,r=s.length,i=n[e],o=t.n;return e<r&&o<r&&!(i<o&&s[i]===e)&&(s[o]=e,n[e]=o,t.n++),this}delete(e){const t=te.get(this),s=t.dense,n=t.sparse,r=n[e];if(r<t.n&&s[r]===e){const e=s[--t.n];return s[r]=e,n[e]=r,!0}return!1}has(e){const t=te.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=te.get(this);return e.n?e.dense[0]:void 0}into(e){return S(this,e)}disj(e){return l(this,e)}forEach(e,t){const s=te.get(this),n=s.dense,r=s.n;for(let s=0;s<r;s++){const r=n[s];e.call(t,r,r,this)}}*entries(){const e=te.get(this),t=e.dense,s=e.n;for(let e=0;e<s;e++)yield[t[e],t[e]]}*keys(){const e=te.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=te.get(this),s=te.get(e);return s.dense=t.dense.slice(),s.sparse=t.sparse.slice(),s.n=t.n,e}},e.ASparseSet=t.__decorate([y],e.ASparseSet);class ne extends e.ASparseSet{constructor(e,t){r.isNumber(e)?super(new Uint8Array(e),new Uint8Array(e)):e.length===t.length?super(e,t):se()}get[Symbol.species](){return ne}get[Symbol.toStringTag](){return"SparseSet8"}copy(){return this.__copyTo(new ne(0))}empty(){return new ne(this.capacity)}}class re extends e.ASparseSet{constructor(e,t){r.isNumber(e)?super(new Uint16Array(e),new Uint16Array(e)):e.length===t.length?super(e,t):se()}get[Symbol.species](){return re}get[Symbol.toStringTag](){return"SparseSet16"}copy(){return this.__copyTo(new re(0))}empty(){return new re(this.capacity)}}class ie extends e.ASparseSet{constructor(e,t){r.isNumber(e)?super(new Uint32Array(e),new Uint32Array(e)):e.length===t.length?super(e,t):se()}get[Symbol.species](){return ie}get[Symbol.toStringTag](){return"SparseSet32"}copy(){return this.__copyTo(new ie(0))}empty(){return new ie(this.capacity)}}class oe{constructor(e){this.next={},this.n=0,e&&this.into(e)}*[Symbol.iterator](){const e=[["",this]];for(;e.length;){const[t,s]=e.pop();void 0!==s.val?yield[t,s.val]:s.queueChildren(e,t)}}*keys(e=""){const t=[[e,this]];for(;t.length;){const[e,s]=t.pop();void 0!==s.val?yield e:s.queueChildren(t,e)}}*values(){const e=[this];for(;e.length;){const t=e.pop();void 0!==t.val?yield t.val:e.push(...i.vals(t.next))}}*suffixes(e,t=!1){const s=this.find(e);s&&(yield*s.keys(t?e:""))}clear(){this.next={},this.n=0,this.val=void 0}has(e){return void 0!==this.get(e)}hasPrefix(e){return!!this.find(e)}get(e,t){const s=this.find(e);return s?s.val:t}find(e){let t=this;for(let s=0,n=e.length;s<n;s++)if(t=t.next[e[s]],!t)return;return t}knownPrefix(e){let t=this,s="";for(let n=0,r=e.length;n<r;n++){const r=e[n],i=t.next[r];if(!i)break;s+=r,t=i}return s||void 0}hasKnownPrefix(e){return!!this.knownPrefix(e)}set(e,t){let s=this;for(let t=0,n=e.length;t<n;t++){const n=e[t],r=s.next[n];s=r||(s.n++,s.next[n]=new oe)}s.val=t}into(e){for(let[t,s]of e)this.set(t,s)}delete(e){const t=e.length;if(t<1)return!1;const s=[],n=[];let r=0,i=this;for(;r<t;r++){const t=e[r];if(n.push(t),s.push(i),i=i.next[t],!i)return!1}for(;(i=s[--r])&&(delete i.next[n[r]],!--i.n););return!0}queueChildren(e,t){e.push(...Object.keys(this.next).map(e=>[t+e,this.next[e]]))}}const ae=(e,t,s)=>{if(e.size<t.size){const s=e;e=t,t=s}return s=s?S(s,e):k(e,Set),e===t?s:S(s,t)};e.MultiTrie=Q,e.SparseSet16=re,e.SparseSet32=ie,e.SparseSet8=ne,e.TrieMap=oe,e.commonKeysMap=(e,t,s=[])=>{for(let n of e.keys())t.has(n)&&s.push(n);return s},e.commonKeysObj=w,e.defArraySet=(t,s)=>new e.ArraySet(t,s),e.defEquivMap=function(t,s){return new e.EquivMap(r.isPlainObject(t)?i.pairs(t):t,s)},e.defHashMap=function(t,s){if(r.isPlainObject(t)){const n=Object.keys(t);return new e.HashMap(i.map(e=>[e,t[e]],n),Object.assign({cap:n.length/(s.load||.75)},s))}return new e.HashMap(t,s)},e.defLLSet=(t,s)=>new e.LLSet(t,s),e.defMultiTrie=(e,t)=>new Q(e,t),e.defSortedMap=function(t,s){if(r.isPlainObject(t)){const n=Object.keys(t);return new e.SortedMap(i.map(e=>[e,t[e]],n),Object.assign({capacity:n.length},s))}return new e.SortedMap(t,s)},e.defSortedSet=(t,s)=>new e.SortedSet(t,s),e.defSparseSet=e=>e<=256?new ne(e):e<=65536?new re(e):new ie(e),e.defTrieMap=e=>new oe(e),e.difference=j,e.differenceR=function e(t){return O(e,j,t)},e.dissoc=l,e.dissocObj=(e,t)=>{for(let s of t)delete e[s];return e},e.indexed=L,e.intersection=R,e.intersectionR=function e(t){return O(e,R,t)},e.into=S,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 n,r;e.size<=t.size?(n=e,r=t):(n=t,r=e);const i=L(n,s),o=x(e,Set);for(let e of r){const t=i.get(H(e,s));if(t)for(let s of t)o.add(C(Object.assign({},s),e))}return o}return x(e,Set)},e.joinWith=F,e.meldApplyObj=N,e.meldDeepObj=J,e.meldObjWith=G,e.mergeApplyMap=(e,t)=>{const s=k(e,Map);for(let[e,n]of t)s.set(e,r.isFunction(n)?n(s.get(e)):n);return s},e.mergeApplyObj=(e,t)=>N(Object.assign({},e),t),e.mergeDeepObj=I,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 n=k(t,Map);for(let t of s)if(null!=t)for(let[s,r]of t)n.set(s,n.has(s)?e(n.get(s),r):r);return n},e.mergeObj=C,e.mergeObjWith=B,e.renameKeysMap=(e,t,s)=>{s=s||x(e,Map);for(let[n,r]of e)s.set(t.has(n)?t.get(n):n,r);return s},e.renameKeysObj=W,e.selectKeysMap=(e,t)=>{const s=x(e,Map);for(let n of t)e.has(n)&&s.set(n,e.get(n));return s},e.selectKeysObj=H,e.union=ae,e.unionR=function e(t){return O(e,ae,t)},e.withoutKeysMap=(e,t)=>{const s=q(t),n=x(e,Map);for(let t of e.entries()){const e=t[0];!s.has(e)&&n.set(e,t[1])}return n},e.withoutKeysObj=(e,t)=>{const s=q(t),n={};for(let t in e)e.hasOwnProperty(t)&&!s.has(t)&&(n[t]=e[t]);return n},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="undefined"!=typeof globalThis?globalThis: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,n,r,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(!n.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},f=r.isNode()?require("util").inspect:null,g=(e,t)=>[...i.map((e=>f(e,t)),e)].join(", "),d=(e,t)=>[...i.map((([e,s])=>`${f(e,t)} => ${f(s,t)}`),e)].join(", "),y=s.mixin({[Symbol.for("nodejs.util.inspect.custom")](e,t){const s=this[Symbol.toStringTag],n=Object.assign(Object.assign({},t),{depth:null===t.depth?null:t.depth-1});return e>=0?[`${s}(${this.size||0}) {`,f?this instanceof Set?g(this,n):this instanceof Map?d(this,n):"":"","}"].join(" "):t.stylize(`[${s}]`,"special")}});function S(e,t){if(r.isMap(e))for(let s of t)e.set(s[0],s[1]);else for(let s of t)e.add(s);return e}var v;const m=new WeakMap,b=e=>m.get(e).vals;e.ArraySet=v=class extends Set{constructor(e,t={}){super(),m.set(this,{equiv:t.equiv||n.equiv,vals:[]}),e&&this.into(e)}*[Symbol.iterator](){yield*b(this)}get[Symbol.species](){return v}get[Symbol.toStringTag](){return"ArraySet"}get size(){return b(this).length}copy(){const e=m.get(this),t=new v(null,{equiv:e.equiv});return m.get(t).vals=e.vals.slice(),t}empty(){return new v(null,this.opts())}clear(){b(this).length=0}first(){if(this.size)return b(this)[0]}add(e){return!this.has(e)&&b(this).push(e),this}into(e){return S(this,e)}has(e){return this.get(e,s.SEMAPHORE)!==s.SEMAPHORE}get(e,t){const s=m.get(this),n=s.equiv,r=s.vals;for(let t=r.length;--t>=0;)if(n(r[t],e))return r[t];return t}delete(e){const t=m.get(this),s=t.equiv,n=t.vals;for(let t=n.length;--t>=0;)if(s(n[t],e))return n.splice(t,1),!0;return!1}disj(e){return l(this,e)}equiv(e){return p(this,e)}forEach(e,t){const s=b(this);for(let n=s.length;--n>=0;){const r=s[n];e.call(t,r,r,this)}}*entries(){for(let e of b(this))yield[e,e]}*keys(){yield*b(this)}*values(){yield*b(this)}opts(){return{equiv:m.get(this).equiv}}},e.ArraySet=v=t.__decorate([y],e.ArraySet);const w=(e,t,s=[])=>{for(let n in e)t.hasOwnProperty(n)&&s.push(n);return s},x=(e,t)=>r.implementsFunction(e,"empty")?e.empty():new(e[Symbol.species]||t),k=(e,t)=>r.implementsFunction(e,"copy")?e.copy():new(e[Symbol.species]||t)(e),M=e=>e[Symbol.iterator]().next().value,q=e=>r.isSet(e)?e:new Set(e),O=(e,t,s)=>s?i.reduce(e(),s):[()=>null,e=>e||new Set,(e,s)=>e?t(e,q(s)):q(s)],j=(e,t,s)=>{if(e===t)return s||x(e,Set);s=s?S(s,e):k(e,Set);for(let e of t)s.delete(e);return s};var A;const z=new WeakMap,E=e=>z.get(e).map;var P;e.EquivMap=A=class extends Map{constructor(t,s){super();const r=Object.assign({equiv:n.equiv,keys:e.ArraySet},s);z.set(this,{keys:new r.keys(null,{equiv:r.equiv}),map:new Map,opts:r}),t&&this.into(t)}[Symbol.iterator](){return this.entries()}get[Symbol.species](){return A}get[Symbol.toStringTag](){return"EquivMap"}get size(){return z.get(this).keys.size}clear(){const e=z.get(this);e.keys.clear(),e.map.clear()}empty(){return new A(null,z.get(this).opts)}copy(){const e=z.get(this),t=new A;return z.set(t,{keys:e.keys.copy(),map:new Map(e.map),opts:e.opts}),t}equiv(e){return c(this,e)}delete(e){const t=z.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 n=z.get(this);return(e=n.keys.get(e,s.SEMAPHORE))!==s.SEMAPHORE?n.map.get(e):t}has(e){return z.get(this).keys.has(e)}set(e,t){const n=z.get(this),r=n.keys.get(e,s.SEMAPHORE);return r!==s.SEMAPHORE?n.map.set(r,t):(n.keys.add(e),n.map.set(e,t)),this}into(e){return S(this,e)}entries(){return E(this).entries()}keys(){return E(this).keys()}values(){return E(this).values()}opts(){return z.get(this).opts}},e.EquivMap=A=t.__decorate([y],e.EquivMap);const _=new WeakMap,T=(e,t)=>function*(){for(let s of _.get(e).bins)s&&(yield s[t])};e.HashMap=P=class extends Map{constructor(e,t){super();const s=o.ceilPow2(Math.min(t.cap||16,4))-1;_.set(this,{hash:t.hash,equiv:t.equiv||n.equiv,load:t.load||.75,mask:s,bins:new Array(s+1),size:0}),e&&this.into(e)}get[Symbol.species](){return P}get[Symbol.toStringTag](){return"HashMap"}get size(){return _.get(this).size}[Symbol.iterator](){return this.entries()}*entries(){for(let e of _.get(this).bins)e&&(yield[e[0],e[1]])}keys(){return T(this,0)()}values(){return T(this,1)()}forEach(e,t){for(let s of _.get(this).bins)e.call(t,s[1],s[0],this)}clear(){const e=_.get(this);e.bins=new Array(16),e.mask=15,e.size=0}empty(){return new P(null,this.opts({cap:16}))}copy(){const e=_.get(this),t=new P(null,this.opts({cap:4}));return Object.assign(_.get(t),{bins:e.bins.slice(),mask:e.mask,size:e.size}),t}equiv(e){return c(this,e)}has(e){const t=_.get(this),s=this.find(e,t);return s>=0&&null!=t.bins[s]}get(e,t){const s=_.get(this),n=this.find(e,s);return n>=0&&s.bins[n]?s.bins[n][1]:t}set(e,t){const s=_.get(this);let n=this.find(e,s);return n>=0&&s.bins[n]?(s.bins[n][1]=t,this):(s.size>s.mask*s.load&&(this.resize(s),n=this.find(e,s)),s.bins[n]=[e,t],s.size++,this)}delete(e){const t=_.get(this);let s=this.find(e,t);const n=t.bins;if(s>=0&&!n[s])return!1;t.size--;const r=t.mask;let i,o=s;for(;;){delete n[s];do{if(o=o+1&r,!n[o])return!0;i=t.hash(n[o][0])&r}while(s<=o?s<i&&i<=o:s<i||i<=o);n[s]=n[o],s=o}}into(e){return S(this,e)}dissoc(e){return l(this,e)}opts(e){const t=_.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,n=t.bins,r=t.equiv;let i=s,o=t.hash(e)&s;for(;n[o]&&!r(n[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])}},e.HashMap=P=t.__decorate([y],e.HashMap);const H=(e,t)=>{const s={};for(let n of t)e.hasOwnProperty(n)&&(s[n]=e[n]);return s},L=(t,s)=>{const n=new e.EquivMap;let r,i,o;for(r of t)i=H(r,s),o=n.get(i),!o&&n.set(i,o=x(t,Set)),o.add(r);return n},R=(e,t,s)=>{if(s=s||x(e,Set),e===t)return S(s,e);if(t.size<e.size)return R(t,e,s);for(let n of t)e.has(n)&&s.add(n);return s};const U=(e,t={})=>{for(let s in e)t[e[s]]=s;return t},C=(e,...t)=>Object.assign(e,...t),W=(e,t,s={})=>{for(let n in e)s[t.hasOwnProperty(n)?t[n]:n]=e[n];return s},F=(e,t,s)=>{if(e.size&&t.size){let n,r,i;e.size<=t.size?(n=e,r=t,i=U(s)):(n=t,r=e,i=s);const o=L(n,(e=>{const t=[];for(let s in e)e.hasOwnProperty(s)&&t.push(e[s]);return t})(i)),a=Object.keys(i),h=x(e,Set);for(let e of r){const t=o.get(W(H(e,a),i));if(t)for(let s of t)h.add(C(Object.assign({},s),e))}return h}return x(e,Set)};var K;F(new Set([{a:1,b:2}]),new Set([{id:1,c:2}]),{a:"id"});const D=new WeakMap,$=e=>D.get(e).vals;e.LLSet=K=class extends Set{constructor(e,t={}){super(),D.set(this,{equiv:t.equiv||n.equiv,vals:new a.DCons}),e&&this.into(e)}*[Symbol.iterator](){yield*$(this)}get[Symbol.species](){return K}get[Symbol.toStringTag](){return"LLSet"}get size(){return $(this).length}copy(){const e=D.get(this),t=new K(null,this.opts());return D.get(t).vals=e.vals.copy(),t}empty(){return new K(null,this.opts())}clear(){$(this).clear()}first(){if(this.size)return $(this).head.value}add(e){return!this.has(e)&&$(this).push(e),this}into(e){return S(this,e)}has(e){return this.get(e,s.SEMAPHORE)!==s.SEMAPHORE}get(e,t){const s=D.get(this),n=s.equiv;let r=s.vals.head;for(;r;){if(n(r.value,e))return r.value;r=r.next}return t}delete(e){const t=D.get(this),s=t.equiv;let n=t.vals.head;for(;n;){if(s(n.value,e))return t.vals.splice(n,1),!0;n=n.next}return!1}disj(e){return l(this,e)}equiv(e){return p(this,e)}forEach(e,t){let s=$(this).head;for(;s;)e.call(t,s.value,s.value,this),s=s.next}*entries(){for(let e of $(this))yield[e,e]}*keys(){yield*$(this)}*values(){yield*$(this)}opts(){return{equiv:D.get(this).equiv}}},e.LLSet=K=t.__decorate([y],e.LLSet);const N=(e,t)=>{for(let s in t){if("__proto__"===s)continue;const n=t[s];e[s]=r.isFunction(n)?n(e[s]):n}return e},B=(e,t,...s)=>G(e,Object.assign({},t),...s),G=(e,t,...s)=>{for(let n of s)if(null!=n)for(let s in n){if("__proto__"===s)continue;const r=n[s];t[s]=t.hasOwnProperty(s)?e(t[s],r):r}return t},I=(e,...t)=>B(((e,t)=>r.isPlainObject(e)&&r.isPlainObject(t)?I(e,t):t),e,...t),J=(e,...t)=>G(((e,t)=>r.isPlainObject(e)&&r.isPlainObject(t)?J(e,t):t),e,...t);class Q{constructor(e,t){this.opts=t,this.next={},this.n=0,e&&this.into(e)}*[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,n]=s.pop();n.vals?yield t:n.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))}}*suffixes(e,t=!1,s=""){const n=this.find(e);n&&(yield*n.keys(s,t?r.isArray(e)?e.join(s):e.toString():""))}clear(){this.next={},this.n=0,this.vals=void 0}has(e){return!!this.get(e)}hasPrefix(e){return!!this.find(e)}get(e){const t=this.find(e);return t?t.vals:void 0}find(e){let t=this;for(let s=0,n=e.length;s<n;s++)if(t=t.next[e[s].toString()],!t)return;return t}knownPrefix(e){let t=this;const s=[];for(let n=0,r=e.length;n<r;n++){const r=e[n].toString(),i=t.next[r];if(!i)break;s.push(r),t=i}return s}hasKnownPrefix(e){return this.knownPrefix(e).length>0}add(e,t){var s;let n=this;for(let t=0,s=e.length;t<s;t++){const s=e[t].toString(),r=n.next[s];n=r||(n.n++,n.next[s]=new Q(null,this.opts))}if(!n.vals){const e=null===(s=this.opts)||void 0===s?void 0:s.vals;n.vals=e?e():new Set}n.vals.add(t)}into(e){for(let[t,s]of e)this.add(t,s)}delete(e,t){const s=e.length;if(s<1)return!1;const n=[],r=[];let i=0,o=this;for(;i<s;i++){const t=e[i].toString();if(r.push(t),n.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=n[--i])&&(delete o.next[r[i]],!--o.n););return!0}queueChildren(e,t,s=""){t=t.length?t+s:t,e.push(...Object.keys(this.next).map((e=>[t+e,this.next[e]])))}}var V;class X{constructor(e,t,s){this.k=e,this.v=t,this.next=new Array(s+1)}}const Y=new WeakMap;var Z;e.SortedMap=V=class extends Map{constructor(e,t={}){super();const s=t.capacity||V.DEFAULT_CAP,n=Math.ceil(Math.log2(s));Y.set(this,{head:new X(null,null,0),cap:Math.pow(2,n),cmp:t.compare||h.compare,p:t.probability||V.DEFAULT_P,maxh:n,length:0,h:0}),e&&this.into(e)}get[Symbol.species](){return V}*[Symbol.iterator](){let e=Y.get(this).head;for(;e=e.next[0];)yield[e.k,e.v]}*entries(e,t=!1){const s=Y.get(this);let n=s.head;const r=s.cmp;let i;if(t){for(;n=n.next[0];)if((void 0===e||(i=r(n.k,e))<=0)&&(yield[n.k,n.v],0===i))return}else for(;n=n.next[0];)(void 0===e||(i=r(n.k,e))>=0)&&(yield[n.k,n.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 Y.get(this).length}clear(){const e=Y.get(this);e.head=new X(null,null,0),e.length=0,e.h=0}empty(){return new V(null,Object.assign(Object.assign({},this.opts()),{capacity:V.DEFAULT_CAP}))}copy(){return new V(this,this.opts())}compare(e){const t=this.size,s=e.size;if(t<s)return-1;if(t>s)return 1;const n=this.entries(),r=e.entries();let i,o,a;for(;i=n.next(),o=r.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=Y.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===Y.get(this).cmp(s.k,e)?s.v:t}has(e){return this.get(e,s.SEMAPHORE)!==s.SEMAPHORE}set(e,t){const s=Y.get(this);let n=s.head,r=s.h,i=new Array(r);const o=s.cmp;let a;for(;r>=0;){for(;n.next[r]&&(a=o(n.next[r].k,e))<0;)n=n.next[r];if(n.next[r]&&0===a){do{n.next[r].v=t}while(--r>=0);return this}i[r--]=n}const h=this.pickHeight(s.maxh,s.h,s.p);for(n=new X(e,t,h);s.h<h;)i[++s.h]=s.head;for(let e=0;e<=h;e++)n.next[e]=i[e].next[e],i[e].next[e]=n;return s.length++,s.length>=s.cap&&(s.cap*=2,s.maxh++),this}delete(e){const t=Y.get(this);let s=t.head,n=t.h,r=!1;const i=t.cmp;let o;for(;n>=0;){for(;s.next[n]&&(o=i(s.next[n].k,e))<0;)s=s.next[n];s.next[n]&&0===o&&(r=!0,s.next[n]=s.next[n].next[n],s!=t.head||s.next[n]||(t.h=Math.max(0,t.h-1))),n--}return r&&t.length--,r}into(e){return S(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=Y.get(this).head;for(;(s=s.next[0])&&!i.isReduced(t);)t=e(t,[s.k,s.v]);return t}opts(){const e=Y.get(this);return{capacity:e.cap,compare:e.cmp,probability:e.p}}findPredNode(e){const t=Y.get(this),s=t.cmp;let n=t.head,r=t.h;for(;r>=0;){for(;n.next[r]&&s(n.next[r].k,e)<0;)n=n.next[r];r--}return n}pickHeight(e,t,s){const n=Math.min(e,t+1);let r=0;for(;Math.random()<s&&r<n;)r++;return r}},e.SortedMap.DEFAULT_CAP=8,e.SortedMap.DEFAULT_P=1/Math.E,e.SortedMap=V=t.__decorate([y],e.SortedMap);const ee=new WeakMap;e.SortedSet=Z=class extends Set{constructor(t,s){super(),ee.set(this,new e.SortedMap(t?i.map((e=>[e,e]),t):null,s))}[Symbol.iterator](){return this.keys()}get[Symbol.species](){return Z}get[Symbol.toStringTag](){return"SortedSet"}get size(){return ee.get(this).size}copy(){return new Z(this.keys(),this.opts())}empty(){return new Z(null,Object.assign(Object.assign({},this.opts()),{capacity:e.SortedMap.DEFAULT_CAP}))}compare(e){const t=this.size,s=e.size;if(t<s)return-1;if(t>s)return 1;const n=this.entries(),r=e.entries();let i,o,a;for(;i=n.next(),o=r.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 ee.get(this).$reduce(((t,s)=>e(t,s[0])),t)}entries(e,t=!1){return ee.get(this).entries(e,t)}keys(e,t=!1){return ee.get(this).keys(e,t)}values(e,t=!1){return ee.get(this).values(e,t)}add(e){return ee.get(this).set(e,e),this}into(e){return S(this,e)}clear(){ee.get(this).clear()}first(){const e=ee.get(this).first();return e?e[0]:void 0}delete(e){return ee.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 ee.get(this).has(e)}get(e,t){return ee.get(this).get(e,t)}opts(){return ee.get(this).opts()}},e.SortedSet=Z=t.__decorate([y],e.SortedSet);const te=new WeakMap,se=()=>u.illegalArgs("dense & sparse arrays must be of same size");e.ASparseSet=class extends Set{constructor(e,t){super(),te.set(this,{dense:e,sparse:t,n:0})}[Symbol.iterator](){return this.keys()}get size(){return te.get(this).n}get capacity(){return te.get(this).dense.length}clear(){te.get(this).n=0}equiv(e){if(this===e)return!0;if(!(e instanceof Set)||this.size!==e.size)return!1;const t=te.get(this),s=t.dense;for(let n=t.n;--n>=0;)if(!e.has(s[n]))return!1;return!0}add(e){const t=te.get(this),s=t.dense,n=t.sparse,r=s.length,i=n[e],o=t.n;return e<r&&o<r&&!(i<o&&s[i]===e)&&(s[o]=e,n[e]=o,t.n++),this}delete(e){const t=te.get(this),s=t.dense,n=t.sparse,r=n[e];if(r<t.n&&s[r]===e){const e=s[--t.n];return s[r]=e,n[e]=r,!0}return!1}has(e){const t=te.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=te.get(this);return e.n?e.dense[0]:void 0}into(e){return S(this,e)}disj(e){return l(this,e)}forEach(e,t){const s=te.get(this),n=s.dense,r=s.n;for(let s=0;s<r;s++){const r=n[s];e.call(t,r,r,this)}}*entries(){const e=te.get(this),t=e.dense,s=e.n;for(let e=0;e<s;e++)yield[t[e],t[e]]}*keys(){const e=te.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=te.get(this),s=te.get(e);return s.dense=t.dense.slice(),s.sparse=t.sparse.slice(),s.n=t.n,e}},e.ASparseSet=t.__decorate([y],e.ASparseSet);class ne extends e.ASparseSet{constructor(e,t){r.isNumber(e)?super(new Uint8Array(e),new Uint8Array(e)):e.length===t.length?super(e,t):se()}get[Symbol.species](){return ne}get[Symbol.toStringTag](){return"SparseSet8"}copy(){return this.__copyTo(new ne(0))}empty(){return new ne(this.capacity)}}class re extends e.ASparseSet{constructor(e,t){r.isNumber(e)?super(new Uint16Array(e),new Uint16Array(e)):e.length===t.length?super(e,t):se()}get[Symbol.species](){return re}get[Symbol.toStringTag](){return"SparseSet16"}copy(){return this.__copyTo(new re(0))}empty(){return new re(this.capacity)}}class ie extends e.ASparseSet{constructor(e,t){r.isNumber(e)?super(new Uint32Array(e),new Uint32Array(e)):e.length===t.length?super(e,t):se()}get[Symbol.species](){return ie}get[Symbol.toStringTag](){return"SparseSet32"}copy(){return this.__copyTo(new ie(0))}empty(){return new ie(this.capacity)}}class oe{constructor(e){this.next={},this.n=0,e&&this.into(e)}*[Symbol.iterator](){const e=[["",this]];for(;e.length;){const[t,s]=e.pop();void 0!==s.val?yield[t,s.val]:s.queueChildren(e,t)}}*keys(e=""){const t=[[e,this]];for(;t.length;){const[e,s]=t.pop();void 0!==s.val?yield e:s.queueChildren(t,e)}}*values(){const e=[this];for(;e.length;){const t=e.pop();void 0!==t.val?yield t.val:e.push(...i.vals(t.next))}}*suffixes(e,t=!1){const s=this.find(e);s&&(yield*s.keys(t?e:""))}clear(){this.next={},this.n=0,this.val=void 0}has(e){return void 0!==this.get(e)}hasPrefix(e){return!!this.find(e)}get(e,t){const s=this.find(e);return s?s.val:t}find(e){let t=this;for(let s=0,n=e.length;s<n;s++)if(t=t.next[e[s]],!t)return;return t}knownPrefix(e){let t=this,s="";for(let n=0,r=e.length;n<r;n++){const r=e[n],i=t.next[r];if(!i)break;s+=r,t=i}return s||void 0}hasKnownPrefix(e){return!!this.knownPrefix(e)}set(e,t){let s=this;for(let t=0,n=e.length;t<n;t++){const n=e[t],r=s.next[n];s=r||(s.n++,s.next[n]=new oe)}s.val=t}into(e){for(let[t,s]of e)this.set(t,s)}delete(e){const t=e.length;if(t<1)return!1;const s=[],n=[];let r=0,i=this;for(;r<t;r++){const t=e[r];if(n.push(t),s.push(i),i=i.next[t],!i)return!1}for(;(i=s[--r])&&(delete i.next[n[r]],!--i.n););return!0}queueChildren(e,t){e.push(...Object.keys(this.next).map((e=>[t+e,this.next[e]])))}}const ae=(e,t,s)=>{if(e.size<t.size){const s=e;e=t,t=s}return s=s?S(s,e):k(e,Set),e===t?s:S(s,t)};e.MultiTrie=Q,e.SparseSet16=re,e.SparseSet32=ie,e.SparseSet8=ne,e.TrieMap=oe,e.commonKeysMap=(e,t,s=[])=>{for(let n of e.keys())t.has(n)&&s.push(n);return s},e.commonKeysObj=w,e.defArraySet=(t,s)=>new e.ArraySet(t,s),e.defEquivMap=function(t,s){return new e.EquivMap(r.isPlainObject(t)?i.pairs(t):t,s)},e.defHashMap=function(t,s){if(r.isPlainObject(t)){const n=Object.keys(t);return new e.HashMap(i.map((e=>[e,t[e]]),n),Object.assign({cap:n.length/(s.load||.75)},s))}return new e.HashMap(t,s)},e.defLLSet=(t,s)=>new e.LLSet(t,s),e.defMultiTrie=(e,t)=>new Q(e,t),e.defSortedMap=function(t,s){if(r.isPlainObject(t)){const n=Object.keys(t);return new e.SortedMap(i.map((e=>[e,t[e]]),n),Object.assign({capacity:n.length},s))}return new e.SortedMap(t,s)},e.defSortedSet=(t,s)=>new e.SortedSet(t,s),e.defSparseSet=e=>e<=256?new ne(e):e<=65536?new re(e):new ie(e),e.defTrieMap=e=>new oe(e),e.difference=j,e.differenceR=function e(t){return O(e,j,t)},e.dissoc=l,e.dissocObj=(e,t)=>{for(let s of t)delete e[s];return e},e.indexed=L,e.intersection=R,e.intersectionR=function e(t){return O(e,R,t)},e.into=S,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 n,r;e.size<=t.size?(n=e,r=t):(n=t,r=e);const i=L(n,s),o=x(e,Set);for(let e of r){const t=i.get(H(e,s));if(t)for(let s of t)o.add(C(Object.assign({},s),e))}return o}return x(e,Set)},e.joinWith=F,e.meldApplyObj=N,e.meldDeepObj=J,e.meldObjWith=G,e.mergeApplyMap=(e,t)=>{const s=k(e,Map);for(let[e,n]of t)s.set(e,r.isFunction(n)?n(s.get(e)):n);return s},e.mergeApplyObj=(e,t)=>N(Object.assign({},e),t),e.mergeDeepObj=I,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 n=k(t,Map);for(let t of s)if(null!=t)for(let[s,r]of t)n.set(s,n.has(s)?e(n.get(s),r):r);return n},e.mergeObj=C,e.mergeObjWith=B,e.renameKeysMap=(e,t,s)=>{s=s||x(e,Map);for(let[n,r]of e)s.set(t.has(n)?t.get(n):n,r);return s},e.renameKeysObj=W,e.selectKeysMap=(e,t)=>{const s=x(e,Map);for(let n of t)e.has(n)&&s.set(n,e.get(n));return s},e.selectKeysObj=H,e.union=ae,e.unionR=function e(t){return O(e,ae,t)},e.withoutKeysMap=(e,t)=>{const s=q(t),n=x(e,Map);for(let t of e.entries()){const e=t[0];!s.has(e)&&n.set(e,t[1])}return n},e.withoutKeysObj=(e,t)=>{const s=q(t),n={};for(let t in e)e.hasOwnProperty(t)&&!s.has(t)&&(n[t]=e[t]);return n},Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@thi.ng/associative", | ||
"version": "5.0.8", | ||
"version": "5.0.9", | ||
"description": "Alternative Map and Set implementations with customizable equality semantics & supporting operations", | ||
@@ -42,21 +42,21 @@ "module": "./index.js", | ||
"@istanbuljs/nyc-config-typescript": "^1.0.1", | ||
"@microsoft/api-extractor": "^7.9.11", | ||
"@microsoft/api-extractor": "^7.12.0", | ||
"@types/mocha": "^8.0.3", | ||
"@types/node": "^14.6.1", | ||
"mocha": "^8.1.2", | ||
"mocha": "^8.2.1", | ||
"nyc": "^15.1.0", | ||
"ts-node": "^9.0.0", | ||
"typedoc": "^0.18.0", | ||
"typescript": "^4.0.2" | ||
"typedoc": "^0.19.2", | ||
"typescript": "^4.1.2" | ||
}, | ||
"dependencies": { | ||
"@thi.ng/api": "^6.13.1", | ||
"@thi.ng/binary": "^2.0.16", | ||
"@thi.ng/checks": "^2.7.9", | ||
"@thi.ng/compare": "^1.3.17", | ||
"@thi.ng/dcons": "^2.3.0", | ||
"@thi.ng/equiv": "^1.0.32", | ||
"@thi.ng/errors": "^1.2.22", | ||
"@thi.ng/transducers": "^7.4.0", | ||
"tslib": "^2.0.1" | ||
"@thi.ng/api": "^6.13.2", | ||
"@thi.ng/binary": "^2.0.17", | ||
"@thi.ng/checks": "^2.7.10", | ||
"@thi.ng/compare": "^1.3.18", | ||
"@thi.ng/dcons": "^2.3.1", | ||
"@thi.ng/equiv": "^1.0.33", | ||
"@thi.ng/errors": "^1.2.23", | ||
"@thi.ng/transducers": "^7.5.0", | ||
"tslib": "^2.0.3" | ||
}, | ||
@@ -70,5 +70,6 @@ "files": [ | ||
"keywords": [ | ||
"cache", | ||
"datastructure", | ||
"equality", | ||
"hashmap", | ||
"hash", | ||
"intersection", | ||
@@ -96,3 +97,3 @@ "join", | ||
}, | ||
"gitHead": "fddd3584c295648598109dab9b52b1f6bd6a1a18" | ||
"gitHead": "3a89bdfa4c58983d5e005b3e9fb056b0351198fe" | ||
} |
@@ -179,3 +179,3 @@ <!-- This file is generated - DO NOT EDIT! --> | ||
Package sizes (gzipped, pre-treeshake): ESM: 6.23 KB / CJS: 6.42 KB / UMD: 6.20 KB | ||
Package sizes (gzipped, pre-treeshake): ESM: 6.24 KB / CJS: 6.43 KB / UMD: 6.21 KB | ||
@@ -182,0 +182,0 @@ ## Dependencies |
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
335208
70
Updated@thi.ng/api@^6.13.2
Updated@thi.ng/binary@^2.0.17
Updated@thi.ng/checks@^2.7.10
Updated@thi.ng/compare@^1.3.18
Updated@thi.ng/dcons@^2.3.1
Updated@thi.ng/equiv@^1.0.33
Updated@thi.ng/errors@^1.2.23
Updated@thi.ng/transducers@^7.5.0
Updatedtslib@^2.0.3