@vixsonous/map-array 1.0.0 → 1.0.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 +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,10 +7,10 @@ A TypeScript utility class that converts arrays into an O(1) lookup HashMap whil
|
|
|
7
7
|
When working with arrays of objects, lookups like `array.find(item => item.id === id)` are O(N) — they scan the entire array every time. MapArray converts your array into a HashMap on initialization (O(N) once), then every subsequent lookup is O(1).
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
|
-
//
|
|
10
|
+
// Without MapArray — O(N) every lookup
|
|
11
11
|
const user = users.find(u => u.id === "42");
|
|
12
12
|
|
|
13
|
-
//
|
|
13
|
+
// With MapArray — O(1) every lookup
|
|
14
14
|
const user = userMap.get("42");
|
|
15
15
|
```
|
|
16
16
|
|
|
@@ -193,7 +193,7 @@ const arr = [{ id: 1, name: "Alice" }];
|
|
|
193
193
|
const map = new MapArray({ array: arr, idField: "id" });
|
|
194
194
|
|
|
195
195
|
arr[0].name = "Bob";
|
|
196
|
-
map.get("1")?.name; // Still "Alice"
|
|
196
|
+
map.get("1")?.name; // Still "Alice"
|
|
197
197
|
```
|
|
198
198
|
|
|
199
199
|
## License
|