fast-boolean-array 1.3.4 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -53
- package/dist/index.cjs +183 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -3
- package/dist/index.d.ts +78 -3
- package/dist/index.js +183 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ Gets the boolean value at the specified index.
|
|
|
89
89
|
|
|
90
90
|
---
|
|
91
91
|
|
|
92
|
-
#
|
|
92
|
+
# Performance Breakdown
|
|
93
93
|
|
|
94
94
|
Our benchmark compares the performance of our Fast Boolean Array library against Vanilla JavaScript arrays in terms of get and set operations across varying numbers of Booleans. The results below reflect an updated benchmark algorithm that performs 1,000 runs for each x amount of Booleans to better simulate real-world scenarios.
|
|
95
95
|
|
|
@@ -97,90 +97,113 @@ Our benchmark compares the performance of our Fast Boolean Array library against
|
|
|
97
97
|
|
|
98
98
|
### 1 Boolean
|
|
99
99
|
|
|
100
|
-
| Test | Time (ms)
|
|
101
|
-
| ---------------------- |
|
|
102
|
-
| Set Vanilla Array | 0.
|
|
103
|
-
| Set Fast Boolean Array | 0.
|
|
104
|
-
| Get Vanilla Array | 0.
|
|
105
|
-
| Get Fast Boolean Array | 0.
|
|
100
|
+
| Test | Time (ms) | Memory (Bytes) | Booleans |
|
|
101
|
+
| ---------------------- | ---------- | -------------- | -------- |
|
|
102
|
+
| Set Vanilla Array | 0.00236000 | 8 | 1 |
|
|
103
|
+
| Set Fast Boolean Array | 0.00423000 | 6 | 1 |
|
|
104
|
+
| Get Vanilla Array | 0.00053000 | N/A | 1 |
|
|
105
|
+
| Get Fast Boolean Array | 0.00291000 | N/A | 1 |
|
|
106
106
|
|
|
107
|
-
**Observation:**
|
|
107
|
+
**Observation:** As useless as having just 1 boolean stored in an array might be, For **1 boolean**, the **Fast Boolean Array** is **1.8x slower** for **Set** and **5.5x slower** for **Get** operations. Memory usage is nearly identical, with a small advantage for the **Fast Boolean Array** in terms of bytes.
|
|
108
|
+
|
|
109
|
+
---
|
|
108
110
|
|
|
109
111
|
### 100 Booleans
|
|
110
112
|
|
|
111
|
-
| Test | Time (ms)
|
|
112
|
-
| ---------------------- |
|
|
113
|
-
| Set Vanilla Array | 0.
|
|
114
|
-
| Set Fast Boolean Array | 0.
|
|
115
|
-
| Get Vanilla Array | 0.
|
|
116
|
-
| Get Fast Boolean Array | 0.
|
|
113
|
+
| Test | Time (ms) | Memory (Bytes) | Booleans |
|
|
114
|
+
| ---------------------- | ---------- | -------------- | -------- |
|
|
115
|
+
| Set Vanilla Array | 0.00332000 | 107 | 100 |
|
|
116
|
+
| Set Fast Boolean Array | 0.00824000 | 18 | 100 |
|
|
117
|
+
| Get Vanilla Array | 0.00149000 | N/A | 100 |
|
|
118
|
+
| Get Fast Boolean Array | 0.00581000 | N/A | 100 |
|
|
117
119
|
|
|
118
|
-
**Observation:**
|
|
120
|
+
**Observation:** For **100 booleans**, **Fast Boolean Array** is **2.5x slower** in **Set** operations but **3.9x more memory efficient**. However, **Fast Boolean Array**'s' **Get** operation is **3.9x slower** . compared to the **Vanilla Array**.
|
|
121
|
+
|
|
122
|
+
---
|
|
119
123
|
|
|
120
124
|
### 1,000 Booleans
|
|
121
125
|
|
|
122
|
-
| Test | Time (ms)
|
|
123
|
-
| ---------------------- |
|
|
124
|
-
| Set Vanilla Array | 0.
|
|
125
|
-
| Set Fast Boolean Array | 0.
|
|
126
|
-
| Get Vanilla Array | 0.
|
|
127
|
-
| Get Fast Boolean Array | 0.
|
|
126
|
+
| Test | Time (ms) | Memory (Bytes) | Booleans |
|
|
127
|
+
| ---------------------- | ---------- | -------------- | -------- |
|
|
128
|
+
| Set Vanilla Array | 0.09599000 | 1009 | 1000 |
|
|
129
|
+
| Set Fast Boolean Array | 0.04467000 | 130 | 1000 |
|
|
130
|
+
| Get Vanilla Array | 0.01261000 | N/A | 1000 |
|
|
131
|
+
| Get Fast Boolean Array | 0.05476000 | N/A | 1000 |
|
|
128
132
|
|
|
129
|
-
**Observation:**
|
|
133
|
+
**Observation:** For **1,000 booleans**, **Fast Boolean Array** is **2.1x faster** for **Set** operations and uses **7.7x less memory**. However, **Fast Boolean Array**'s' **Get** operation is **4.3x slower** . compared to the **Vanilla Array**.
|
|
134
|
+
|
|
135
|
+
---
|
|
130
136
|
|
|
131
137
|
### 10,000 Booleans
|
|
132
138
|
|
|
133
|
-
| Test | Time (ms)
|
|
134
|
-
| ---------------------- |
|
|
135
|
-
| Set Vanilla Array | 0.
|
|
136
|
-
| Set Fast Boolean Array | 0.
|
|
137
|
-
| Get Vanilla Array | 0.
|
|
138
|
-
| Get Fast Boolean Array | 0.
|
|
139
|
+
| Test | Time (ms) | Memory (Bytes) | Booleans |
|
|
140
|
+
| ---------------------- | ---------- | -------------- | -------- |
|
|
141
|
+
| Set Vanilla Array | 0.30075000 | 10009 | 10000 |
|
|
142
|
+
| Set Fast Boolean Array | 0.04225000 | 1256 | 10000 |
|
|
143
|
+
| Get Vanilla Array | 0.06054000 | N/A | 10000 |
|
|
144
|
+
| Get Fast Boolean Array | 0.12325000 | N/A | 10000 |
|
|
145
|
+
|
|
146
|
+
**Observation:** For **10,000 booleans**, **Fast Boolean Array** is **7.1x faster** in **Set** operations and uses **8x less memory**. However, **Fast Boolean Array**'s' **Get** operation is **2x slower** . compared to the **Vanilla Array**.
|
|
139
147
|
|
|
140
|
-
|
|
148
|
+
---
|
|
141
149
|
|
|
142
150
|
### 100,000 Booleans
|
|
143
151
|
|
|
144
|
-
| Test | Time (ms)
|
|
145
|
-
| ---------------------- |
|
|
146
|
-
| Set Vanilla Array | 1.
|
|
147
|
-
| Set Fast Boolean Array | 0.
|
|
148
|
-
| Get Vanilla Array | 0.
|
|
149
|
-
| Get Fast Boolean Array | 0.
|
|
152
|
+
| Test | Time (ms) | Memory (Bytes) | Booleans |
|
|
153
|
+
| ---------------------- | ---------- | -------------- | -------- |
|
|
154
|
+
| Set Vanilla Array | 1.67949000 | 100011 | 100000 |
|
|
155
|
+
| Set Fast Boolean Array | 0.15400000 | 12506 | 100000 |
|
|
156
|
+
| Get Vanilla Array | 0.04920000 | N/A | 100000 |
|
|
157
|
+
| Get Fast Boolean Array | 0.07523000 | N/A | 100000 |
|
|
158
|
+
|
|
159
|
+
**Observation:** For **100,000 booleans**, **Fast Boolean Array** is **10.9x faster** in **Set** operations and uses **8x less memory**. However, **Fast Boolean Array**'s' **Get** operation is **1.5x slower** .
|
|
150
160
|
|
|
151
|
-
|
|
161
|
+
---
|
|
152
162
|
|
|
153
163
|
### 1,000,000 Booleans
|
|
154
164
|
|
|
155
|
-
| Test | Time (ms)
|
|
156
|
-
| ---------------------- |
|
|
157
|
-
| Set Vanilla Array |
|
|
158
|
-
| Set Fast Boolean Array |
|
|
159
|
-
| Get Vanilla Array | 0.
|
|
160
|
-
| Get Fast Boolean Array | 0.
|
|
165
|
+
| Test | Time (ms) | Memory (Bytes) | Booleans |
|
|
166
|
+
| ---------------------- | ----------- | -------------- | -------- |
|
|
167
|
+
| Set Vanilla Array | 20.07889000 | 1000011 | 1000000 |
|
|
168
|
+
| Set Fast Boolean Array | 3.42817000 | 125007 | 1000000 |
|
|
169
|
+
| Get Vanilla Array | 0.49531000 | N/A | 1000000 |
|
|
170
|
+
| Get Fast Boolean Array | 0.74617000 | N/A | 1000000 |
|
|
171
|
+
|
|
172
|
+
**Observation:** For **1,000,000 booleans**, the **Fast Boolean Array** is **5.9x faster** for **Set** operations and uses **8x less memory**. However, **Fast Boolean Array**'s' **Get** operation is **1.5x slower** .
|
|
161
173
|
|
|
162
|
-
|
|
174
|
+
---
|
|
163
175
|
|
|
164
176
|
### 10,000,000 Booleans
|
|
165
177
|
|
|
166
|
-
| Test | Time (ms)
|
|
167
|
-
| ---------------------- |
|
|
168
|
-
| Set Vanilla Array |
|
|
169
|
-
| Set Fast Boolean Array |
|
|
170
|
-
| Get Vanilla Array | 4.
|
|
171
|
-
| Get Fast Boolean Array | 7.
|
|
178
|
+
| Test | Time (ms) | Memory (Bytes) | Booleans |
|
|
179
|
+
| ---------------------- | ------------ | -------------- | -------- |
|
|
180
|
+
| Set Vanilla Array | 266.65778000 | 10000013 | 10000000 |
|
|
181
|
+
| Set Fast Boolean Array | 35.53492000 | 1250007 | 10000000 |
|
|
182
|
+
| Get Vanilla Array | 4.90792000 | N/A | 10000000 |
|
|
183
|
+
| Get Fast Boolean Array | 7.57038000 | N/A | 10000000 |
|
|
172
184
|
|
|
173
|
-
**Observation:**
|
|
185
|
+
**Observation:** For **10,000,000 booleans**, **Fast Boolean Array** is **7.5x faster** for **Set** operations and uses **8x less memory**. However, **Fast Boolean Array**'s' **Get** operation is **1.5x slower** .
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
### Summary
|
|
190
|
+
|
|
191
|
+
- The **Fast Boolean Array** is significantly more efficient in terms of memory usage and **Set** operation speeds, particularly as the number of booleans increases.
|
|
192
|
+
- For example, at **10,000,000 booleans**, it is **7.5x faster** in **Set** operations and uses **8x less memory**.
|
|
193
|
+
- The **Get** operation, however, tends to be slower for the **Fast Boolean Array**, with it being up to **1.5x slower** compared to the **Vanilla Array** in larger datasets.
|
|
194
|
+
- If memory efficiency and **Set** performance are priorities, the **Fast Boolean Array** is clearly advantageous, but if **Get** performance is more important, the **Vanilla Array** may still offer better results for certain use cases.
|
|
195
|
+
|
|
196
|
+
---
|
|
174
197
|
|
|
175
|
-
|
|
198
|
+
# Why not use BigInt or larger array?
|
|
176
199
|
|
|
177
|
-
|
|
200
|
+
Backwards compatibility with older version of NodeJS and browsers.
|
|
178
201
|
|
|
179
202
|
---
|
|
180
203
|
|
|
181
204
|
## Contributing
|
|
182
205
|
|
|
183
|
-
Contributions are welcome! If you'd like to report a bug, suggest a feature, or submit a pull request, please visit the [GitHub repository](https://github.com/
|
|
206
|
+
Contributions are welcome! If you'd like to report a bug, suggest a feature, or submit a pull request, please visit the [GitHub repository](https://github.com/ultracakebakery/FastBooleanArray).
|
|
184
207
|
|
|
185
208
|
---
|
|
186
209
|
|
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,9 @@ 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
|
-
|
|
78
|
+
const byteIndex = index >>> 3;
|
|
79
|
+
const bitIndex = index & 7;
|
|
80
|
+
return (this.buffer[byteIndex] & 1 << bitIndex) !== 0;
|
|
69
81
|
}
|
|
70
82
|
/**
|
|
71
83
|
* 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 +91,178 @@ var FastBooleanArray = class {
|
|
|
79
91
|
}
|
|
80
92
|
return this.get(index);
|
|
81
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Resizes the array to a new size, preserving existing data.
|
|
96
|
+
* @param {number} newSize - The new size of the array.
|
|
97
|
+
*/
|
|
98
|
+
resize(newSize) {
|
|
99
|
+
const newBuffer = new Uint8Array(Math.ceil(newSize / 8));
|
|
100
|
+
newBuffer.set(this.buffer.subarray(0, Math.min(this.buffer.length, newBuffer.length)));
|
|
101
|
+
this.buffer = newBuffer;
|
|
102
|
+
this.size = newSize;
|
|
103
|
+
}
|
|
82
104
|
get length() {
|
|
83
105
|
return this.size;
|
|
84
106
|
}
|
|
85
|
-
|
|
86
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Compares this FastBooleanArray with another for equality.
|
|
109
|
+
* @param {FastBooleanArray} other - The other FastBooleanArray to compare.
|
|
110
|
+
* @returns {boolean} True if both arrays are equal, false otherwise.
|
|
111
|
+
*/
|
|
112
|
+
equals(other) {
|
|
113
|
+
if (this.size !== other.size) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return this.buffer.every((byte, i) => byte === other.buffer[i]);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Makes the array iterable using `for...of`.
|
|
120
|
+
*/
|
|
121
|
+
*[Symbol.iterator]() {
|
|
122
|
+
for (let i = 0; i < this.size; i++) {
|
|
123
|
+
yield this.get(i);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Converts to a standard JavaScript array.
|
|
128
|
+
*/
|
|
129
|
+
toArray() {
|
|
130
|
+
const arr = new Array(this.size);
|
|
131
|
+
for (let i = 0; i < this.size; i++) {
|
|
132
|
+
arr[i] = this.get(i);
|
|
133
|
+
}
|
|
134
|
+
return arr;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Returns a proxy to the FastBooleanArray instance
|
|
138
|
+
* With this you can access indexes like on an actual array.
|
|
139
|
+
*/
|
|
140
|
+
accessLikeArray() {
|
|
141
|
+
return new Proxy(this, {
|
|
142
|
+
get: (target, prop) => {
|
|
143
|
+
if (typeof prop === "string" && !isNaN(Number(prop))) {
|
|
144
|
+
const index = Number(prop);
|
|
145
|
+
return target.get(index);
|
|
146
|
+
}
|
|
147
|
+
return target[prop];
|
|
148
|
+
},
|
|
149
|
+
set: (target, prop, value) => {
|
|
150
|
+
if (typeof prop === "string" && !isNaN(Number(prop))) {
|
|
151
|
+
const index = Number(prop);
|
|
152
|
+
return target.set(index, value);
|
|
153
|
+
}
|
|
154
|
+
return target[prop] = value;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Applies a callback function to each element in the array.
|
|
160
|
+
* @param {Function} callback - The function to execute on each element.
|
|
161
|
+
*/
|
|
162
|
+
forEach(callback) {
|
|
163
|
+
for (let i = 0; i < this.size; i++) {
|
|
164
|
+
callback(this.get(i), i, this);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Creates a new array with the results of calling a provided function on every element.
|
|
169
|
+
* @param {Function} callback - The function to execute on each element.
|
|
170
|
+
*/
|
|
171
|
+
map(callback) {
|
|
172
|
+
const result = new Array(this.size);
|
|
173
|
+
for (let i = 0; i < this.size; i++) {
|
|
174
|
+
result[i] = callback(this.get(i), i, this);
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Creates a new array with all elements that pass the test implemented by the provided function.
|
|
180
|
+
* @param {Function} callback - The function to test each element.
|
|
181
|
+
*/
|
|
182
|
+
filter(callback) {
|
|
183
|
+
const result = [];
|
|
184
|
+
for (let i = 0; i < this.size; i++) {
|
|
185
|
+
const value = this.get(i);
|
|
186
|
+
if (callback(value, i, this)) {
|
|
187
|
+
result.push(value);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Tests whether at least one element in the array passes the test implemented by the provided function.
|
|
194
|
+
* @param {Function} callback - The function to test each element.
|
|
195
|
+
*/
|
|
196
|
+
some(callback) {
|
|
197
|
+
for (let i = 0; i < this.size; i++) {
|
|
198
|
+
if (callback(this.get(i), i, this)) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Tests whether all elements in the array pass the test implemented by the provided function.
|
|
206
|
+
* @param {Function} callback - The function to test each element.
|
|
207
|
+
*/
|
|
208
|
+
every(callback) {
|
|
209
|
+
for (let i = 0; i < this.size; i++) {
|
|
210
|
+
if (!callback(this.get(i), i, this)) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Reduces the array to a single value by applying a function to each element.
|
|
218
|
+
* @param {Function} callback - The function to execute on each element.
|
|
219
|
+
* @param {any} initialValue - The initial value for the accumulator.
|
|
220
|
+
*/
|
|
221
|
+
reduce(callback, initialValue) {
|
|
222
|
+
let accumulator = initialValue;
|
|
223
|
+
for (let i = 0; i < this.size; i++) {
|
|
224
|
+
accumulator = callback(accumulator, this.get(i), i, this);
|
|
225
|
+
}
|
|
226
|
+
return accumulator;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Generates a string where every boolean is either a 0 or 1.
|
|
230
|
+
*/
|
|
231
|
+
toString() {
|
|
232
|
+
let result = ``;
|
|
233
|
+
for (let i = 0; i < this.size; i++) {
|
|
234
|
+
result += this.get(i) ? "1" : "0";
|
|
235
|
+
}
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Returns a FastBooleanArray from .toString() output
|
|
240
|
+
*/
|
|
241
|
+
static fromString(value) {
|
|
242
|
+
const array = new _FastBooleanArray(value.length);
|
|
243
|
+
for (let i = 0; i < value.length; i++) {
|
|
244
|
+
array.set(i, value[i] == "1");
|
|
245
|
+
}
|
|
246
|
+
return array;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Returns a FastBooleanArray from a boolean array or number array
|
|
250
|
+
*/
|
|
251
|
+
static fromArray(value) {
|
|
252
|
+
const array = new _FastBooleanArray(value.length);
|
|
253
|
+
for (let i = 0; i < value.length; i++) {
|
|
254
|
+
array.set(i, !!value[i]);
|
|
255
|
+
}
|
|
256
|
+
return array;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Returns a FastBooleanArray from a string, boolean array or number array
|
|
260
|
+
*/
|
|
261
|
+
static from(value) {
|
|
262
|
+
if (typeof value === "string") {
|
|
263
|
+
return _FastBooleanArray.fromString(value);
|
|
264
|
+
}
|
|
265
|
+
return _FastBooleanArray.fromArray(value);
|
|
87
266
|
}
|
|
88
267
|
};
|
|
89
268
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.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;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\tconst byteIndex = index >>> 3; // index divided by 8 (shifted)\r\n\t\tconst bitIndex = index & 7; // index modulo 8 (masking)\r\n\t\treturn (this.buffer[byteIndex] & (1 << bitIndex)) !== 0; // Direct comparison is faster than double negation !!\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;AAAA;AAAA;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;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,OAAgB;AACtB,SAAK,OAAO,KAAK,QAAQ,MAAO,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tC,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:
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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,9 @@ 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
|
-
|
|
54
|
+
const byteIndex = index >>> 3;
|
|
55
|
+
const bitIndex = index & 7;
|
|
56
|
+
return (this.buffer[byteIndex] & 1 << bitIndex) !== 0;
|
|
45
57
|
}
|
|
46
58
|
/**
|
|
47
59
|
* 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 +67,178 @@ var FastBooleanArray = class {
|
|
|
55
67
|
}
|
|
56
68
|
return this.get(index);
|
|
57
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Resizes the array to a new size, preserving existing data.
|
|
72
|
+
* @param {number} newSize - The new size of the array.
|
|
73
|
+
*/
|
|
74
|
+
resize(newSize) {
|
|
75
|
+
const newBuffer = new Uint8Array(Math.ceil(newSize / 8));
|
|
76
|
+
newBuffer.set(this.buffer.subarray(0, Math.min(this.buffer.length, newBuffer.length)));
|
|
77
|
+
this.buffer = newBuffer;
|
|
78
|
+
this.size = newSize;
|
|
79
|
+
}
|
|
58
80
|
get length() {
|
|
59
81
|
return this.size;
|
|
60
82
|
}
|
|
61
|
-
|
|
62
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Compares this FastBooleanArray with another for equality.
|
|
85
|
+
* @param {FastBooleanArray} other - The other FastBooleanArray to compare.
|
|
86
|
+
* @returns {boolean} True if both arrays are equal, false otherwise.
|
|
87
|
+
*/
|
|
88
|
+
equals(other) {
|
|
89
|
+
if (this.size !== other.size) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return this.buffer.every((byte, i) => byte === other.buffer[i]);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Makes the array iterable using `for...of`.
|
|
96
|
+
*/
|
|
97
|
+
*[Symbol.iterator]() {
|
|
98
|
+
for (let i = 0; i < this.size; i++) {
|
|
99
|
+
yield this.get(i);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Converts to a standard JavaScript array.
|
|
104
|
+
*/
|
|
105
|
+
toArray() {
|
|
106
|
+
const arr = new Array(this.size);
|
|
107
|
+
for (let i = 0; i < this.size; i++) {
|
|
108
|
+
arr[i] = this.get(i);
|
|
109
|
+
}
|
|
110
|
+
return arr;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Returns a proxy to the FastBooleanArray instance
|
|
114
|
+
* With this you can access indexes like on an actual array.
|
|
115
|
+
*/
|
|
116
|
+
accessLikeArray() {
|
|
117
|
+
return new Proxy(this, {
|
|
118
|
+
get: (target, prop) => {
|
|
119
|
+
if (typeof prop === "string" && !isNaN(Number(prop))) {
|
|
120
|
+
const index = Number(prop);
|
|
121
|
+
return target.get(index);
|
|
122
|
+
}
|
|
123
|
+
return target[prop];
|
|
124
|
+
},
|
|
125
|
+
set: (target, prop, value) => {
|
|
126
|
+
if (typeof prop === "string" && !isNaN(Number(prop))) {
|
|
127
|
+
const index = Number(prop);
|
|
128
|
+
return target.set(index, value);
|
|
129
|
+
}
|
|
130
|
+
return target[prop] = value;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Applies a callback function to each element in the array.
|
|
136
|
+
* @param {Function} callback - The function to execute on each element.
|
|
137
|
+
*/
|
|
138
|
+
forEach(callback) {
|
|
139
|
+
for (let i = 0; i < this.size; i++) {
|
|
140
|
+
callback(this.get(i), i, this);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Creates a new array with the results of calling a provided function on every element.
|
|
145
|
+
* @param {Function} callback - The function to execute on each element.
|
|
146
|
+
*/
|
|
147
|
+
map(callback) {
|
|
148
|
+
const result = new Array(this.size);
|
|
149
|
+
for (let i = 0; i < this.size; i++) {
|
|
150
|
+
result[i] = callback(this.get(i), i, this);
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Creates a new array with all elements that pass the test implemented by the provided function.
|
|
156
|
+
* @param {Function} callback - The function to test each element.
|
|
157
|
+
*/
|
|
158
|
+
filter(callback) {
|
|
159
|
+
const result = [];
|
|
160
|
+
for (let i = 0; i < this.size; i++) {
|
|
161
|
+
const value = this.get(i);
|
|
162
|
+
if (callback(value, i, this)) {
|
|
163
|
+
result.push(value);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Tests whether at least one element in the array passes the test implemented by the provided function.
|
|
170
|
+
* @param {Function} callback - The function to test each element.
|
|
171
|
+
*/
|
|
172
|
+
some(callback) {
|
|
173
|
+
for (let i = 0; i < this.size; i++) {
|
|
174
|
+
if (callback(this.get(i), i, this)) {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Tests whether all elements in the array pass the test implemented by the provided function.
|
|
182
|
+
* @param {Function} callback - The function to test each element.
|
|
183
|
+
*/
|
|
184
|
+
every(callback) {
|
|
185
|
+
for (let i = 0; i < this.size; i++) {
|
|
186
|
+
if (!callback(this.get(i), i, this)) {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Reduces the array to a single value by applying a function to each element.
|
|
194
|
+
* @param {Function} callback - The function to execute on each element.
|
|
195
|
+
* @param {any} initialValue - The initial value for the accumulator.
|
|
196
|
+
*/
|
|
197
|
+
reduce(callback, initialValue) {
|
|
198
|
+
let accumulator = initialValue;
|
|
199
|
+
for (let i = 0; i < this.size; i++) {
|
|
200
|
+
accumulator = callback(accumulator, this.get(i), i, this);
|
|
201
|
+
}
|
|
202
|
+
return accumulator;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Generates a string where every boolean is either a 0 or 1.
|
|
206
|
+
*/
|
|
207
|
+
toString() {
|
|
208
|
+
let result = ``;
|
|
209
|
+
for (let i = 0; i < this.size; i++) {
|
|
210
|
+
result += this.get(i) ? "1" : "0";
|
|
211
|
+
}
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Returns a FastBooleanArray from .toString() output
|
|
216
|
+
*/
|
|
217
|
+
static fromString(value) {
|
|
218
|
+
const array = new _FastBooleanArray(value.length);
|
|
219
|
+
for (let i = 0; i < value.length; i++) {
|
|
220
|
+
array.set(i, value[i] == "1");
|
|
221
|
+
}
|
|
222
|
+
return array;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Returns a FastBooleanArray from a boolean array or number array
|
|
226
|
+
*/
|
|
227
|
+
static fromArray(value) {
|
|
228
|
+
const array = new _FastBooleanArray(value.length);
|
|
229
|
+
for (let i = 0; i < value.length; i++) {
|
|
230
|
+
array.set(i, !!value[i]);
|
|
231
|
+
}
|
|
232
|
+
return array;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Returns a FastBooleanArray from a string, boolean array or number array
|
|
236
|
+
*/
|
|
237
|
+
static from(value) {
|
|
238
|
+
if (typeof value === "string") {
|
|
239
|
+
return _FastBooleanArray.fromString(value);
|
|
240
|
+
}
|
|
241
|
+
return _FastBooleanArray.fromArray(value);
|
|
63
242
|
}
|
|
64
243
|
};
|
|
65
244
|
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\tconst byteIndex = index >>> 3; // index divided by 8 (shifted)\r\n\t\tconst bitIndex = index & 7; // index modulo 8 (masking)\r\n\t\treturn (this.buffer[byteIndex] & (1 << bitIndex)) !== 0; // Direct comparison is faster than double negation !!\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;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,OAAgB;AACtB,SAAK,OAAO,KAAK,QAAQ,MAAO,CAAI;AAAA,EACrC;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AG,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
|
+
"version": "1.4.1",
|
|
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
|
}
|