flat-pair 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ For more awesome packages, check out [my homepage💛](https://baendlorel.github
|
|
|
14
14
|
- 🛡️ **Type Safe**: Full TypeScript support with generic types
|
|
15
15
|
- 🎯 **Zero Cost**: Static methods available for minimal overhead
|
|
16
16
|
- ⚡ **Lightweight**: No dependencies, minimal bundle size
|
|
17
|
-
- 🌲 **Native Behavior**: `forEach`, `find` acts like they are in `Array`. Equality check uses `
|
|
17
|
+
- 🌲 **Native Behavior**: `forEach`, `find` acts like they are in `Array`. Equality check uses `SameValueZero`
|
|
18
18
|
|
|
19
19
|
## Installation / Import
|
|
20
20
|
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const e=function(e,r){return e===r||e!=e&&r!=r};function r(e){const r=e.length;if(r%2!=0)throw new TypeError("[FlatPair: size] items length must be even number");return r/2}function t(r,t,n){const i=r.length;if(i%2!=0)throw new TypeError("[FlatPair: add] items length must be even number");for(let n=0;n<i;n+=2)if(e(r[n],t))return;r.push(t,n)}function n(r,t){const n=r.length;if(n%2!=0)throw new TypeError("[FlatPair: has] items length must be even number");for(let i=0;i<n;i+=2)if(e(r[i],t))return!0;return!1}function i(r,t){const n=r.length;if(n%2!=0)throw new TypeError("[FlatPair: hasByValue] items length must be even number");for(let i=1;i<n;i+=2)if(e(r[i],t))return!0;return!1}function u(r,t){const n=r.length;if(n%2!=0)throw new TypeError("[FlatPair: get] items length must be even number");for(let i=0;i<n;i+=2)if(e(r[i],t))return r[i+1]}function o(r,t){const n=r.length;if(n%2!=0)throw new TypeError("[FlatPair: getByValue] items length must be even number");for(let i=1;i<n;i+=2)if(e(r[i],t))return r[i-1]}function s(r,t){const n=r.length;if(n%2!=0)throw new TypeError("[FlatPair: remove] items length must be even number");for(let i=0;i<n;i+=2)if(e(r[i],t))return r.splice(i,2),!0;return!1}function l(r,t){const n=r.length;if(n%2!=0)throw new TypeError("[FlatPair: removeByValue] items length must be even number");for(let i=1;i<n;i+=2)if(e(r[i],t))return r.splice(i-1,2),!0;return!1}function f(e,r,t){const n=e.length;if(n%2!=0)throw new TypeError("[FlatPair: forEach] items length must be even number");for(let i=0;i<n;i+=2)i in e&&r.call(t,e[i+1],e[i],i,e)}function a(e){e.length=0}function h(e,r){const t=e.length;if(t%2!=0)throw new TypeError("[FlatPair: find] items length must be even number");for(let n=0;n<t;n+=2){if(r(e[n+1],e[n],n,e))return[e[n],e[n+1]]}}function m(e,r){const t=e.length;if(t%2!=0)throw new TypeError("[FlatPair: findIndex] items length must be even number");for(let n=0;n<t;n+=2){if(r(e[n+1],e[n],n,e))return n}return-1}class c{static from(e){if("[object Map]"!==Object.prototype.toString.call(e))throw new TypeError("[FlatPair: from] Argument must be a Map");const r=[];return e.forEach((e,t)=>r.push(t,e)),new c(r)}t=[];constructor(e){if(e.length%2!=0)throw new TypeError("[FlatPair: constructor] items length must be even number");this.t=e.slice()}get size(){return this.t.length/2}get array(){return this.t}add(e,r){return t(this.t,e,r),this}hasByValue(e){return i(this.t,e)}remove(e){return s(this.t,e)}removeByValue(e){return l(this.t,e)}get(e){return u(this.t,e)}getByValue(e){return o(this.t,e)}find(e){return h(this.t,e)}findIndex(e){return m(this.t,e)}clear(){this.t.length=0}has(e){return n(this.t,e)}forEach(e,r){f(this.t,e,r)}*keys(){for(let e=0;e<this.t.length;e+=2)yield this.t[e]}*values(){for(let e=1;e<this.t.length;e+=2)yield this.t[e]}*entries(){for(let e=0;e<this.t.length;e+=2)yield[this.t[e],this.t[e+1]]}[Symbol.iterator](){return this.entries()}}class y{add(e,r,n){t(e,r,n)}remove(e,r){return s(e,r)}get(e,r){return u(e,r)}getByValue(e,r){return o(e,r)}find(e,r){return h(e,r)}findIndex(e,r){return m(e,r)}removeByValue(e,r){return l(e,r)}forEach(e,r,t){f(e,r,t)}*keys(e){for(let r=0;r<e.length;r+=2)yield e[r]}*values(e){for(let r=1;r<e.length;r+=2)yield e[r]}*entries(e){for(let r=0;r<e.length;r+=2)yield[e[r],e[r+1]]}clear(e){e.length=0}has(e,r){return n(e,r)}hasByValue(e,r){return i(e,r)}}export{c as FlatPair,y as FlatPairOperator,t as add,a as clear,h as find,m as findIndex,f as forEach,u as get,o as getByValue,n as has,i as hasByValue,s as remove,l as removeByValue,r as size};
|