fast-boolean-array 1.3.4 → 1.4.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 CHANGED
@@ -23,10 +23,13 @@ __export(src_exports, {
23
23
  default: () => FastBooleanArray
24
24
  });
25
25
  module.exports = __toCommonJS(src_exports);
26
- var FastBooleanArray = class {
26
+ var FastBooleanArray = class _FastBooleanArray {
27
27
  size;
28
28
  buffer;
29
29
  constructor(size) {
30
+ if (!size) {
31
+ throw new Error("FastBooleanArray must have a size greater than 0");
32
+ }
30
33
  this.size = size;
31
34
  this.buffer = new Uint8Array(Math.ceil(size / 8));
32
35
  }
@@ -58,6 +61,13 @@ var FastBooleanArray = class {
58
61
  }
59
62
  return this.set(index, value);
60
63
  }
64
+ /**
65
+ * Sets all bits to the specified boolean value.
66
+ * @param {boolean} value - The boolean value to set all bits to.
67
+ */
68
+ setAll(value) {
69
+ this.buffer.fill(value ? 255 : 0);
70
+ }
61
71
  /**
62
72
  * Gets a boolean value at the specified index.
63
73
  * @param {number} index - The index to get the boolean value of.
@@ -65,7 +75,7 @@ var FastBooleanArray = class {
65
75
  * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).
66
76
  */
67
77
  get(index) {
68
- return (this.buffer[index >> 3] & 1 << index % 8) !== 0;
78
+ return !!(this.buffer[index >> 3] & 1 << index % 8);
69
79
  }
70
80
  /**
71
81
  * like `get` but throws if the index is out of bounds (less than 0 or greater than or equal to the array size).
@@ -79,11 +89,178 @@ var FastBooleanArray = class {
79
89
  }
80
90
  return this.get(index);
81
91
  }
92
+ /**
93
+ * Resizes the array to a new size, preserving existing data.
94
+ * @param {number} newSize - The new size of the array.
95
+ */
96
+ resize(newSize) {
97
+ const newBuffer = new Uint8Array(Math.ceil(newSize / 8));
98
+ newBuffer.set(this.buffer.subarray(0, Math.min(this.buffer.length, newBuffer.length)));
99
+ this.buffer = newBuffer;
100
+ this.size = newSize;
101
+ }
82
102
  get length() {
83
103
  return this.size;
84
104
  }
85
- set length(_value) {
86
- throw new Error("Setting the length on BooleanArray's is not supported");
105
+ /**
106
+ * Compares this FastBooleanArray with another for equality.
107
+ * @param {FastBooleanArray} other - The other FastBooleanArray to compare.
108
+ * @returns {boolean} True if both arrays are equal, false otherwise.
109
+ */
110
+ equals(other) {
111
+ if (this.size !== other.size) {
112
+ return false;
113
+ }
114
+ return this.buffer.every((byte, i) => byte === other.buffer[i]);
115
+ }
116
+ /**
117
+ * Makes the array iterable using `for...of`.
118
+ */
119
+ *[Symbol.iterator]() {
120
+ for (let i = 0; i < this.size; i++) {
121
+ yield this.get(i);
122
+ }
123
+ }
124
+ /**
125
+ * Converts to a standard JavaScript array.
126
+ */
127
+ toArray() {
128
+ const arr = new Array(this.size);
129
+ for (let i = 0; i < this.size; i++) {
130
+ arr[i] = this.get(i);
131
+ }
132
+ return arr;
133
+ }
134
+ /**
135
+ * Returns a proxy to the FastBooleanArray instance
136
+ * With this you can access indexes like on an actual array.
137
+ */
138
+ accessLikeArray() {
139
+ return new Proxy(this, {
140
+ get: (target, prop) => {
141
+ if (typeof prop === "string" && !isNaN(Number(prop))) {
142
+ const index = Number(prop);
143
+ return target.get(index);
144
+ }
145
+ return target[prop];
146
+ },
147
+ set: (target, prop, value) => {
148
+ if (typeof prop === "string" && !isNaN(Number(prop))) {
149
+ const index = Number(prop);
150
+ return target.set(index, value);
151
+ }
152
+ return target[prop] = value;
153
+ }
154
+ });
155
+ }
156
+ /**
157
+ * Applies a callback function to each element in the array.
158
+ * @param {Function} callback - The function to execute on each element.
159
+ */
160
+ forEach(callback) {
161
+ for (let i = 0; i < this.size; i++) {
162
+ callback(this.get(i), i, this);
163
+ }
164
+ }
165
+ /**
166
+ * Creates a new array with the results of calling a provided function on every element.
167
+ * @param {Function} callback - The function to execute on each element.
168
+ */
169
+ map(callback) {
170
+ const result = new Array(this.size);
171
+ for (let i = 0; i < this.size; i++) {
172
+ result[i] = callback(this.get(i), i, this);
173
+ }
174
+ return result;
175
+ }
176
+ /**
177
+ * Creates a new array with all elements that pass the test implemented by the provided function.
178
+ * @param {Function} callback - The function to test each element.
179
+ */
180
+ filter(callback) {
181
+ const result = [];
182
+ for (let i = 0; i < this.size; i++) {
183
+ const value = this.get(i);
184
+ if (callback(value, i, this)) {
185
+ result.push(value);
186
+ }
187
+ }
188
+ return result;
189
+ }
190
+ /**
191
+ * Tests whether at least one element in the array passes the test implemented by the provided function.
192
+ * @param {Function} callback - The function to test each element.
193
+ */
194
+ some(callback) {
195
+ for (let i = 0; i < this.size; i++) {
196
+ if (callback(this.get(i), i, this)) {
197
+ return true;
198
+ }
199
+ }
200
+ return false;
201
+ }
202
+ /**
203
+ * Tests whether all elements in the array pass the test implemented by the provided function.
204
+ * @param {Function} callback - The function to test each element.
205
+ */
206
+ every(callback) {
207
+ for (let i = 0; i < this.size; i++) {
208
+ if (!callback(this.get(i), i, this)) {
209
+ return false;
210
+ }
211
+ }
212
+ return true;
213
+ }
214
+ /**
215
+ * Reduces the array to a single value by applying a function to each element.
216
+ * @param {Function} callback - The function to execute on each element.
217
+ * @param {any} initialValue - The initial value for the accumulator.
218
+ */
219
+ reduce(callback, initialValue) {
220
+ let accumulator = initialValue;
221
+ for (let i = 0; i < this.size; i++) {
222
+ accumulator = callback(accumulator, this.get(i), i, this);
223
+ }
224
+ return accumulator;
225
+ }
226
+ /**
227
+ * Generates a string where every boolean is either a 0 or 1.
228
+ */
229
+ toString() {
230
+ let result = ``;
231
+ for (let i = 0; i < this.size; i++) {
232
+ result += this.get(i) ? "1" : "0";
233
+ }
234
+ return result;
235
+ }
236
+ /**
237
+ * Returns a FastBooleanArray from .toString() output
238
+ */
239
+ static fromString(value) {
240
+ const array = new _FastBooleanArray(value.length);
241
+ for (let i = 0; i < value.length; i++) {
242
+ array.set(i, value[i] == "1");
243
+ }
244
+ return array;
245
+ }
246
+ /**
247
+ * Returns a FastBooleanArray from a boolean array or number array
248
+ */
249
+ static fromArray(value) {
250
+ const array = new _FastBooleanArray(value.length);
251
+ for (let i = 0; i < value.length; i++) {
252
+ array.set(i, !!value[i]);
253
+ }
254
+ return array;
255
+ }
256
+ /**
257
+ * Returns a FastBooleanArray from a string, boolean array or number array
258
+ */
259
+ static from(value) {
260
+ if (typeof value === "string") {
261
+ return _FastBooleanArray.fromString(value);
262
+ }
263
+ return _FastBooleanArray.fromArray(value);
87
264
  }
88
265
  };
89
266
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export default class FastBooleanArray {\r\n\tpublic size: number;\r\n\tprivate buffer: Uint8Array;\r\n\r\n\tconstructor(size: number) {\r\n\t\tthis.size = size;\r\n\t\tthis.buffer = new Uint8Array(Math.ceil(size / 8)); // Allocate memory\r\n\t}\r\n\r\n\t/**\r\n\t * Sets a boolean value at the specified index.\r\n\t * @param {number} index - The index to set the boolean value at.\r\n\t * @param {number} value - The boolean value to set the `index`.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t */\r\n\tset(index: number, value: any) {\r\n\t\tif (value) {\r\n\t\t\tthis.buffer[index >> 3] |= 1 << (index & 7); // Set bit\r\n\t\t\treturn true;\r\n\t\t} else {\r\n\t\t\tthis.buffer[index >> 3] &= ~(1 << (index & 7)); // Clear bit\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * 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\t * @param {number} index - The index to set the boolean value at.\r\n\t * @param {number} value - The boolean value to set the `index`.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n\t */\r\n\tsetSafe(index: number, value: any) {\r\n\t\tif (index < 0 || index >= this.size) {\r\n\t\t\tthrow new RangeError('Index out of bounds');\r\n\t\t}\r\n\t\treturn this.set(index, value);\r\n\t}\r\n\r\n\t/**\r\n\t * Gets a boolean value at the specified index.\r\n\t * @param {number} index - The index to get the boolean value of.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n\t */\r\n\tget(index: number) {\r\n\t\treturn (this.buffer[index >> 3] & (1 << index % 8)) !== 0; // Check bit\r\n\t}\r\n\r\n\t/**\r\n\t * 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\t * @param {number} index - The index to get the boolean value of.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n\t */\r\n\tgetSafe(index: number) {\r\n\t\tif (index < 0 || index >= this.size) {\r\n\t\t\tthrow new RangeError('Index out of bounds');\r\n\t\t}\r\n\t\treturn this.get(index);\r\n\t}\r\n\r\n\tget length() {\r\n\t\treturn this.size;\r\n\t}\r\n\r\n\tset length(_value: number) {\r\n\t\tthrow new Error(\"Setting the length on BooleanArray's is not supported\");\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAqB,mBAArB,MAAsC;AAAA,EAC9B;AAAA,EACC;AAAA,EAER,YAAY,MAAc;AACzB,SAAK,OAAO;AACZ,SAAK,SAAS,IAAI,WAAW,KAAK,KAAK,OAAO,CAAC,CAAC;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,OAAe,OAAY;AAC9B,QAAI,OAAO;AACV,WAAK,OAAO,SAAS,CAAC,KAAK,MAAM,QAAQ;AACzC,aAAO;AAAA,IACR,OAAO;AACN,WAAK,OAAO,SAAS,CAAC,KAAK,EAAE,MAAM,QAAQ;AAC3C,aAAO;AAAA,IACR;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,QAAQ,OAAe,OAAY;AAClC,QAAI,QAAQ,KAAK,SAAS,KAAK,MAAM;AACpC,YAAM,IAAI,WAAW,qBAAqB;AAAA,IAC3C;AACA,WAAO,KAAK,IAAI,OAAO,KAAK;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,OAAe;AAClB,YAAQ,KAAK,OAAO,SAAS,CAAC,IAAK,KAAK,QAAQ,OAAQ;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,QAAQ,OAAe;AACtB,QAAI,QAAQ,KAAK,SAAS,KAAK,MAAM;AACpC,YAAM,IAAI,WAAW,qBAAqB;AAAA,IAC3C;AACA,WAAO,KAAK,IAAI,KAAK;AAAA,EACtB;AAAA,EAEA,IAAI,SAAS;AACZ,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,IAAI,OAAO,QAAgB;AAC1B,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACxE;AACD;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export default class FastBooleanArray {\r\n\tpublic size: number;\r\n\tprivate buffer: Uint8Array;\r\n\r\n\tconstructor(size: number) {\r\n\t\tif (!size) {\r\n\t\t\tthrow new Error('FastBooleanArray must have a size greater than 0');\r\n\t\t}\r\n\t\tthis.size = size;\r\n\t\tthis.buffer = new Uint8Array(Math.ceil(size / 8)); // Allocate memory\r\n\t}\r\n\r\n\t/**\r\n\t * Sets a boolean value at the specified index.\r\n\t * @param {number} index - The index to set the boolean value at.\r\n\t * @param {number} value - The boolean value to set the `index`.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t */\r\n\tset(index: number, value: boolean) {\r\n\t\tif (value) {\r\n\t\t\tthis.buffer[index >> 3] |= 1 << (index & 7); // Set bit\r\n\t\t\treturn true;\r\n\t\t} else {\r\n\t\t\tthis.buffer[index >> 3] &= ~(1 << (index & 7)); // Clear bit\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * 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\t * @param {number} index - The index to set the boolean value at.\r\n\t * @param {number} value - The boolean value to set the `index`.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n\t */\r\n\tsetSafe(index: number, value: boolean) {\r\n\t\tif (index < 0 || index >= this.size) {\r\n\t\t\tthrow new RangeError('Index out of bounds');\r\n\t\t}\r\n\t\treturn this.set(index, value);\r\n\t}\r\n\r\n\t/**\r\n\t * Sets all bits to the specified boolean value.\r\n\t * @param {boolean} value - The boolean value to set all bits to.\r\n\t */\r\n\tsetAll(value: boolean) {\r\n\t\tthis.buffer.fill(value ? 0xff : 0x00);\r\n\t}\r\n\r\n\t/**\r\n\t * Gets a boolean value at the specified index.\r\n\t * @param {number} index - The index to get the boolean value of.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n\t */\r\n\tget(index: number) {\r\n\t\treturn !!(this.buffer[index >> 3] & (1 << index % 8)); // Check bit\r\n\t}\r\n\r\n\t/**\r\n\t * 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\t * @param {number} index - The index to get the boolean value of.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n\t */\r\n\tgetSafe(index: number) {\r\n\t\tif (index < 0 || index >= this.size) {\r\n\t\t\tthrow new RangeError('Index out of bounds');\r\n\t\t}\r\n\t\treturn this.get(index);\r\n\t}\r\n\r\n\t/**\r\n\t * Resizes the array to a new size, preserving existing data.\r\n\t * @param {number} newSize - The new size of the array.\r\n\t */\r\n\tresize(newSize: number) {\r\n\t\tconst newBuffer = new Uint8Array(Math.ceil(newSize / 8));\r\n\t\tnewBuffer.set(this.buffer.subarray(0, Math.min(this.buffer.length, newBuffer.length)));\r\n\t\tthis.buffer = newBuffer;\r\n\t\tthis.size = newSize;\r\n\t}\r\n\r\n\tget length() {\r\n\t\treturn this.size;\r\n\t}\r\n\r\n\t/**\r\n\t * Compares this FastBooleanArray with another for equality.\r\n\t * @param {FastBooleanArray} other - The other FastBooleanArray to compare.\r\n\t * @returns {boolean} True if both arrays are equal, false otherwise.\r\n\t */\r\n\tequals(other: FastBooleanArray) {\r\n\t\tif (this.size !== other.size) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\treturn this.buffer.every((byte, i) => byte === other.buffer[i]);\r\n\t}\r\n\r\n\t/**\r\n\t * Makes the array iterable using `for...of`.\r\n\t */\r\n\t*[Symbol.iterator]() {\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tyield this.get(i);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Converts to a standard JavaScript array.\r\n\t */\r\n\ttoArray() {\r\n\t\tconst arr = new Array(this.size);\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tarr[i] = this.get(i);\r\n\t\t}\r\n\t\treturn arr;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a proxy to the FastBooleanArray instance\r\n\t * With this you can access indexes like on an actual array.\r\n\t */\r\n\taccessLikeArray() {\r\n\t\treturn new Proxy(this, {\r\n\t\t\tget: (target, prop) => {\r\n\t\t\t\tif (typeof prop === 'string' && !isNaN(Number(prop))) {\r\n\t\t\t\t\tconst index = Number(prop);\r\n\t\t\t\t\treturn target.get(index);\r\n\t\t\t\t}\r\n\t\t\t\treturn target[prop as keyof FastBooleanArray];\r\n\t\t\t},\r\n\t\t\tset: (target, prop, value) => {\r\n\t\t\t\tif (typeof prop === 'string' && !isNaN(Number(prop))) {\r\n\t\t\t\t\tconst index = Number(prop);\r\n\t\t\t\t\treturn target.set(index, value as never);\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn (target[prop as Exclude<keyof FastBooleanArray, 'length'>] = value);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Applies a callback function to each element in the array.\r\n\t * @param {Function} callback - The function to execute on each element.\r\n\t */\r\n\tforEach(callback: (value: boolean, index: number, array: FastBooleanArray) => void) {\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tcallback(this.get(i), i, this);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a new array with the results of calling a provided function on every element.\r\n\t * @param {Function} callback - The function to execute on each element.\r\n\t */\r\n\tmap(callback: (value: boolean, index: number, array: FastBooleanArray) => never) {\r\n\t\tconst result = new Array(this.size);\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tresult[i] = callback(this.get(i), i, this);\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a new array with all elements that pass the test implemented by the provided function.\r\n\t * @param {Function} callback - The function to test each element.\r\n\t */\r\n\tfilter(callback: (value: boolean, index: number, array: FastBooleanArray) => boolean) {\r\n\t\tconst result: boolean[] = [];\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tconst value = this.get(i);\r\n\t\t\tif (callback(value, i, this)) {\r\n\t\t\t\tresult.push(value);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/**\r\n\t * Tests whether at least one element in the array passes the test implemented by the provided function.\r\n\t * @param {Function} callback - The function to test each element.\r\n\t */\r\n\tsome(callback: (value: boolean, index: number, array: FastBooleanArray) => boolean) {\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tif (callback(this.get(i), i, this)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t}\r\n\r\n\t/**\r\n\t * Tests whether all elements in the array pass the test implemented by the provided function.\r\n\t * @param {Function} callback - The function to test each element.\r\n\t */\r\n\tevery(callback: (value: boolean, index: number, array: FastBooleanArray) => boolean) {\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tif (!callback(this.get(i), i, this)) {\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn true;\r\n\t}\r\n\r\n\t/**\r\n\t * Reduces the array to a single value by applying a function to each element.\r\n\t * @param {Function} callback - The function to execute on each element.\r\n\t * @param {any} initialValue - The initial value for the accumulator.\r\n\t */\r\n\treduce<T>(\r\n\t\tcallback: (accumulator: T, value: boolean, index: number, array: FastBooleanArray) => T,\r\n\t\tinitialValue: T\r\n\t): T {\r\n\t\tlet accumulator = initialValue;\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\taccumulator = callback(accumulator, this.get(i), i, this);\r\n\t\t}\r\n\t\treturn accumulator;\r\n\t}\r\n\r\n\t/**\r\n\t * Generates a string where every boolean is either a 0 or 1.\r\n\t */\r\n\ttoString() {\r\n\t\tlet result = ``;\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tresult += this.get(i) ? '1' : '0';\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a FastBooleanArray from .toString() output\r\n\t */\r\n\tstatic fromString(value: string) {\r\n\t\tconst array = new FastBooleanArray(value.length);\r\n\t\tfor (let i = 0; i < value.length; i++) {\r\n\t\t\tarray.set(i, value[i] == '1');\r\n\t\t}\r\n\t\treturn array;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a FastBooleanArray from a boolean array or number array\r\n\t */\r\n\tstatic fromArray(value: boolean[] | number[]) {\r\n\t\tconst array = new FastBooleanArray(value.length);\r\n\t\tfor (let i = 0; i < value.length; i++) {\r\n\t\t\tarray.set(i, !!value[i]);\r\n\t\t}\r\n\t\treturn array;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a FastBooleanArray from a string, boolean array or number array\r\n\t */\r\n\tstatic from(value: string | boolean[] | number[]) {\r\n\t\tif (typeof value === 'string') {\r\n\t\t\treturn FastBooleanArray.fromString(value);\r\n\t\t}\r\n\r\n\t\treturn FastBooleanArray.fromArray(value);\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AA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AAA;AAAA;AAAA;AAAA;AAAA,EAOA,OACC,UACA,cACI;AACJ,QAAI,cAAc;AAClB,aAAS,IAAI,GAAG,IAAI,KAAK,MAAM,KAAK;AACnC,oBAAc,SAAS,aAAa,KAAK,IAAI,CAAC,GAAG,GAAG,IAAI;AAAA,IACzD;AACA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW;AACV,QAAI,SAAS;AACb,aAAS,IAAI,GAAG,IAAI,KAAK,MAAM,KAAK;AACnC,gBAAU,KAAK,IAAI,CAAC,IAAI,MAAM;AAAA,IAC/B;AACA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,WAAW,OAAe;AAChC,UAAM,QAAQ,IAAI,kBAAiB,MAAM,MAAM;AAC/C,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,YAAM,IAAI,GAAG,MAAM,CAAC,KAAK,GAAG;AAAA,IAC7B;AACA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,UAAU,OAA6B;AAC7C,UAAM,QAAQ,IAAI,kBAAiB,MAAM,MAAM;AAC/C,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,YAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;AAAA,IACxB;AACA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,KAAK,OAAsC;AACjD,QAAI,OAAO,UAAU,UAAU;AAC9B,aAAO,kBAAiB,WAAW,KAAK;AAAA,IACzC;AAEA,WAAO,kBAAiB,UAAU,KAAK;AAAA,EACxC;AACD;","names":[]}
package/dist/index.d.cts CHANGED
@@ -8,7 +8,7 @@ declare class FastBooleanArray {
8
8
  * @param {number} value - The boolean value to set the `index`.
9
9
  * @returns {boolean} The boolean value that was set.
10
10
  */
11
- set(index: number, value: any): boolean;
11
+ set(index: number, value: boolean): boolean;
12
12
  /**
13
13
  * like `set` but throws if the index is out of bounds (less than 0 or greater than or equal to the array size).
14
14
  * @param {number} index - The index to set the boolean value at.
@@ -16,7 +16,12 @@ declare class FastBooleanArray {
16
16
  * @returns {boolean} The boolean value that was set.
17
17
  * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).
18
18
  */
19
- setSafe(index: number, value: any): boolean;
19
+ setSafe(index: number, value: boolean): boolean;
20
+ /**
21
+ * Sets all bits to the specified boolean value.
22
+ * @param {boolean} value - The boolean value to set all bits to.
23
+ */
24
+ setAll(value: boolean): void;
20
25
  /**
21
26
  * Gets a boolean value at the specified index.
22
27
  * @param {number} index - The index to get the boolean value of.
@@ -31,8 +36,78 @@ declare class FastBooleanArray {
31
36
  * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).
32
37
  */
33
38
  getSafe(index: number): boolean;
39
+ /**
40
+ * Resizes the array to a new size, preserving existing data.
41
+ * @param {number} newSize - The new size of the array.
42
+ */
43
+ resize(newSize: number): void;
34
44
  get length(): number;
35
- set length(_value: number);
45
+ /**
46
+ * Compares this FastBooleanArray with another for equality.
47
+ * @param {FastBooleanArray} other - The other FastBooleanArray to compare.
48
+ * @returns {boolean} True if both arrays are equal, false otherwise.
49
+ */
50
+ equals(other: FastBooleanArray): boolean;
51
+ /**
52
+ * Makes the array iterable using `for...of`.
53
+ */
54
+ [Symbol.iterator](): Generator<boolean, void, unknown>;
55
+ /**
56
+ * Converts to a standard JavaScript array.
57
+ */
58
+ toArray(): any[];
59
+ /**
60
+ * Returns a proxy to the FastBooleanArray instance
61
+ * With this you can access indexes like on an actual array.
62
+ */
63
+ accessLikeArray(): this;
64
+ /**
65
+ * Applies a callback function to each element in the array.
66
+ * @param {Function} callback - The function to execute on each element.
67
+ */
68
+ forEach(callback: (value: boolean, index: number, array: FastBooleanArray) => void): void;
69
+ /**
70
+ * Creates a new array with the results of calling a provided function on every element.
71
+ * @param {Function} callback - The function to execute on each element.
72
+ */
73
+ map(callback: (value: boolean, index: number, array: FastBooleanArray) => never): any[];
74
+ /**
75
+ * Creates a new array with all elements that pass the test implemented by the provided function.
76
+ * @param {Function} callback - The function to test each element.
77
+ */
78
+ filter(callback: (value: boolean, index: number, array: FastBooleanArray) => boolean): boolean[];
79
+ /**
80
+ * Tests whether at least one element in the array passes the test implemented by the provided function.
81
+ * @param {Function} callback - The function to test each element.
82
+ */
83
+ some(callback: (value: boolean, index: number, array: FastBooleanArray) => boolean): boolean;
84
+ /**
85
+ * Tests whether all elements in the array pass the test implemented by the provided function.
86
+ * @param {Function} callback - The function to test each element.
87
+ */
88
+ every(callback: (value: boolean, index: number, array: FastBooleanArray) => boolean): boolean;
89
+ /**
90
+ * Reduces the array to a single value by applying a function to each element.
91
+ * @param {Function} callback - The function to execute on each element.
92
+ * @param {any} initialValue - The initial value for the accumulator.
93
+ */
94
+ reduce<T>(callback: (accumulator: T, value: boolean, index: number, array: FastBooleanArray) => T, initialValue: T): T;
95
+ /**
96
+ * Generates a string where every boolean is either a 0 or 1.
97
+ */
98
+ toString(): string;
99
+ /**
100
+ * Returns a FastBooleanArray from .toString() output
101
+ */
102
+ static fromString(value: string): FastBooleanArray;
103
+ /**
104
+ * Returns a FastBooleanArray from a boolean array or number array
105
+ */
106
+ static fromArray(value: boolean[] | number[]): FastBooleanArray;
107
+ /**
108
+ * Returns a FastBooleanArray from a string, boolean array or number array
109
+ */
110
+ static from(value: string | boolean[] | number[]): FastBooleanArray;
36
111
  }
37
112
 
38
113
  export { FastBooleanArray as default };
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ declare class FastBooleanArray {
8
8
  * @param {number} value - The boolean value to set the `index`.
9
9
  * @returns {boolean} The boolean value that was set.
10
10
  */
11
- set(index: number, value: any): boolean;
11
+ set(index: number, value: boolean): boolean;
12
12
  /**
13
13
  * like `set` but throws if the index is out of bounds (less than 0 or greater than or equal to the array size).
14
14
  * @param {number} index - The index to set the boolean value at.
@@ -16,7 +16,12 @@ declare class FastBooleanArray {
16
16
  * @returns {boolean} The boolean value that was set.
17
17
  * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).
18
18
  */
19
- setSafe(index: number, value: any): boolean;
19
+ setSafe(index: number, value: boolean): boolean;
20
+ /**
21
+ * Sets all bits to the specified boolean value.
22
+ * @param {boolean} value - The boolean value to set all bits to.
23
+ */
24
+ setAll(value: boolean): void;
20
25
  /**
21
26
  * Gets a boolean value at the specified index.
22
27
  * @param {number} index - The index to get the boolean value of.
@@ -31,8 +36,78 @@ declare class FastBooleanArray {
31
36
  * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).
32
37
  */
33
38
  getSafe(index: number): boolean;
39
+ /**
40
+ * Resizes the array to a new size, preserving existing data.
41
+ * @param {number} newSize - The new size of the array.
42
+ */
43
+ resize(newSize: number): void;
34
44
  get length(): number;
35
- set length(_value: number);
45
+ /**
46
+ * Compares this FastBooleanArray with another for equality.
47
+ * @param {FastBooleanArray} other - The other FastBooleanArray to compare.
48
+ * @returns {boolean} True if both arrays are equal, false otherwise.
49
+ */
50
+ equals(other: FastBooleanArray): boolean;
51
+ /**
52
+ * Makes the array iterable using `for...of`.
53
+ */
54
+ [Symbol.iterator](): Generator<boolean, void, unknown>;
55
+ /**
56
+ * Converts to a standard JavaScript array.
57
+ */
58
+ toArray(): any[];
59
+ /**
60
+ * Returns a proxy to the FastBooleanArray instance
61
+ * With this you can access indexes like on an actual array.
62
+ */
63
+ accessLikeArray(): this;
64
+ /**
65
+ * Applies a callback function to each element in the array.
66
+ * @param {Function} callback - The function to execute on each element.
67
+ */
68
+ forEach(callback: (value: boolean, index: number, array: FastBooleanArray) => void): void;
69
+ /**
70
+ * Creates a new array with the results of calling a provided function on every element.
71
+ * @param {Function} callback - The function to execute on each element.
72
+ */
73
+ map(callback: (value: boolean, index: number, array: FastBooleanArray) => never): any[];
74
+ /**
75
+ * Creates a new array with all elements that pass the test implemented by the provided function.
76
+ * @param {Function} callback - The function to test each element.
77
+ */
78
+ filter(callback: (value: boolean, index: number, array: FastBooleanArray) => boolean): boolean[];
79
+ /**
80
+ * Tests whether at least one element in the array passes the test implemented by the provided function.
81
+ * @param {Function} callback - The function to test each element.
82
+ */
83
+ some(callback: (value: boolean, index: number, array: FastBooleanArray) => boolean): boolean;
84
+ /**
85
+ * Tests whether all elements in the array pass the test implemented by the provided function.
86
+ * @param {Function} callback - The function to test each element.
87
+ */
88
+ every(callback: (value: boolean, index: number, array: FastBooleanArray) => boolean): boolean;
89
+ /**
90
+ * Reduces the array to a single value by applying a function to each element.
91
+ * @param {Function} callback - The function to execute on each element.
92
+ * @param {any} initialValue - The initial value for the accumulator.
93
+ */
94
+ reduce<T>(callback: (accumulator: T, value: boolean, index: number, array: FastBooleanArray) => T, initialValue: T): T;
95
+ /**
96
+ * Generates a string where every boolean is either a 0 or 1.
97
+ */
98
+ toString(): string;
99
+ /**
100
+ * Returns a FastBooleanArray from .toString() output
101
+ */
102
+ static fromString(value: string): FastBooleanArray;
103
+ /**
104
+ * Returns a FastBooleanArray from a boolean array or number array
105
+ */
106
+ static fromArray(value: boolean[] | number[]): FastBooleanArray;
107
+ /**
108
+ * Returns a FastBooleanArray from a string, boolean array or number array
109
+ */
110
+ static from(value: string | boolean[] | number[]): FastBooleanArray;
36
111
  }
37
112
 
38
113
  export { FastBooleanArray as default };
package/dist/index.js CHANGED
@@ -1,8 +1,11 @@
1
1
  // src/index.ts
2
- var FastBooleanArray = class {
2
+ var FastBooleanArray = class _FastBooleanArray {
3
3
  size;
4
4
  buffer;
5
5
  constructor(size) {
6
+ if (!size) {
7
+ throw new Error("FastBooleanArray must have a size greater than 0");
8
+ }
6
9
  this.size = size;
7
10
  this.buffer = new Uint8Array(Math.ceil(size / 8));
8
11
  }
@@ -34,6 +37,13 @@ var FastBooleanArray = class {
34
37
  }
35
38
  return this.set(index, value);
36
39
  }
40
+ /**
41
+ * Sets all bits to the specified boolean value.
42
+ * @param {boolean} value - The boolean value to set all bits to.
43
+ */
44
+ setAll(value) {
45
+ this.buffer.fill(value ? 255 : 0);
46
+ }
37
47
  /**
38
48
  * Gets a boolean value at the specified index.
39
49
  * @param {number} index - The index to get the boolean value of.
@@ -41,7 +51,7 @@ var FastBooleanArray = class {
41
51
  * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).
42
52
  */
43
53
  get(index) {
44
- return (this.buffer[index >> 3] & 1 << index % 8) !== 0;
54
+ return !!(this.buffer[index >> 3] & 1 << index % 8);
45
55
  }
46
56
  /**
47
57
  * like `get` but throws if the index is out of bounds (less than 0 or greater than or equal to the array size).
@@ -55,11 +65,178 @@ var FastBooleanArray = class {
55
65
  }
56
66
  return this.get(index);
57
67
  }
68
+ /**
69
+ * Resizes the array to a new size, preserving existing data.
70
+ * @param {number} newSize - The new size of the array.
71
+ */
72
+ resize(newSize) {
73
+ const newBuffer = new Uint8Array(Math.ceil(newSize / 8));
74
+ newBuffer.set(this.buffer.subarray(0, Math.min(this.buffer.length, newBuffer.length)));
75
+ this.buffer = newBuffer;
76
+ this.size = newSize;
77
+ }
58
78
  get length() {
59
79
  return this.size;
60
80
  }
61
- set length(_value) {
62
- throw new Error("Setting the length on BooleanArray's is not supported");
81
+ /**
82
+ * Compares this FastBooleanArray with another for equality.
83
+ * @param {FastBooleanArray} other - The other FastBooleanArray to compare.
84
+ * @returns {boolean} True if both arrays are equal, false otherwise.
85
+ */
86
+ equals(other) {
87
+ if (this.size !== other.size) {
88
+ return false;
89
+ }
90
+ return this.buffer.every((byte, i) => byte === other.buffer[i]);
91
+ }
92
+ /**
93
+ * Makes the array iterable using `for...of`.
94
+ */
95
+ *[Symbol.iterator]() {
96
+ for (let i = 0; i < this.size; i++) {
97
+ yield this.get(i);
98
+ }
99
+ }
100
+ /**
101
+ * Converts to a standard JavaScript array.
102
+ */
103
+ toArray() {
104
+ const arr = new Array(this.size);
105
+ for (let i = 0; i < this.size; i++) {
106
+ arr[i] = this.get(i);
107
+ }
108
+ return arr;
109
+ }
110
+ /**
111
+ * Returns a proxy to the FastBooleanArray instance
112
+ * With this you can access indexes like on an actual array.
113
+ */
114
+ accessLikeArray() {
115
+ return new Proxy(this, {
116
+ get: (target, prop) => {
117
+ if (typeof prop === "string" && !isNaN(Number(prop))) {
118
+ const index = Number(prop);
119
+ return target.get(index);
120
+ }
121
+ return target[prop];
122
+ },
123
+ set: (target, prop, value) => {
124
+ if (typeof prop === "string" && !isNaN(Number(prop))) {
125
+ const index = Number(prop);
126
+ return target.set(index, value);
127
+ }
128
+ return target[prop] = value;
129
+ }
130
+ });
131
+ }
132
+ /**
133
+ * Applies a callback function to each element in the array.
134
+ * @param {Function} callback - The function to execute on each element.
135
+ */
136
+ forEach(callback) {
137
+ for (let i = 0; i < this.size; i++) {
138
+ callback(this.get(i), i, this);
139
+ }
140
+ }
141
+ /**
142
+ * Creates a new array with the results of calling a provided function on every element.
143
+ * @param {Function} callback - The function to execute on each element.
144
+ */
145
+ map(callback) {
146
+ const result = new Array(this.size);
147
+ for (let i = 0; i < this.size; i++) {
148
+ result[i] = callback(this.get(i), i, this);
149
+ }
150
+ return result;
151
+ }
152
+ /**
153
+ * Creates a new array with all elements that pass the test implemented by the provided function.
154
+ * @param {Function} callback - The function to test each element.
155
+ */
156
+ filter(callback) {
157
+ const result = [];
158
+ for (let i = 0; i < this.size; i++) {
159
+ const value = this.get(i);
160
+ if (callback(value, i, this)) {
161
+ result.push(value);
162
+ }
163
+ }
164
+ return result;
165
+ }
166
+ /**
167
+ * Tests whether at least one element in the array passes the test implemented by the provided function.
168
+ * @param {Function} callback - The function to test each element.
169
+ */
170
+ some(callback) {
171
+ for (let i = 0; i < this.size; i++) {
172
+ if (callback(this.get(i), i, this)) {
173
+ return true;
174
+ }
175
+ }
176
+ return false;
177
+ }
178
+ /**
179
+ * Tests whether all elements in the array pass the test implemented by the provided function.
180
+ * @param {Function} callback - The function to test each element.
181
+ */
182
+ every(callback) {
183
+ for (let i = 0; i < this.size; i++) {
184
+ if (!callback(this.get(i), i, this)) {
185
+ return false;
186
+ }
187
+ }
188
+ return true;
189
+ }
190
+ /**
191
+ * Reduces the array to a single value by applying a function to each element.
192
+ * @param {Function} callback - The function to execute on each element.
193
+ * @param {any} initialValue - The initial value for the accumulator.
194
+ */
195
+ reduce(callback, initialValue) {
196
+ let accumulator = initialValue;
197
+ for (let i = 0; i < this.size; i++) {
198
+ accumulator = callback(accumulator, this.get(i), i, this);
199
+ }
200
+ return accumulator;
201
+ }
202
+ /**
203
+ * Generates a string where every boolean is either a 0 or 1.
204
+ */
205
+ toString() {
206
+ let result = ``;
207
+ for (let i = 0; i < this.size; i++) {
208
+ result += this.get(i) ? "1" : "0";
209
+ }
210
+ return result;
211
+ }
212
+ /**
213
+ * Returns a FastBooleanArray from .toString() output
214
+ */
215
+ static fromString(value) {
216
+ const array = new _FastBooleanArray(value.length);
217
+ for (let i = 0; i < value.length; i++) {
218
+ array.set(i, value[i] == "1");
219
+ }
220
+ return array;
221
+ }
222
+ /**
223
+ * Returns a FastBooleanArray from a boolean array or number array
224
+ */
225
+ static fromArray(value) {
226
+ const array = new _FastBooleanArray(value.length);
227
+ for (let i = 0; i < value.length; i++) {
228
+ array.set(i, !!value[i]);
229
+ }
230
+ return array;
231
+ }
232
+ /**
233
+ * Returns a FastBooleanArray from a string, boolean array or number array
234
+ */
235
+ static from(value) {
236
+ if (typeof value === "string") {
237
+ return _FastBooleanArray.fromString(value);
238
+ }
239
+ return _FastBooleanArray.fromArray(value);
63
240
  }
64
241
  };
65
242
  export {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export default class FastBooleanArray {\r\n\tpublic size: number;\r\n\tprivate buffer: Uint8Array;\r\n\r\n\tconstructor(size: number) {\r\n\t\tthis.size = size;\r\n\t\tthis.buffer = new Uint8Array(Math.ceil(size / 8)); // Allocate memory\r\n\t}\r\n\r\n\t/**\r\n\t * Sets a boolean value at the specified index.\r\n\t * @param {number} index - The index to set the boolean value at.\r\n\t * @param {number} value - The boolean value to set the `index`.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t */\r\n\tset(index: number, value: any) {\r\n\t\tif (value) {\r\n\t\t\tthis.buffer[index >> 3] |= 1 << (index & 7); // Set bit\r\n\t\t\treturn true;\r\n\t\t} else {\r\n\t\t\tthis.buffer[index >> 3] &= ~(1 << (index & 7)); // Clear bit\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * 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\t * @param {number} index - The index to set the boolean value at.\r\n\t * @param {number} value - The boolean value to set the `index`.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n\t */\r\n\tsetSafe(index: number, value: any) {\r\n\t\tif (index < 0 || index >= this.size) {\r\n\t\t\tthrow new RangeError('Index out of bounds');\r\n\t\t}\r\n\t\treturn this.set(index, value);\r\n\t}\r\n\r\n\t/**\r\n\t * Gets a boolean value at the specified index.\r\n\t * @param {number} index - The index to get the boolean value of.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n\t */\r\n\tget(index: number) {\r\n\t\treturn (this.buffer[index >> 3] & (1 << index % 8)) !== 0; // Check bit\r\n\t}\r\n\r\n\t/**\r\n\t * 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\t * @param {number} index - The index to get the boolean value of.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n\t */\r\n\tgetSafe(index: number) {\r\n\t\tif (index < 0 || index >= this.size) {\r\n\t\t\tthrow new RangeError('Index out of bounds');\r\n\t\t}\r\n\t\treturn this.get(index);\r\n\t}\r\n\r\n\tget length() {\r\n\t\treturn this.size;\r\n\t}\r\n\r\n\tset length(_value: number) {\r\n\t\tthrow new Error(\"Setting the length on BooleanArray's is not supported\");\r\n\t}\r\n}\r\n"],"mappings":";AAAA,IAAqB,mBAArB,MAAsC;AAAA,EAC9B;AAAA,EACC;AAAA,EAER,YAAY,MAAc;AACzB,SAAK,OAAO;AACZ,SAAK,SAAS,IAAI,WAAW,KAAK,KAAK,OAAO,CAAC,CAAC;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,OAAe,OAAY;AAC9B,QAAI,OAAO;AACV,WAAK,OAAO,SAAS,CAAC,KAAK,MAAM,QAAQ;AACzC,aAAO;AAAA,IACR,OAAO;AACN,WAAK,OAAO,SAAS,CAAC,KAAK,EAAE,MAAM,QAAQ;AAC3C,aAAO;AAAA,IACR;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,QAAQ,OAAe,OAAY;AAClC,QAAI,QAAQ,KAAK,SAAS,KAAK,MAAM;AACpC,YAAM,IAAI,WAAW,qBAAqB;AAAA,IAC3C;AACA,WAAO,KAAK,IAAI,OAAO,KAAK;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,OAAe;AAClB,YAAQ,KAAK,OAAO,SAAS,CAAC,IAAK,KAAK,QAAQ,OAAQ;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,QAAQ,OAAe;AACtB,QAAI,QAAQ,KAAK,SAAS,KAAK,MAAM;AACpC,YAAM,IAAI,WAAW,qBAAqB;AAAA,IAC3C;AACA,WAAO,KAAK,IAAI,KAAK;AAAA,EACtB;AAAA,EAEA,IAAI,SAAS;AACZ,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,IAAI,OAAO,QAAgB;AAC1B,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACxE;AACD;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export default class FastBooleanArray {\r\n\tpublic size: number;\r\n\tprivate buffer: Uint8Array;\r\n\r\n\tconstructor(size: number) {\r\n\t\tif (!size) {\r\n\t\t\tthrow new Error('FastBooleanArray must have a size greater than 0');\r\n\t\t}\r\n\t\tthis.size = size;\r\n\t\tthis.buffer = new Uint8Array(Math.ceil(size / 8)); // Allocate memory\r\n\t}\r\n\r\n\t/**\r\n\t * Sets a boolean value at the specified index.\r\n\t * @param {number} index - The index to set the boolean value at.\r\n\t * @param {number} value - The boolean value to set the `index`.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t */\r\n\tset(index: number, value: boolean) {\r\n\t\tif (value) {\r\n\t\t\tthis.buffer[index >> 3] |= 1 << (index & 7); // Set bit\r\n\t\t\treturn true;\r\n\t\t} else {\r\n\t\t\tthis.buffer[index >> 3] &= ~(1 << (index & 7)); // Clear bit\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * 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\t * @param {number} index - The index to set the boolean value at.\r\n\t * @param {number} value - The boolean value to set the `index`.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n\t */\r\n\tsetSafe(index: number, value: boolean) {\r\n\t\tif (index < 0 || index >= this.size) {\r\n\t\t\tthrow new RangeError('Index out of bounds');\r\n\t\t}\r\n\t\treturn this.set(index, value);\r\n\t}\r\n\r\n\t/**\r\n\t * Sets all bits to the specified boolean value.\r\n\t * @param {boolean} value - The boolean value to set all bits to.\r\n\t */\r\n\tsetAll(value: boolean) {\r\n\t\tthis.buffer.fill(value ? 0xff : 0x00);\r\n\t}\r\n\r\n\t/**\r\n\t * Gets a boolean value at the specified index.\r\n\t * @param {number} index - The index to get the boolean value of.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n\t */\r\n\tget(index: number) {\r\n\t\treturn !!(this.buffer[index >> 3] & (1 << index % 8)); // Check bit\r\n\t}\r\n\r\n\t/**\r\n\t * 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\t * @param {number} index - The index to get the boolean value of.\r\n\t * @returns {boolean} The boolean value that was set.\r\n\t * @throws {RangeError} If the index is out of bounds (less than 0 or greater than or equal to the array size).\r\n\t */\r\n\tgetSafe(index: number) {\r\n\t\tif (index < 0 || index >= this.size) {\r\n\t\t\tthrow new RangeError('Index out of bounds');\r\n\t\t}\r\n\t\treturn this.get(index);\r\n\t}\r\n\r\n\t/**\r\n\t * Resizes the array to a new size, preserving existing data.\r\n\t * @param {number} newSize - The new size of the array.\r\n\t */\r\n\tresize(newSize: number) {\r\n\t\tconst newBuffer = new Uint8Array(Math.ceil(newSize / 8));\r\n\t\tnewBuffer.set(this.buffer.subarray(0, Math.min(this.buffer.length, newBuffer.length)));\r\n\t\tthis.buffer = newBuffer;\r\n\t\tthis.size = newSize;\r\n\t}\r\n\r\n\tget length() {\r\n\t\treturn this.size;\r\n\t}\r\n\r\n\t/**\r\n\t * Compares this FastBooleanArray with another for equality.\r\n\t * @param {FastBooleanArray} other - The other FastBooleanArray to compare.\r\n\t * @returns {boolean} True if both arrays are equal, false otherwise.\r\n\t */\r\n\tequals(other: FastBooleanArray) {\r\n\t\tif (this.size !== other.size) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\treturn this.buffer.every((byte, i) => byte === other.buffer[i]);\r\n\t}\r\n\r\n\t/**\r\n\t * Makes the array iterable using `for...of`.\r\n\t */\r\n\t*[Symbol.iterator]() {\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tyield this.get(i);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Converts to a standard JavaScript array.\r\n\t */\r\n\ttoArray() {\r\n\t\tconst arr = new Array(this.size);\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tarr[i] = this.get(i);\r\n\t\t}\r\n\t\treturn arr;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a proxy to the FastBooleanArray instance\r\n\t * With this you can access indexes like on an actual array.\r\n\t */\r\n\taccessLikeArray() {\r\n\t\treturn new Proxy(this, {\r\n\t\t\tget: (target, prop) => {\r\n\t\t\t\tif (typeof prop === 'string' && !isNaN(Number(prop))) {\r\n\t\t\t\t\tconst index = Number(prop);\r\n\t\t\t\t\treturn target.get(index);\r\n\t\t\t\t}\r\n\t\t\t\treturn target[prop as keyof FastBooleanArray];\r\n\t\t\t},\r\n\t\t\tset: (target, prop, value) => {\r\n\t\t\t\tif (typeof prop === 'string' && !isNaN(Number(prop))) {\r\n\t\t\t\t\tconst index = Number(prop);\r\n\t\t\t\t\treturn target.set(index, value as never);\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn (target[prop as Exclude<keyof FastBooleanArray, 'length'>] = value);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Applies a callback function to each element in the array.\r\n\t * @param {Function} callback - The function to execute on each element.\r\n\t */\r\n\tforEach(callback: (value: boolean, index: number, array: FastBooleanArray) => void) {\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tcallback(this.get(i), i, this);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a new array with the results of calling a provided function on every element.\r\n\t * @param {Function} callback - The function to execute on each element.\r\n\t */\r\n\tmap(callback: (value: boolean, index: number, array: FastBooleanArray) => never) {\r\n\t\tconst result = new Array(this.size);\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tresult[i] = callback(this.get(i), i, this);\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a new array with all elements that pass the test implemented by the provided function.\r\n\t * @param {Function} callback - The function to test each element.\r\n\t */\r\n\tfilter(callback: (value: boolean, index: number, array: FastBooleanArray) => boolean) {\r\n\t\tconst result: boolean[] = [];\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tconst value = this.get(i);\r\n\t\t\tif (callback(value, i, this)) {\r\n\t\t\t\tresult.push(value);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/**\r\n\t * Tests whether at least one element in the array passes the test implemented by the provided function.\r\n\t * @param {Function} callback - The function to test each element.\r\n\t */\r\n\tsome(callback: (value: boolean, index: number, array: FastBooleanArray) => boolean) {\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tif (callback(this.get(i), i, this)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t}\r\n\r\n\t/**\r\n\t * Tests whether all elements in the array pass the test implemented by the provided function.\r\n\t * @param {Function} callback - The function to test each element.\r\n\t */\r\n\tevery(callback: (value: boolean, index: number, array: FastBooleanArray) => boolean) {\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tif (!callback(this.get(i), i, this)) {\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn true;\r\n\t}\r\n\r\n\t/**\r\n\t * Reduces the array to a single value by applying a function to each element.\r\n\t * @param {Function} callback - The function to execute on each element.\r\n\t * @param {any} initialValue - The initial value for the accumulator.\r\n\t */\r\n\treduce<T>(\r\n\t\tcallback: (accumulator: T, value: boolean, index: number, array: FastBooleanArray) => T,\r\n\t\tinitialValue: T\r\n\t): T {\r\n\t\tlet accumulator = initialValue;\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\taccumulator = callback(accumulator, this.get(i), i, this);\r\n\t\t}\r\n\t\treturn accumulator;\r\n\t}\r\n\r\n\t/**\r\n\t * Generates a string where every boolean is either a 0 or 1.\r\n\t */\r\n\ttoString() {\r\n\t\tlet result = ``;\r\n\t\tfor (let i = 0; i < this.size; i++) {\r\n\t\t\tresult += this.get(i) ? '1' : '0';\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a FastBooleanArray from .toString() output\r\n\t */\r\n\tstatic fromString(value: string) {\r\n\t\tconst array = new FastBooleanArray(value.length);\r\n\t\tfor (let i = 0; i < value.length; i++) {\r\n\t\t\tarray.set(i, value[i] == '1');\r\n\t\t}\r\n\t\treturn array;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a FastBooleanArray from a boolean array or number array\r\n\t */\r\n\tstatic fromArray(value: boolean[] | number[]) {\r\n\t\tconst array = new FastBooleanArray(value.length);\r\n\t\tfor (let i = 0; i < value.length; i++) {\r\n\t\t\tarray.set(i, !!value[i]);\r\n\t\t}\r\n\t\treturn array;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a FastBooleanArray from a string, boolean array or number array\r\n\t */\r\n\tstatic from(value: string | boolean[] | number[]) {\r\n\t\tif (typeof value === 'string') {\r\n\t\t\treturn FastBooleanArray.fromString(value);\r\n\t\t}\r\n\r\n\t\treturn FastBooleanArray.fromArray(value);\r\n\t}\r\n}\r\n"],"mappings":";AAAA,IAAqB,mBAArB,MAAqB,kBAAiB;AAAA,EAC9B;AAAA,EACC;AAAA,EAER,YAAY,MAAc;AACzB,QAAI,CAAC,MAAM;AACV,YAAM,IAAI,MAAM,kDAAkD;AAAA,IACnE;AACA,SAAK,OAAO;AACZ,SAAK,SAAS,IAAI,WAAW,KAAK,KAAK,OAAO,CAAC,CAAC;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,OAAe,OAAgB;AAClC,QAAI,OAAO;AACV,WAAK,OAAO,SAAS,CAAC,KAAK,MAAM,QAAQ;AACzC,aAAO;AAAA,IACR,OAAO;AACN,WAAK,OAAO,SAAS,CAAC,KAAK,EAAE,MAAM,QAAQ;AAC3C,aAAO;AAAA,IACR;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,QAAQ,OAAe,OAAgB;AACtC,QAAI,QAAQ,KAAK,SAAS,KAAK,MAAM;AACpC,YAAM,IAAI,WAAW,qBAAqB;AAAA,IAC3C;AACA,WAAO,KAAK,IAAI,OAAO,KAAK;AAA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AAM,MAAM;AAC/C,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,YAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;AAAA,IACxB;AACA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,KAAK,OAAsC;AACjD,QAAI,OAAO,UAAU,UAAU;AAC9B,aAAO,kBAAiB,WAAW,KAAK;AAAA,IACzC;AAEA,WAAO,kBAAiB,UAAU,KAAK;AAAA,EACxC;AACD;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-boolean-array",
3
- "version": "1.3.4",
3
+ "version": "1.4.0",
4
4
  "homepage": "https://github.com/UltraCakeBakery/FastBooleanArray",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,6 +43,7 @@
43
43
  "node": ">=0.10.3"
44
44
  },
45
45
  "devDependencies": {
46
+ "@types/node": "^22.10.2",
46
47
  "tsup": "^8.3.5"
47
48
  }
48
49
  }