@bemoje/map 1.2.2 → 1.2.3
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 +23 -21
- package/package.json +14 -154
package/README.md
CHANGED
|
@@ -2,8 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
Extended Map class and utilities for sorting, filtering, mapping, and managing key-value data.
|
|
4
4
|
|
|
5
|
-
[](https://www.typescriptlang.org/)
|
|
6
|
-
|
|
5
|
+
[](https://www.typescriptlang.org/) [](https://nodejs.org/api/esm.html)
|
|
6
|
+
|
|
7
|
+
## Exports
|
|
8
|
+
|
|
9
|
+
<!-- EXPORTS_START -->
|
|
10
|
+
|
|
11
|
+
- **ExtMap**: Minimal Extended Map class focused only on Map-specific utilities.
|
|
12
|
+
- **TimeoutWeakMap**: A WeakMap with automatic timeout-based expiry for entries. Entries are automatically removed after a specified timeout period. Accessing an entry refreshes its timeout, extending its lifetime. This is useful for caching scenarios where you want automatic cleanup of unused entries while keeping frequently accessed ones alive.
|
|
13
|
+
- **countUniques**: Count unique occurrences of values in an iterable, returning a sorted map by count descending.
|
|
14
|
+
- **entriesArray**: Returns an array of all key-value pairs in the map. Convenience method that converts the entries iterator to an array.
|
|
15
|
+
- **isGenericMap**: Checks if the provided value implements the Map interface with the specified required properties.
|
|
16
|
+
- **keysArray**: Returns an array of all keys in the map. Convenience method that converts the keys iterator to an array.
|
|
17
|
+
- **mapGetOrDefault**: Gets a value from a map or creates it using a factory function if it doesn't exist.
|
|
18
|
+
- **mapLoad**: Loads multiple entries into the map from an iterable.
|
|
19
|
+
- **mapReverse**: Reverses the order of entries in a Map.
|
|
20
|
+
- **mapUpdate**: Updates a value in the map using an update function.
|
|
21
|
+
- **sort**: Sorts the map entries using a custom comparison function and updates the map in place. This is Map-specific because it maintains insertion order.
|
|
22
|
+
- **sortByKeys**: Sorts the map entries by their keys and updates the map in place.
|
|
23
|
+
- **sortByValues**: Sorts the map entries by their values and updates the map in place.
|
|
24
|
+
- **toMap**: Converts a GenericMap to a native Map.
|
|
25
|
+
- **valuesArray**: Returns an array of all values in the map. Convenience method that converts the values iterator to an array.
|
|
26
|
+
|
|
27
|
+
<!-- EXPORTS_END -->
|
|
7
28
|
|
|
8
29
|
## Installation
|
|
9
30
|
|
|
@@ -79,22 +100,3 @@ mapGetOrDefault(m, 'c', () => 99) // 99 (inserted into map)
|
|
|
79
100
|
mapReverse(m) // reverses entry order in-place
|
|
80
101
|
sortByValues(m, (a, b) => a - b) // sorts entries by value in-place
|
|
81
102
|
```
|
|
82
|
-
|
|
83
|
-
## API Reference
|
|
84
|
-
|
|
85
|
-
| Export | Description |
|
|
86
|
-
| ----------------- | --------------------------------------------------------- |
|
|
87
|
-
| `ExtMap` | Extended Map with sort, filter, map, reduce, and chaining |
|
|
88
|
-
| `TimeoutWeakMap` | WeakMap with automatic timeout-based entry expiry |
|
|
89
|
-
| `mapGetOrDefault` | Get a value or create it with a factory function |
|
|
90
|
-
| `mapLoad` | Load multiple entries into a map |
|
|
91
|
-
| `mapReverse` | Reverse the order of map entries |
|
|
92
|
-
| `mapUpdate` | Update a map value using an update function |
|
|
93
|
-
| `sort` | Sort map entries with a custom comparator |
|
|
94
|
-
| `sortByKeys` | Sort map entries by keys |
|
|
95
|
-
| `sortByValues` | Sort map entries by values |
|
|
96
|
-
| `toMap` | Convert a GenericMap to a native Map |
|
|
97
|
-
| `keysArray` | Get all keys as an array |
|
|
98
|
-
| `valuesArray` | Get all values as an array |
|
|
99
|
-
| `entriesArray` | Get all entries as an array |
|
|
100
|
-
| `isGenericMap` | Check if a value implements the Map interface |
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/map",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Extended Map class and utilities for sorting, filtering, mapping, and managing key-value data.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"iter-tools": "^7.5.4",
|
|
12
|
+
"mnemonist": "^0.40.3"
|
|
13
|
+
},
|
|
7
14
|
"keywords": [
|
|
8
15
|
"map",
|
|
9
16
|
"key-value",
|
|
@@ -33,147 +40,7 @@
|
|
|
33
40
|
"default": "./lib/index.cjs"
|
|
34
41
|
}
|
|
35
42
|
},
|
|
36
|
-
"
|
|
37
|
-
"import": {
|
|
38
|
-
"types": "./lib/index.d.ts",
|
|
39
|
-
"default": "./lib/index.js"
|
|
40
|
-
},
|
|
41
|
-
"require": {
|
|
42
|
-
"types": "./lib/index.d.cts",
|
|
43
|
-
"default": "./lib/index.cjs"
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
"./TimeoutWeakMap": {
|
|
47
|
-
"import": {
|
|
48
|
-
"types": "./lib/index.d.ts",
|
|
49
|
-
"default": "./lib/index.js"
|
|
50
|
-
},
|
|
51
|
-
"require": {
|
|
52
|
-
"types": "./lib/index.d.cts",
|
|
53
|
-
"default": "./lib/index.cjs"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
"./countUniques": {
|
|
57
|
-
"import": {
|
|
58
|
-
"types": "./lib/index.d.ts",
|
|
59
|
-
"default": "./lib/index.js"
|
|
60
|
-
},
|
|
61
|
-
"require": {
|
|
62
|
-
"types": "./lib/index.d.cts",
|
|
63
|
-
"default": "./lib/index.cjs"
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
"./entriesArray": {
|
|
67
|
-
"import": {
|
|
68
|
-
"types": "./lib/index.d.ts",
|
|
69
|
-
"default": "./lib/index.js"
|
|
70
|
-
},
|
|
71
|
-
"require": {
|
|
72
|
-
"types": "./lib/index.d.cts",
|
|
73
|
-
"default": "./lib/index.cjs"
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
"./isGenericMap": {
|
|
77
|
-
"import": {
|
|
78
|
-
"types": "./lib/index.d.ts",
|
|
79
|
-
"default": "./lib/index.js"
|
|
80
|
-
},
|
|
81
|
-
"require": {
|
|
82
|
-
"types": "./lib/index.d.cts",
|
|
83
|
-
"default": "./lib/index.cjs"
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
"./keysArray": {
|
|
87
|
-
"import": {
|
|
88
|
-
"types": "./lib/index.d.ts",
|
|
89
|
-
"default": "./lib/index.js"
|
|
90
|
-
},
|
|
91
|
-
"require": {
|
|
92
|
-
"types": "./lib/index.d.cts",
|
|
93
|
-
"default": "./lib/index.cjs"
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
"./mapGetOrDefault": {
|
|
97
|
-
"import": {
|
|
98
|
-
"types": "./lib/index.d.ts",
|
|
99
|
-
"default": "./lib/index.js"
|
|
100
|
-
},
|
|
101
|
-
"require": {
|
|
102
|
-
"types": "./lib/index.d.cts",
|
|
103
|
-
"default": "./lib/index.cjs"
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
"./mapLoad": {
|
|
107
|
-
"import": {
|
|
108
|
-
"types": "./lib/index.d.ts",
|
|
109
|
-
"default": "./lib/index.js"
|
|
110
|
-
},
|
|
111
|
-
"require": {
|
|
112
|
-
"types": "./lib/index.d.cts",
|
|
113
|
-
"default": "./lib/index.cjs"
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
"./mapReverse": {
|
|
117
|
-
"import": {
|
|
118
|
-
"types": "./lib/index.d.ts",
|
|
119
|
-
"default": "./lib/index.js"
|
|
120
|
-
},
|
|
121
|
-
"require": {
|
|
122
|
-
"types": "./lib/index.d.cts",
|
|
123
|
-
"default": "./lib/index.cjs"
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
"./mapUpdate": {
|
|
127
|
-
"import": {
|
|
128
|
-
"types": "./lib/index.d.ts",
|
|
129
|
-
"default": "./lib/index.js"
|
|
130
|
-
},
|
|
131
|
-
"require": {
|
|
132
|
-
"types": "./lib/index.d.cts",
|
|
133
|
-
"default": "./lib/index.cjs"
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
"./sort": {
|
|
137
|
-
"import": {
|
|
138
|
-
"types": "./lib/index.d.ts",
|
|
139
|
-
"default": "./lib/index.js"
|
|
140
|
-
},
|
|
141
|
-
"require": {
|
|
142
|
-
"types": "./lib/index.d.cts",
|
|
143
|
-
"default": "./lib/index.cjs"
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
"./sortByKeys": {
|
|
147
|
-
"import": {
|
|
148
|
-
"types": "./lib/index.d.ts",
|
|
149
|
-
"default": "./lib/index.js"
|
|
150
|
-
},
|
|
151
|
-
"require": {
|
|
152
|
-
"types": "./lib/index.d.cts",
|
|
153
|
-
"default": "./lib/index.cjs"
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
"./sortByValues": {
|
|
157
|
-
"import": {
|
|
158
|
-
"types": "./lib/index.d.ts",
|
|
159
|
-
"default": "./lib/index.js"
|
|
160
|
-
},
|
|
161
|
-
"require": {
|
|
162
|
-
"types": "./lib/index.d.cts",
|
|
163
|
-
"default": "./lib/index.cjs"
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
"./toMap": {
|
|
167
|
-
"import": {
|
|
168
|
-
"types": "./lib/index.d.ts",
|
|
169
|
-
"default": "./lib/index.js"
|
|
170
|
-
},
|
|
171
|
-
"require": {
|
|
172
|
-
"types": "./lib/index.d.cts",
|
|
173
|
-
"default": "./lib/index.cjs"
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
"./valuesArray": {
|
|
43
|
+
"./*": {
|
|
177
44
|
"import": {
|
|
178
45
|
"types": "./lib/index.d.ts",
|
|
179
46
|
"default": "./lib/index.js"
|
|
@@ -184,22 +51,15 @@
|
|
|
184
51
|
}
|
|
185
52
|
}
|
|
186
53
|
},
|
|
187
|
-
"
|
|
188
|
-
"
|
|
189
|
-
"
|
|
190
|
-
|
|
191
|
-
"publishConfig": {
|
|
192
|
-
"access": "public"
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "git+https://github.com/bemoje/mono.git",
|
|
57
|
+
"directory": "libs/map"
|
|
193
58
|
},
|
|
194
|
-
"license": "MIT",
|
|
195
59
|
"author": {
|
|
196
60
|
"name": "Benjamin Møller Jensen",
|
|
197
61
|
"email": "bemoje@bemoje.net",
|
|
198
62
|
"url": "https://github.com/bemoje/"
|
|
199
63
|
},
|
|
200
|
-
"
|
|
201
|
-
"type": "git",
|
|
202
|
-
"url": "git+https://github.com/bemoje/mono.git",
|
|
203
|
-
"directory": "libs/map"
|
|
204
|
-
}
|
|
64
|
+
"license": "MIT"
|
|
205
65
|
}
|