fast-boolean-array 1.5.0 → 1.7.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +51 -51
- package/pnpm-lock.yaml +1734 -0
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var h=(n,e)=>{for(var r in e)a(n,r,{get:e[r],enumerable:!0})},b=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of l(e))!f.call(n,s)&&s!==r&&a(n,s,{get:()=>e[s],enumerable:!(t=u(e,s))||t.enumerable});return n};var y=n=>b(a({},"__esModule",{value:!0}),n);var g={};h(g,{default:()=>i});module.exports=y(g);var o="Index out of bounds",i=class n{size;buffer;constructor(e){if(!e)throw new Error("FastBooleanArray must have a size greater than 0");this.size=e,this.buffer=new Uint8Array(Math.ceil(e/8))}set(e,r){return r?(this.buffer[e>>3]|=1<<(e&7),!0):(this.buffer[e>>3]&=~(1<<(e&7)),!1)}setSafe(e,r){if(e<0||e>=this.size)throw new RangeError(o);return this.set(e,r)}setAll(e){this.buffer.fill(e?255:0)}get(e){
|
|
1
|
+
var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var h=(n,e)=>{for(var r in e)a(n,r,{get:e[r],enumerable:!0})},b=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of l(e))!f.call(n,s)&&s!==r&&a(n,s,{get:()=>e[s],enumerable:!(t=u(e,s))||t.enumerable});return n};var y=n=>b(a({},"__esModule",{value:!0}),n);var g={};h(g,{default:()=>i});module.exports=y(g);var o="Index out of bounds",i=class n{size;buffer;constructor(e){if(!e)throw new Error("FastBooleanArray must have a size greater than 0");this.size=e,this.buffer=new Uint8Array(Math.ceil(e/8))}set(e,r){return r?(this.buffer[e>>3]|=1<<(e&7),!0):(this.buffer[e>>3]&=~(1<<(e&7)),!1)}setSafe(e,r){if(e<0||e>=this.size)throw new RangeError(o);return this.set(e,r)}setAll(e){this.buffer.fill(e?255:0)}get(e){return!!(this.buffer[e>>3]>>(e&7)&1)}getSafe(e){if(e<0||e>=this.size)throw new RangeError(o);return this.get(e)}resize(e){let r=new Uint8Array(Math.ceil(e/8));r.set(this.buffer.subarray(0,Math.min(this.buffer.length,r.length))),this.size=e,this.buffer=r}get length(){return this.size}equals(e){return this.size!==e.size?!1:this.buffer.every((r,t)=>r===e.buffer[t])}*[Symbol.iterator](){for(let e=0;e<this.size;e++)yield this.get(e)}toArray(){let e=new Array(this.size);for(let r=0;r<this.size;r++)e[r]=this.get(r);return e}accessLikeArray(){return new Proxy(this,{get:(e,r)=>{if(typeof r=="string"&&!isNaN(Number(r))){let t=Number(r);return e.get(t)}return e[r]},set:(e,r,t)=>{if(typeof r=="string"&&!isNaN(Number(r))){let s=Number(r);e.set(s,t)}else e[r]=t;return!0}})}forEach(e){for(let r=0;r<this.size;r++)e(this.get(r),r,this)}map(e){let r=new Array(this.size);for(let t=0;t<this.size;t++)r[t]=e(this.get(t),t,this);return r}filter(e){let r=[];for(let t=0;t<this.size;t++){let s=this.get(t);e(s,t,this)&&r.push(s)}return r}some(e){for(let r=0;r<this.size;r++)if(e(this.get(r),r,this))return!0;return!1}every(e){for(let r=0;r<this.size;r++)if(!e(this.get(r),r,this))return!1;return!0}reduce(e,r){let t=r;for(let s=0;s<this.size;s++)t=e(t,this.get(s),s,this);return t}toString(){let e="";for(let r=0;r<this.size;r++)e+=this.get(r)?"1":"0";return e}static fromString(e){let r=new n(e.length);for(let t=0;t<e.length;t++)r.set(t,e[t]=="1");return r}static fromArray(e){let r=new n(e.length);for(let t=0;t<e.length;t++)r.set(t,!!e[t]);return r}static from(e){return typeof e=="string"?n.fromString(e):n.fromArray(e)}};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["const ERROR_OUT_OF_BOUNDS = \"Index out of bounds\";\r\n\r\nexport default class FastBooleanArray {\r\n public size: number;\r\n private buffer: Uint8Array;\r\n\r\n constructor(size: number) {\r\n if (!size) {\r\n throw new Error(\"FastBooleanArray must have a size greater than 0\");\r\n }\r\n this.size = size;\r\n this.buffer = new Uint8Array(Math.ceil(size / 8)); // Allocate memory\r\n }\r\n\r\n /**\r\n * Sets a boolean value at the specified index.\r\n * @param {number} index - The index to set the boolean value at.\r\n * @param {number} value - The boolean value to set the `index`.\r\n * @returns {boolean} The boolean value that was set.\r\n */\r\n set(index: number, value: boolean) {\r\n if (value) {\r\n this.buffer[index >> 3] |= 1 << (index & 7); // Set bit\r\n return true;\r\n } else {\r\n this.buffer[index >> 3] &= ~(1 << (index & 7)); // Clear bit\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * like `set` but throws if the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n * @param {number} index - The index to set the boolean value at.\r\n * @param {number} value - The boolean value to set the `index`.\r\n * @returns {boolean} The boolean value that was set.\r\n * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n */\r\n setSafe(index: number, value: boolean) {\r\n if (index < 0 || index >= this.size) {\r\n throw new RangeError(ERROR_OUT_OF_BOUNDS);\r\n }\r\n return this.set(index, value);\r\n }\r\n\r\n /**\r\n * Sets all bits to the specified boolean value.\r\n * @param {boolean} value - The boolean value to set all bits to.\r\n */\r\n setAll(value: boolean) {\r\n this.buffer.fill(value ? 0xff : 0x00);\r\n }\r\n\r\n /**\r\n * Gets a boolean value at the specified index.\r\n * @param {number} index - The index to get the boolean value of.\r\n * @returns {boolean} The boolean value that was set.\r\n * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n */\r\n get(index: number) {\r\n const byteIndex = index >>> 3; // index divided by 8 (shifted)\r\n const bitIndex = index & 7; // index modulo 8 (masking)\r\n return (this.buffer[byteIndex] & (1 << bitIndex)) !== 0; // Direct comparison is faster than double negation !!\r\n }\r\n\r\n /**\r\n * like `get` but throws if the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n * @param {number} index - The index to get the boolean value of.\r\n * @returns {boolean} The boolean value that was set.\r\n * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n */\r\n getSafe(index: number) {\r\n if (index < 0 || index >= this.size) {\r\n throw new RangeError(ERROR_OUT_OF_BOUNDS);\r\n }\r\n return this.get(index);\r\n }\r\n\r\n /**\r\n * Resizes the array to a new size, preserving existing data.\r\n * @param {number} newSize - The new size of the array.\r\n */\r\n resize(newSize: number) {\r\n const newBuffer = new Uint8Array(Math.ceil(newSize / 8));\r\n newBuffer.set(\r\n this.buffer.subarray(0, Math.min(this.buffer.length, newBuffer.length))\r\n );\r\n this.size = newSize;\r\n this.buffer = newBuffer;\r\n }\r\n\r\n get length() {\r\n return this.size;\r\n }\r\n\r\n /**\r\n * Compares this FastBooleanArray with another for equality.\r\n * @param {FastBooleanArray} other - The other FastBooleanArray to compare.\r\n * @returns {boolean} True if both arrays are equal, false otherwise.\r\n */\r\n equals(other: FastBooleanArray) {\r\n if (this.size !== other.size) {\r\n return false;\r\n }\r\n return this.buffer.every((byte, i) => byte === other.buffer[i]);\r\n }\r\n\r\n /**\r\n * Makes the array iterable using `for...of`.\r\n */\r\n *[Symbol.iterator]() {\r\n for (let i = 0; i < this.size; i++) {\r\n yield this.get(i);\r\n }\r\n }\r\n\r\n /**\r\n * Converts to a standard JavaScript array.\r\n */\r\n toArray() {\r\n const arr = new Array(this.size);\r\n for (let i = 0; i < this.size; i++) {\r\n arr[i] = this.get(i);\r\n }\r\n return arr;\r\n }\r\n\r\n /**\r\n * Returns a proxy to the FastBooleanArray instance\r\n * With this you can access indexes like on an actual array.\r\n */\r\n accessLikeArray() {\r\n return new Proxy(this, {\r\n get: (target, prop) => {\r\n if (typeof prop === \"string\" && !isNaN(Number(prop))) {\r\n const index = Number(prop);\r\n return target.get(index);\r\n }\r\n return target[prop as keyof FastBooleanArray];\r\n },\r\n set: (target, prop, value) => {\r\n if (typeof prop === \"string\" && !isNaN(Number(prop))) {\r\n const index = Number(prop);\r\n target.set(index, value as never);\r\n } else {\r\n target[prop as Exclude<keyof FastBooleanArray, \"length\">] = value;\r\n }\r\n\r\n return true;\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Applies a callback function to each element in the array.\r\n * @param {Function} callback - The function to execute on each element.\r\n */\r\n forEach(\r\n callback: (value: boolean, index: number, array: FastBooleanArray) => void\r\n ) {\r\n for (let i = 0; i < this.size; i++) {\r\n callback(this.get(i), i, this);\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new array with the results of calling a provided function on every element.\r\n * @param {Function} callback - The function to execute on each element.\r\n */\r\n map(\r\n callback: (value: boolean, index: number, array: FastBooleanArray) => never\r\n ) {\r\n const result = new Array(this.size);\r\n for (let i = 0; i < this.size; i++) {\r\n result[i] = callback(this.get(i), i, this);\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a new array with all elements that pass the test implemented by the provided function.\r\n * @param {Function} callback - The function to test each element.\r\n */\r\n filter(\r\n callback: (\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => boolean\r\n ) {\r\n const result: boolean[] = [];\r\n for (let i = 0; i < this.size; i++) {\r\n const value = this.get(i);\r\n if (callback(value, i, this)) {\r\n result.push(value);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Tests whether at least one element in the array passes the test implemented by the provided function.\r\n * @param {Function} callback - The function to test each element.\r\n */\r\n some(\r\n callback: (\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => boolean\r\n ) {\r\n for (let i = 0; i < this.size; i++) {\r\n if (callback(this.get(i), i, this)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Tests whether all elements in the array pass the test implemented by the provided function.\r\n * @param {Function} callback - The function to test each element.\r\n */\r\n every(\r\n callback: (\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => boolean\r\n ) {\r\n for (let i = 0; i < this.size; i++) {\r\n if (!callback(this.get(i), i, this)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Reduces the array to a single value by applying a function to each element.\r\n * @param {Function} callback - The function to execute on each element.\r\n * @param {any} initialValue - The initial value for the accumulator.\r\n */\r\n reduce<T>(\r\n callback: (\r\n accumulator: T,\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => T,\r\n initialValue: T\r\n ): T {\r\n let accumulator = initialValue;\r\n for (let i = 0; i < this.size; i++) {\r\n accumulator = callback(accumulator, this.get(i), i, this);\r\n }\r\n return accumulator;\r\n }\r\n\r\n /**\r\n * Generates a string where every boolean is either a 0 or 1.\r\n */\r\n toString() {\r\n let result = ``;\r\n for (let i = 0; i < this.size; i++) {\r\n result += this.get(i) ? \"1\" : \"0\";\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns a FastBooleanArray from .toString() output\r\n */\r\n static fromString(value: string) {\r\n const array = new FastBooleanArray(value.length);\r\n for (let i = 0; i < value.length; i++) {\r\n array.set(i, value[i] == \"1\");\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Returns a FastBooleanArray from a boolean array or number array\r\n */\r\n static fromArray(value: boolean[] | number[]) {\r\n const array = new FastBooleanArray(value.length);\r\n for (let i = 0; i < value.length; i++) {\r\n array.set(i, !!value[i]);\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Returns a FastBooleanArray from a string, boolean array or number array\r\n */\r\n static from(value: string | boolean[] | number[]) {\r\n if (typeof value === \"string\") {\r\n return FastBooleanArray.fromString(value);\r\n }\r\n\r\n return FastBooleanArray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AO,KAAKf,EAAsC,CAChD,OAAI,OAAOA,GAAU,SACZH,EAAiB,WAAWG,CAAK,EAGnCH,EAAiB,UAAUG,CAAK,CACzC,CACF","names":["index_exports","__export","FastBooleanArray","__toCommonJS","ERROR_OUT_OF_BOUNDS","_FastBooleanArray","size","index","value","byteIndex","bitIndex","newSize","newBuffer","other","byte","i","arr","target","prop","callback","result","initialValue","accumulator","array"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["const ERROR_OUT_OF_BOUNDS = \"Index out of bounds\";\r\n\r\nexport default class FastBooleanArray {\r\n public size: number;\r\n private buffer: Uint8Array;\r\n\r\n constructor(size: number) {\r\n if (!size) {\r\n throw new Error(\"FastBooleanArray must have a size greater than 0\");\r\n }\r\n this.size = size;\r\n this.buffer = new Uint8Array(Math.ceil(size / 8)); // Allocate memory\r\n }\r\n\r\n /**\r\n * Sets a boolean value at the specified index.\r\n * @param {number} index - The index to set the boolean value at.\r\n * @param {number} value - The boolean value to set the `index`.\r\n * @returns {boolean} The boolean value that was set.\r\n */\r\n set(index: number, value: boolean) {\r\n if (value) {\r\n this.buffer[index >> 3] |= 1 << (index & 7); // Set bit\r\n return true;\r\n } else {\r\n this.buffer[index >> 3] &= ~(1 << (index & 7)); // Clear bit\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * like `set` but throws if the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n * @param {number} index - The index to set the boolean value at.\r\n * @param {number} value - The boolean value to set the `index`.\r\n * @returns {boolean} The boolean value that was set.\r\n * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n */\r\n setSafe(index: number, value: boolean) {\r\n if (index < 0 || index >= this.size) {\r\n throw new RangeError(ERROR_OUT_OF_BOUNDS);\r\n }\r\n return this.set(index, value);\r\n }\r\n\r\n /**\r\n * Sets all bits to the specified boolean value.\r\n * @param {boolean} value - The boolean value to set all bits to.\r\n */\r\n setAll(value: boolean) {\r\n this.buffer.fill(value ? 0xff : 0x00);\r\n }\r\n\r\n /**\r\n * Gets a boolean value at the specified index.\r\n * @param {number} index - The index to get the boolean value of.\r\n * @returns {boolean} The boolean value that was set.\r\n * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n */\r\n get(index: number) {\r\n return (this.buffer[index >> 3] >> (index & 7)) & 1 ? true : false;\r\n }\r\n\r\n /**\r\n * like `get` but throws if the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n * @param {number} index - The index to get the boolean value of.\r\n * @returns {boolean} The boolean value that was set.\r\n * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n */\r\n getSafe(index: number) {\r\n if (index < 0 || index >= this.size) {\r\n throw new RangeError(ERROR_OUT_OF_BOUNDS);\r\n }\r\n return this.get(index);\r\n }\r\n\r\n /**\r\n * Resizes the array to a new size, preserving existing data.\r\n * @param {number} newSize - The new size of the array.\r\n */\r\n resize(newSize: number) {\r\n const newBuffer = new Uint8Array(Math.ceil(newSize / 8));\r\n newBuffer.set(\r\n this.buffer.subarray(0, Math.min(this.buffer.length, newBuffer.length))\r\n );\r\n this.size = newSize;\r\n this.buffer = newBuffer;\r\n }\r\n\r\n get length() {\r\n return this.size;\r\n }\r\n\r\n /**\r\n * Compares this FastBooleanArray with another for equality.\r\n * @param {FastBooleanArray} other - The other FastBooleanArray to compare.\r\n * @returns {boolean} True if both arrays are equal, false otherwise.\r\n */\r\n equals(other: FastBooleanArray) {\r\n if (this.size !== other.size) {\r\n return false;\r\n }\r\n return this.buffer.every((byte, i) => byte === other.buffer[i]);\r\n }\r\n\r\n /**\r\n * Makes the array iterable using `for...of`.\r\n */\r\n *[Symbol.iterator]() {\r\n for (let i = 0; i < this.size; i++) {\r\n yield this.get(i);\r\n }\r\n }\r\n\r\n /**\r\n * Converts to a standard JavaScript array.\r\n */\r\n toArray() {\r\n const arr = new Array(this.size);\r\n for (let i = 0; i < this.size; i++) {\r\n arr[i] = this.get(i);\r\n }\r\n return arr;\r\n }\r\n\r\n /**\r\n * Returns a proxy to the FastBooleanArray instance\r\n * With this you can access indexes like on an actual array.\r\n */\r\n accessLikeArray() {\r\n return new Proxy(this, {\r\n get: (target, prop) => {\r\n if (typeof prop === \"string\" && !isNaN(Number(prop))) {\r\n const index = Number(prop);\r\n return target.get(index);\r\n }\r\n return target[prop as keyof FastBooleanArray];\r\n },\r\n set: (target, prop, value) => {\r\n if (typeof prop === \"string\" && !isNaN(Number(prop))) {\r\n const index = Number(prop);\r\n target.set(index, value as never);\r\n } else {\r\n target[prop as Exclude<keyof FastBooleanArray, \"length\">] = value;\r\n }\r\n\r\n return true;\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Applies a callback function to each element in the array.\r\n * @param {Function} callback - The function to execute on each element.\r\n */\r\n forEach(\r\n callback: (value: boolean, index: number, array: FastBooleanArray) => void\r\n ) {\r\n for (let i = 0; i < this.size; i++) {\r\n callback(this.get(i), i, this);\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new array with the results of calling a provided function on every element.\r\n * @param {Function} callback - The function to execute on each element.\r\n */\r\n map(\r\n callback: (value: boolean, index: number, array: FastBooleanArray) => never\r\n ) {\r\n const result = new Array(this.size);\r\n for (let i = 0; i < this.size; i++) {\r\n result[i] = callback(this.get(i), i, this);\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a new array with all elements that pass the test implemented by the provided function.\r\n * @param {Function} callback - The function to test each element.\r\n */\r\n filter(\r\n callback: (\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => boolean\r\n ) {\r\n const result: boolean[] = [];\r\n for (let i = 0; i < this.size; i++) {\r\n const value = this.get(i);\r\n if (callback(value, i, this)) {\r\n result.push(value);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Tests whether at least one element in the array passes the test implemented by the provided function.\r\n * @param {Function} callback - The function to test each element.\r\n */\r\n some(\r\n callback: (\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => boolean\r\n ) {\r\n for (let i = 0; i < this.size; i++) {\r\n if (callback(this.get(i), i, this)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Tests whether all elements in the array pass the test implemented by the provided function.\r\n * @param {Function} callback - The function to test each element.\r\n */\r\n every(\r\n callback: (\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => boolean\r\n ) {\r\n for (let i = 0; i < this.size; i++) {\r\n if (!callback(this.get(i), i, this)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Reduces the array to a single value by applying a function to each element.\r\n * @param {Function} callback - The function to execute on each element.\r\n * @param {any} initialValue - The initial value for the accumulator.\r\n */\r\n reduce<T>(\r\n callback: (\r\n accumulator: T,\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => T,\r\n initialValue: T\r\n ): T {\r\n let accumulator = initialValue;\r\n for (let i = 0; i < this.size; i++) {\r\n accumulator = callback(accumulator, this.get(i), i, this);\r\n }\r\n return accumulator;\r\n }\r\n\r\n /**\r\n * Generates a string where every boolean is either a 0 or 1.\r\n */\r\n toString() {\r\n let result = ``;\r\n for (let i = 0; i < this.size; i++) {\r\n result += this.get(i) ? \"1\" : \"0\";\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns a FastBooleanArray from .toString() output\r\n */\r\n static fromString(value: string) {\r\n const array = new FastBooleanArray(value.length);\r\n for (let i = 0; i < value.length; i++) {\r\n array.set(i, value[i] == \"1\");\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Returns a FastBooleanArray from a boolean array or number array\r\n */\r\n static fromArray(value: boolean[] | number[]) {\r\n const array = new FastBooleanArray(value.length);\r\n for (let i = 0; i < value.length; i++) {\r\n array.set(i, !!value[i]);\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Returns a FastBooleanArray from a string, boolean array or number array\r\n */\r\n static from(value: string | boolean[] | number[]) {\r\n if (typeof value === \"string\") {\r\n return Fast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AAO,KAAKb,EAAsC,CAChD,OAAI,OAAOA,GAAU,SACZH,EAAiB,WAAWG,CAAK,EAGnCH,EAAiB,UAAUG,CAAK,CACzC,CACF","names":["index_exports","__export","FastBooleanArray","__toCommonJS","ERROR_OUT_OF_BOUNDS","_FastBooleanArray","size","index","value","newSize","newBuffer","other","byte","i","arr","target","prop","callback","result","initialValue","accumulator","array"]}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var a="Index out of bounds",i=class n{size;buffer;constructor(e){if(!e)throw new Error("FastBooleanArray must have a size greater than 0");this.size=e,this.buffer=new Uint8Array(Math.ceil(e/8))}set(e,r){return r?(this.buffer[e>>3]|=1<<(e&7),!0):(this.buffer[e>>3]&=~(1<<(e&7)),!1)}setSafe(e,r){if(e<0||e>=this.size)throw new RangeError(a);return this.set(e,r)}setAll(e){this.buffer.fill(e?255:0)}get(e){
|
|
1
|
+
var a="Index out of bounds",i=class n{size;buffer;constructor(e){if(!e)throw new Error("FastBooleanArray must have a size greater than 0");this.size=e,this.buffer=new Uint8Array(Math.ceil(e/8))}set(e,r){return r?(this.buffer[e>>3]|=1<<(e&7),!0):(this.buffer[e>>3]&=~(1<<(e&7)),!1)}setSafe(e,r){if(e<0||e>=this.size)throw new RangeError(a);return this.set(e,r)}setAll(e){this.buffer.fill(e?255:0)}get(e){return!!(this.buffer[e>>3]>>(e&7)&1)}getSafe(e){if(e<0||e>=this.size)throw new RangeError(a);return this.get(e)}resize(e){let r=new Uint8Array(Math.ceil(e/8));r.set(this.buffer.subarray(0,Math.min(this.buffer.length,r.length))),this.size=e,this.buffer=r}get length(){return this.size}equals(e){return this.size!==e.size?!1:this.buffer.every((r,t)=>r===e.buffer[t])}*[Symbol.iterator](){for(let e=0;e<this.size;e++)yield this.get(e)}toArray(){let e=new Array(this.size);for(let r=0;r<this.size;r++)e[r]=this.get(r);return e}accessLikeArray(){return new Proxy(this,{get:(e,r)=>{if(typeof r=="string"&&!isNaN(Number(r))){let t=Number(r);return e.get(t)}return e[r]},set:(e,r,t)=>{if(typeof r=="string"&&!isNaN(Number(r))){let s=Number(r);e.set(s,t)}else e[r]=t;return!0}})}forEach(e){for(let r=0;r<this.size;r++)e(this.get(r),r,this)}map(e){let r=new Array(this.size);for(let t=0;t<this.size;t++)r[t]=e(this.get(t),t,this);return r}filter(e){let r=[];for(let t=0;t<this.size;t++){let s=this.get(t);e(s,t,this)&&r.push(s)}return r}some(e){for(let r=0;r<this.size;r++)if(e(this.get(r),r,this))return!0;return!1}every(e){for(let r=0;r<this.size;r++)if(!e(this.get(r),r,this))return!1;return!0}reduce(e,r){let t=r;for(let s=0;s<this.size;s++)t=e(t,this.get(s),s,this);return t}toString(){let e="";for(let r=0;r<this.size;r++)e+=this.get(r)?"1":"0";return e}static fromString(e){let r=new n(e.length);for(let t=0;t<e.length;t++)r.set(t,e[t]=="1");return r}static fromArray(e){let r=new n(e.length);for(let t=0;t<e.length;t++)r.set(t,!!e[t]);return r}static from(e){return typeof e=="string"?n.fromString(e):n.fromArray(e)}};export{i as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["const ERROR_OUT_OF_BOUNDS = \"Index out of bounds\";\r\n\r\nexport default class FastBooleanArray {\r\n public size: number;\r\n private buffer: Uint8Array;\r\n\r\n constructor(size: number) {\r\n if (!size) {\r\n throw new Error(\"FastBooleanArray must have a size greater than 0\");\r\n }\r\n this.size = size;\r\n this.buffer = new Uint8Array(Math.ceil(size / 8)); // Allocate memory\r\n }\r\n\r\n /**\r\n * Sets a boolean value at the specified index.\r\n * @param {number} index - The index to set the boolean value at.\r\n * @param {number} value - The boolean value to set the `index`.\r\n * @returns {boolean} The boolean value that was set.\r\n */\r\n set(index: number, value: boolean) {\r\n if (value) {\r\n this.buffer[index >> 3] |= 1 << (index & 7); // Set bit\r\n return true;\r\n } else {\r\n this.buffer[index >> 3] &= ~(1 << (index & 7)); // Clear bit\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * like `set` but throws if the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n * @param {number} index - The index to set the boolean value at.\r\n * @param {number} value - The boolean value to set the `index`.\r\n * @returns {boolean} The boolean value that was set.\r\n * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n */\r\n setSafe(index: number, value: boolean) {\r\n if (index < 0 || index >= this.size) {\r\n throw new RangeError(ERROR_OUT_OF_BOUNDS);\r\n }\r\n return this.set(index, value);\r\n }\r\n\r\n /**\r\n * Sets all bits to the specified boolean value.\r\n * @param {boolean} value - The boolean value to set all bits to.\r\n */\r\n setAll(value: boolean) {\r\n this.buffer.fill(value ? 0xff : 0x00);\r\n }\r\n\r\n /**\r\n * Gets a boolean value at the specified index.\r\n * @param {number} index - The index to get the boolean value of.\r\n * @returns {boolean} The boolean value that was set.\r\n * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n */\r\n get(index: number) {\r\n const byteIndex = index >>> 3; // index divided by 8 (shifted)\r\n const bitIndex = index & 7; // index modulo 8 (masking)\r\n return (this.buffer[byteIndex] & (1 << bitIndex)) !== 0; // Direct comparison is faster than double negation !!\r\n }\r\n\r\n /**\r\n * like `get` but throws if the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n * @param {number} index - The index to get the boolean value of.\r\n * @returns {boolean} The boolean value that was set.\r\n * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n */\r\n getSafe(index: number) {\r\n if (index < 0 || index >= this.size) {\r\n throw new RangeError(ERROR_OUT_OF_BOUNDS);\r\n }\r\n return this.get(index);\r\n }\r\n\r\n /**\r\n * Resizes the array to a new size, preserving existing data.\r\n * @param {number} newSize - The new size of the array.\r\n */\r\n resize(newSize: number) {\r\n const newBuffer = new Uint8Array(Math.ceil(newSize / 8));\r\n newBuffer.set(\r\n this.buffer.subarray(0, Math.min(this.buffer.length, newBuffer.length))\r\n );\r\n this.size = newSize;\r\n this.buffer = newBuffer;\r\n }\r\n\r\n get length() {\r\n return this.size;\r\n }\r\n\r\n /**\r\n * Compares this FastBooleanArray with another for equality.\r\n * @param {FastBooleanArray} other - The other FastBooleanArray to compare.\r\n * @returns {boolean} True if both arrays are equal, false otherwise.\r\n */\r\n equals(other: FastBooleanArray) {\r\n if (this.size !== other.size) {\r\n return false;\r\n }\r\n return this.buffer.every((byte, i) => byte === other.buffer[i]);\r\n }\r\n\r\n /**\r\n * Makes the array iterable using `for...of`.\r\n */\r\n *[Symbol.iterator]() {\r\n for (let i = 0; i < this.size; i++) {\r\n yield this.get(i);\r\n }\r\n }\r\n\r\n /**\r\n * Converts to a standard JavaScript array.\r\n */\r\n toArray() {\r\n const arr = new Array(this.size);\r\n for (let i = 0; i < this.size; i++) {\r\n arr[i] = this.get(i);\r\n }\r\n return arr;\r\n }\r\n\r\n /**\r\n * Returns a proxy to the FastBooleanArray instance\r\n * With this you can access indexes like on an actual array.\r\n */\r\n accessLikeArray() {\r\n return new Proxy(this, {\r\n get: (target, prop) => {\r\n if (typeof prop === \"string\" && !isNaN(Number(prop))) {\r\n const index = Number(prop);\r\n return target.get(index);\r\n }\r\n return target[prop as keyof FastBooleanArray];\r\n },\r\n set: (target, prop, value) => {\r\n if (typeof prop === \"string\" && !isNaN(Number(prop))) {\r\n const index = Number(prop);\r\n target.set(index, value as never);\r\n } else {\r\n target[prop as Exclude<keyof FastBooleanArray, \"length\">] = value;\r\n }\r\n\r\n return true;\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Applies a callback function to each element in the array.\r\n * @param {Function} callback - The function to execute on each element.\r\n */\r\n forEach(\r\n callback: (value: boolean, index: number, array: FastBooleanArray) => void\r\n ) {\r\n for (let i = 0; i < this.size; i++) {\r\n callback(this.get(i), i, this);\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new array with the results of calling a provided function on every element.\r\n * @param {Function} callback - The function to execute on each element.\r\n */\r\n map(\r\n callback: (value: boolean, index: number, array: FastBooleanArray) => never\r\n ) {\r\n const result = new Array(this.size);\r\n for (let i = 0; i < this.size; i++) {\r\n result[i] = callback(this.get(i), i, this);\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a new array with all elements that pass the test implemented by the provided function.\r\n * @param {Function} callback - The function to test each element.\r\n */\r\n filter(\r\n callback: (\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => boolean\r\n ) {\r\n const result: boolean[] = [];\r\n for (let i = 0; i < this.size; i++) {\r\n const value = this.get(i);\r\n if (callback(value, i, this)) {\r\n result.push(value);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Tests whether at least one element in the array passes the test implemented by the provided function.\r\n * @param {Function} callback - The function to test each element.\r\n */\r\n some(\r\n callback: (\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => boolean\r\n ) {\r\n for (let i = 0; i < this.size; i++) {\r\n if (callback(this.get(i), i, this)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Tests whether all elements in the array pass the test implemented by the provided function.\r\n * @param {Function} callback - The function to test each element.\r\n */\r\n every(\r\n callback: (\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => boolean\r\n ) {\r\n for (let i = 0; i < this.size; i++) {\r\n if (!callback(this.get(i), i, this)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Reduces the array to a single value by applying a function to each element.\r\n * @param {Function} callback - The function to execute on each element.\r\n * @param {any} initialValue - The initial value for the accumulator.\r\n */\r\n reduce<T>(\r\n callback: (\r\n accumulator: T,\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => T,\r\n initialValue: T\r\n ): T {\r\n let accumulator = initialValue;\r\n for (let i = 0; i < this.size; i++) {\r\n accumulator = callback(accumulator, this.get(i), i, this);\r\n }\r\n return accumulator;\r\n }\r\n\r\n /**\r\n * Generates a string where every boolean is either a 0 or 1.\r\n */\r\n toString() {\r\n let result = ``;\r\n for (let i = 0; i < this.size; i++) {\r\n result += this.get(i) ? \"1\" : \"0\";\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns a FastBooleanArray from .toString() output\r\n */\r\n static fromString(value: string) {\r\n const array = new FastBooleanArray(value.length);\r\n for (let i = 0; i < value.length; i++) {\r\n array.set(i, value[i] == \"1\");\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Returns a FastBooleanArray from a boolean array or number array\r\n */\r\n static fromArray(value: boolean[] | number[]) {\r\n const array = new FastBooleanArray(value.length);\r\n for (let i = 0; i < value.length; i++) {\r\n array.set(i, !!value[i]);\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Returns a FastBooleanArray from a string, boolean array or number array\r\n */\r\n static from(value: string | boolean[] | number[]) {\r\n if (typeof value === \"string\") {\r\n return FastBooleanArray.fromString(value);\r\n }\r\n\r\n return FastBooleanArray.fromArray(value);\r\n }\r\n}\r\n"],"mappings":"AAAA,IAAMA,EAAsB,sBAEPC,EAArB,MAAqBC,CAAiB,CAC7B,KACC,OAER,YAAYC,EAAc,CACxB,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,kDAAkD,EAEpE,KAAK,KAAOA,EACZ,KAAK,OAAS,IAAI,WAAW,KAAK,KAAKA,EAAO,CAAC,CAAC,CAClD,CAQA,IAAIC,EAAeC,EAAgB,CACjC,OAAIA,GACF,KAAK,OAAOD,GAAS,CAAC,GAAK,IAAMA,EAAQ,GAClC,KAEP,KAAK,OAAOA,GAAS,CAAC,GAAK,EAAE,IAAMA,EAAQ,IACpC,GAEX,CASA,QAAQA,EAAeC,EAAgB,CACrC,GAAID,EAAQ,GAAKA,GAAS,KAAK,KAC7B,MAAM,IAAI,WAAWJ,CAAmB,EAE1C,OAAO,KAAK,IAAII,EAAOC,CAAK,CAC9B,CAMA,OAAOA,EAAgB,CACrB,KAAK,OAAO,KAAKA,EAAQ,IA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AW,CACT,IAAIF,EAAS,GACb,QAASL,EAAI,EAAGA,EAAI,KAAK,KAAMA,IAC7BK,GAAU,KAAK,IAAIL,CAAC,EAAI,IAAM,IAEhC,OAAOK,CACT,CAKA,OAAO,WAAWZ,EAAe,CAC/B,IAAMe,EAAQ,IAAIlB,EAAiBG,EAAM,MAAM,EAC/C,QAASO,EAAI,EAAGA,EAAIP,EAAM,OAAQO,IAChCQ,EAAM,IAAIR,EAAGP,EAAMO,CAAC,GAAK,GAAG,EAE9B,OAAOQ,CACT,CAKA,OAAO,UAAUf,EAA6B,CAC5C,IAAMe,EAAQ,IAAIlB,EAAiBG,EAAM,MAAM,EAC/C,QAASO,EAAI,EAAGA,EAAIP,EAAM,OAAQO,IAChCQ,EAAM,IAAIR,EAAG,CAAC,CAACP,EAAMO,CAAC,CAAC,EAEzB,OAAOQ,CACT,CAKA,OAAO,KAAKf,EAAsC,CAChD,OAAI,OAAOA,GAAU,SACZH,EAAiB,WAAWG,CAAK,EAGnCH,EAAiB,UAAUG,CAAK,CACzC,CACF","names":["ERROR_OUT_OF_BOUNDS","FastBooleanArray","_FastBooleanArray","size","index","value","byteIndex","bitIndex","newSize","newBuffer","other","byte","i","arr","target","prop","callback","result","initialValue","accumulator","array"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["const ERROR_OUT_OF_BOUNDS = \"Index out of bounds\";\r\n\r\nexport default class FastBooleanArray {\r\n public size: number;\r\n private buffer: Uint8Array;\r\n\r\n constructor(size: number) {\r\n if (!size) {\r\n throw new Error(\"FastBooleanArray must have a size greater than 0\");\r\n }\r\n this.size = size;\r\n this.buffer = new Uint8Array(Math.ceil(size / 8)); // Allocate memory\r\n }\r\n\r\n /**\r\n * Sets a boolean value at the specified index.\r\n * @param {number} index - The index to set the boolean value at.\r\n * @param {number} value - The boolean value to set the `index`.\r\n * @returns {boolean} The boolean value that was set.\r\n */\r\n set(index: number, value: boolean) {\r\n if (value) {\r\n this.buffer[index >> 3] |= 1 << (index & 7); // Set bit\r\n return true;\r\n } else {\r\n this.buffer[index >> 3] &= ~(1 << (index & 7)); // Clear bit\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * like `set` but throws if the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n * @param {number} index - The index to set the boolean value at.\r\n * @param {number} value - The boolean value to set the `index`.\r\n * @returns {boolean} The boolean value that was set.\r\n * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n */\r\n setSafe(index: number, value: boolean) {\r\n if (index < 0 || index >= this.size) {\r\n throw new RangeError(ERROR_OUT_OF_BOUNDS);\r\n }\r\n return this.set(index, value);\r\n }\r\n\r\n /**\r\n * Sets all bits to the specified boolean value.\r\n * @param {boolean} value - The boolean value to set all bits to.\r\n */\r\n setAll(value: boolean) {\r\n this.buffer.fill(value ? 0xff : 0x00);\r\n }\r\n\r\n /**\r\n * Gets a boolean value at the specified index.\r\n * @param {number} index - The index to get the boolean value of.\r\n * @returns {boolean} The boolean value that was set.\r\n * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n */\r\n get(index: number) {\r\n return (this.buffer[index >> 3] >> (index & 7)) & 1 ? true : false;\r\n }\r\n\r\n /**\r\n * like `get` but throws if the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n * @param {number} index - The index to get the boolean value of.\r\n * @returns {boolean} The boolean value that was set.\r\n * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n */\r\n getSafe(index: number) {\r\n if (index < 0 || index >= this.size) {\r\n throw new RangeError(ERROR_OUT_OF_BOUNDS);\r\n }\r\n return this.get(index);\r\n }\r\n\r\n /**\r\n * Resizes the array to a new size, preserving existing data.\r\n * @param {number} newSize - The new size of the array.\r\n */\r\n resize(newSize: number) {\r\n const newBuffer = new Uint8Array(Math.ceil(newSize / 8));\r\n newBuffer.set(\r\n this.buffer.subarray(0, Math.min(this.buffer.length, newBuffer.length))\r\n );\r\n this.size = newSize;\r\n this.buffer = newBuffer;\r\n }\r\n\r\n get length() {\r\n return this.size;\r\n }\r\n\r\n /**\r\n * Compares this FastBooleanArray with another for equality.\r\n * @param {FastBooleanArray} other - The other FastBooleanArray to compare.\r\n * @returns {boolean} True if both arrays are equal, false otherwise.\r\n */\r\n equals(other: FastBooleanArray) {\r\n if (this.size !== other.size) {\r\n return false;\r\n }\r\n return this.buffer.every((byte, i) => byte === other.buffer[i]);\r\n }\r\n\r\n /**\r\n * Makes the array iterable using `for...of`.\r\n */\r\n *[Symbol.iterator]() {\r\n for (let i = 0; i < this.size; i++) {\r\n yield this.get(i);\r\n }\r\n }\r\n\r\n /**\r\n * Converts to a standard JavaScript array.\r\n */\r\n toArray() {\r\n const arr = new Array(this.size);\r\n for (let i = 0; i < this.size; i++) {\r\n arr[i] = this.get(i);\r\n }\r\n return arr;\r\n }\r\n\r\n /**\r\n * Returns a proxy to the FastBooleanArray instance\r\n * With this you can access indexes like on an actual array.\r\n */\r\n accessLikeArray() {\r\n return new Proxy(this, {\r\n get: (target, prop) => {\r\n if (typeof prop === \"string\" && !isNaN(Number(prop))) {\r\n const index = Number(prop);\r\n return target.get(index);\r\n }\r\n return target[prop as keyof FastBooleanArray];\r\n },\r\n set: (target, prop, value) => {\r\n if (typeof prop === \"string\" && !isNaN(Number(prop))) {\r\n const index = Number(prop);\r\n target.set(index, value as never);\r\n } else {\r\n target[prop as Exclude<keyof FastBooleanArray, \"length\">] = value;\r\n }\r\n\r\n return true;\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Applies a callback function to each element in the array.\r\n * @param {Function} callback - The function to execute on each element.\r\n */\r\n forEach(\r\n callback: (value: boolean, index: number, array: FastBooleanArray) => void\r\n ) {\r\n for (let i = 0; i < this.size; i++) {\r\n callback(this.get(i), i, this);\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new array with the results of calling a provided function on every element.\r\n * @param {Function} callback - The function to execute on each element.\r\n */\r\n map(\r\n callback: (value: boolean, index: number, array: FastBooleanArray) => never\r\n ) {\r\n const result = new Array(this.size);\r\n for (let i = 0; i < this.size; i++) {\r\n result[i] = callback(this.get(i), i, this);\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a new array with all elements that pass the test implemented by the provided function.\r\n * @param {Function} callback - The function to test each element.\r\n */\r\n filter(\r\n callback: (\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => boolean\r\n ) {\r\n const result: boolean[] = [];\r\n for (let i = 0; i < this.size; i++) {\r\n const value = this.get(i);\r\n if (callback(value, i, this)) {\r\n result.push(value);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Tests whether at least one element in the array passes the test implemented by the provided function.\r\n * @param {Function} callback - The function to test each element.\r\n */\r\n some(\r\n callback: (\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => boolean\r\n ) {\r\n for (let i = 0; i < this.size; i++) {\r\n if (callback(this.get(i), i, this)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Tests whether all elements in the array pass the test implemented by the provided function.\r\n * @param {Function} callback - The function to test each element.\r\n */\r\n every(\r\n callback: (\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => boolean\r\n ) {\r\n for (let i = 0; i < this.size; i++) {\r\n if (!callback(this.get(i), i, this)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Reduces the array to a single value by applying a function to each element.\r\n * @param {Function} callback - The function to execute on each element.\r\n * @param {any} initialValue - The initial value for the accumulator.\r\n */\r\n reduce<T>(\r\n callback: (\r\n accumulator: T,\r\n value: boolean,\r\n index: number,\r\n array: FastBooleanArray\r\n ) => T,\r\n initialValue: T\r\n ): T {\r\n let accumulator = initialValue;\r\n for (let i = 0; i < this.size; i++) {\r\n accumulator = callback(accumulator, this.get(i), i, this);\r\n }\r\n return accumulator;\r\n }\r\n\r\n /**\r\n * Generates a string where every boolean is either a 0 or 1.\r\n */\r\n toString() {\r\n let result = ``;\r\n for (let i = 0; i < this.size; i++) {\r\n result += this.get(i) ? \"1\" : \"0\";\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns a FastBooleanArray from .toString() output\r\n */\r\n static fromString(value: string) {\r\n const array = new FastBooleanArray(value.length);\r\n for (let i = 0; i < value.length; i++) {\r\n array.set(i, value[i] == \"1\");\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Returns a FastBooleanArray from a boolean array or number array\r\n */\r\n static fromArray(value: boolean[] | number[]) {\r\n const array = new FastBooleanArray(value.length);\r\n for (let i = 0; i < value.length; i++) {\r\n array.set(i, !!value[i]);\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Returns a FastBooleanArray from a string, boolean array or number array\r\n */\r\n static from(value: string | boolean[] | number[]) {\r\n if (typeof value === \"string\") {\r\n return FastBooleanArray.fromString(value);\r\n }\r\n\r\n return FastBooleanArray.fromArray(value);\r\n }\r\n}\r\n"],"mappings":"AAAA,IAAMA,EAAsB,sBAEPC,EAArB,MAAqBC,CAAiB,CAC7B,KACC,OAER,YAAYC,EAAc,CACxB,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,kDAAkD,EAEpE,KAAK,KAAOA,EACZ,KAAK,OAAS,IAAI,WAAW,KAAK,KAAKA,EAAO,CAAC,CAAC,CAClD,CAQA,IAAIC,EAAeC,EAAgB,CACjC,OAAIA,GACF,KAAK,OAAOD,GAAS,CAAC,GAAK,IAAMA,EAAQ,GAClC,KAEP,KAAK,OAAOA,GAAS,CAAC,GAAK,EAAE,IAAMA,EAAQ,IACpC,GAEX,CASA,QAAQA,EAAeC,EAAgB,CACrC,GAAID,EAAQ,GAAKA,GAAS,KAAK,KAC7B,MAAM,IAAI,WAAWJ,CAAmB,EAE1C,OAAO,KAAK,IAAII,EAAOC,CAAK,CAC9B,CAMA,OAAOA,EAAgB,CACrB,KAAK,OAAO,KAAKA,EAAQ,IAAO,CAAI,CACtC,CAQA,IAAID,EAAe,CACjB,MAAQ,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AAIL,CAAC,EAAI,IAAM,IAEhC,OAAOK,CACT,CAKA,OAAO,WAAWV,EAAe,CAC/B,IAAMa,EAAQ,IAAIhB,EAAiBG,EAAM,MAAM,EAC/C,QAASK,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IAChCQ,EAAM,IAAIR,EAAGL,EAAMK,CAAC,GAAK,GAAG,EAE9B,OAAOQ,CACT,CAKA,OAAO,UAAUb,EAA6B,CAC5C,IAAMa,EAAQ,IAAIhB,EAAiBG,EAAM,MAAM,EAC/C,QAASK,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IAChCQ,EAAM,IAAIR,EAAG,CAAC,CAACL,EAAMK,CAAC,CAAC,EAEzB,OAAOQ,CACT,CAKA,OAAO,KAAKb,EAAsC,CAChD,OAAI,OAAOA,GAAU,SACZH,EAAiB,WAAWG,CAAK,EAGnCH,EAAiB,UAAUG,CAAK,CACzC,CACF","names":["ERROR_OUT_OF_BOUNDS","FastBooleanArray","_FastBooleanArray","size","index","value","newSize","newBuffer","other","byte","i","arr","target","prop","callback","result","initialValue","accumulator","array"]}
|
package/package.json
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "fast-boolean-array",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"homepage": "https://github.com/UltraCakeBakery/FastBooleanArray",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/UltraCakeBakery/FastBooleanArray.git"
|
|
8
|
-
},
|
|
9
|
-
"bugs": {
|
|
10
|
-
"url": "https://github.com/UltraCakeBakery/FastBooleanArray/issues",
|
|
11
|
-
"email": "fast-boolean-array@managing.software"
|
|
12
|
-
},
|
|
13
|
-
"type": "module",
|
|
14
|
-
"main": "./dist/index.cjs",
|
|
15
|
-
"module": "./dist/index.js",
|
|
16
|
-
"types": "./dist/index.d.ts",
|
|
17
|
-
"exports": {
|
|
18
|
-
"import": {
|
|
19
|
-
"types": "./dist/index.d.ts",
|
|
20
|
-
"import": "./dist/index.js"
|
|
21
|
-
},
|
|
22
|
-
"require": {
|
|
23
|
-
"types": "./dist/index.d.cts",
|
|
24
|
-
"require": "./dist/index.cjs"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"scripts": {
|
|
28
|
-
"test": "vitest",
|
|
29
|
-
"check-types": "npx --yes @arethetypeswrong/cli --pack .",
|
|
30
|
-
"build": "tsup src/index.ts --dts --format cjs,esm --clean --sourcemap --minify",
|
|
31
|
-
"publish": "npm publish"
|
|
32
|
-
},
|
|
33
|
-
"keywords": [
|
|
34
|
-
"boolean",
|
|
35
|
-
"array",
|
|
36
|
-
"fast",
|
|
37
|
-
"efficient",
|
|
38
|
-
"map"
|
|
39
|
-
],
|
|
40
|
-
"author": "Jack van der Bil <jack@managing.software> (https://jackvanderbilt.nl)",
|
|
41
|
-
"license": "MIT",
|
|
42
|
-
"description": "",
|
|
43
|
-
"engines": {
|
|
44
|
-
"node": ">=0.10.3"
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"@types/node": "^
|
|
48
|
-
"tsup": "^8.4.0",
|
|
49
|
-
"typescript": "^5.8.3",
|
|
50
|
-
"vitest": "^3.1.2"
|
|
51
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "fast-boolean-array",
|
|
3
|
+
"version": "1.7.0",
|
|
4
|
+
"homepage": "https://github.com/UltraCakeBakery/FastBooleanArray",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/UltraCakeBakery/FastBooleanArray.git"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/UltraCakeBakery/FastBooleanArray/issues",
|
|
11
|
+
"email": "fast-boolean-array@managing.software"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/index.cjs",
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"require": "./dist/index.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"test": "vitest",
|
|
29
|
+
"check-types": "npx --yes @arethetypeswrong/cli --pack .",
|
|
30
|
+
"build": "tsup src/index.ts --dts --format cjs,esm --clean --sourcemap --minify",
|
|
31
|
+
"publish": "npm publish"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"boolean",
|
|
35
|
+
"array",
|
|
36
|
+
"fast",
|
|
37
|
+
"efficient",
|
|
38
|
+
"map"
|
|
39
|
+
],
|
|
40
|
+
"author": "Jack van der Bil <jack@managing.software> (https://jackvanderbilt.nl)",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"description": "",
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=0.10.3"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^24.0.3",
|
|
48
|
+
"tsup": "^8.4.0",
|
|
49
|
+
"typescript": "^5.8.3",
|
|
50
|
+
"vitest": "^3.1.2"
|
|
51
|
+
}
|
|
52
52
|
}
|