@grain/stdlib 0.5.12 → 0.6.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/CHANGELOG.md +200 -0
- package/LICENSE +1 -1
- package/README.md +25 -2
- package/array.gr +1512 -199
- package/array.md +2032 -94
- package/bigint.gr +239 -140
- package/bigint.md +450 -106
- package/buffer.gr +595 -102
- package/buffer.md +903 -145
- package/bytes.gr +401 -110
- package/bytes.md +551 -63
- package/char.gr +228 -49
- package/char.md +373 -7
- package/exception.gr +26 -12
- package/exception.md +29 -5
- package/float32.gr +130 -109
- package/float32.md +185 -57
- package/float64.gr +112 -99
- package/float64.md +185 -57
- package/hash.gr +47 -37
- package/hash.md +21 -3
- package/int16.gr +430 -0
- package/int16.md +618 -0
- package/int32.gr +200 -269
- package/int32.md +254 -289
- package/int64.gr +142 -225
- package/int64.md +254 -289
- package/int8.gr +511 -0
- package/int8.md +786 -0
- package/json.gr +2084 -0
- package/json.md +608 -0
- package/list.gr +120 -68
- package/list.md +125 -80
- package/map.gr +560 -57
- package/map.md +672 -56
- package/marshal.gr +239 -227
- package/marshal.md +36 -4
- package/number.gr +626 -676
- package/number.md +738 -153
- package/option.gr +33 -35
- package/option.md +58 -42
- package/package.json +2 -2
- package/path.gr +148 -187
- package/path.md +47 -96
- package/pervasives.gr +75 -416
- package/pervasives.md +85 -180
- package/priorityqueue.gr +433 -74
- package/priorityqueue.md +422 -54
- package/queue.gr +362 -80
- package/queue.md +433 -38
- package/random.gr +67 -75
- package/random.md +68 -40
- package/range.gr +135 -63
- package/range.md +198 -43
- package/rational.gr +284 -0
- package/rational.md +545 -0
- package/regex.gr +933 -1066
- package/regex.md +59 -60
- package/result.gr +23 -25
- package/result.md +54 -39
- package/runtime/atof/common.gr +78 -82
- package/runtime/atof/common.md +22 -10
- package/runtime/atof/decimal.gr +102 -127
- package/runtime/atof/decimal.md +28 -7
- package/runtime/atof/lemire.gr +56 -71
- package/runtime/atof/lemire.md +9 -1
- package/runtime/atof/parse.gr +83 -110
- package/runtime/atof/parse.md +12 -2
- package/runtime/atof/slow.gr +28 -35
- package/runtime/atof/slow.md +9 -1
- package/runtime/atof/table.gr +19 -18
- package/runtime/atof/table.md +10 -2
- package/runtime/atoi/parse.gr +153 -136
- package/runtime/atoi/parse.md +50 -1
- package/runtime/bigint.gr +410 -517
- package/runtime/bigint.md +71 -57
- package/runtime/compare.gr +176 -85
- package/runtime/compare.md +31 -1
- package/runtime/dataStructures.gr +144 -32
- package/runtime/dataStructures.md +267 -31
- package/runtime/debugPrint.gr +34 -15
- package/runtime/debugPrint.md +37 -5
- package/runtime/equal.gr +53 -52
- package/runtime/equal.md +30 -1
- package/runtime/exception.gr +38 -47
- package/runtime/exception.md +10 -8
- package/runtime/gc.gr +23 -152
- package/runtime/gc.md +13 -17
- package/runtime/malloc.gr +31 -31
- package/runtime/malloc.md +11 -3
- package/runtime/numberUtils.gr +191 -172
- package/runtime/numberUtils.md +17 -9
- package/runtime/numbers.gr +1695 -1021
- package/runtime/numbers.md +1098 -134
- package/runtime/string.gr +540 -242
- package/runtime/string.md +76 -6
- package/runtime/unsafe/constants.gr +30 -13
- package/runtime/unsafe/constants.md +80 -0
- package/runtime/unsafe/conv.gr +55 -28
- package/runtime/unsafe/conv.md +41 -9
- package/runtime/unsafe/memory.gr +10 -30
- package/runtime/unsafe/memory.md +15 -19
- package/runtime/unsafe/tags.gr +37 -21
- package/runtime/unsafe/tags.md +88 -8
- package/runtime/unsafe/wasmf32.gr +30 -36
- package/runtime/unsafe/wasmf32.md +64 -56
- package/runtime/unsafe/wasmf64.gr +30 -36
- package/runtime/unsafe/wasmf64.md +64 -56
- package/runtime/unsafe/wasmi32.gr +49 -66
- package/runtime/unsafe/wasmi32.md +102 -94
- package/runtime/unsafe/wasmi64.gr +52 -79
- package/runtime/unsafe/wasmi64.md +108 -100
- package/runtime/utils/printing.gr +13 -15
- package/runtime/utils/printing.md +11 -3
- package/runtime/wasi.gr +294 -295
- package/runtime/wasi.md +62 -42
- package/set.gr +574 -64
- package/set.md +634 -54
- package/stack.gr +181 -64
- package/stack.md +271 -42
- package/string.gr +453 -533
- package/string.md +241 -151
- package/uint16.gr +369 -0
- package/uint16.md +585 -0
- package/uint32.gr +470 -0
- package/uint32.md +737 -0
- package/uint64.gr +471 -0
- package/uint64.md +737 -0
- package/uint8.gr +369 -0
- package/uint8.md +585 -0
- package/uri.gr +1093 -0
- package/uri.md +477 -0
- package/{sys → wasi}/file.gr +914 -500
- package/{sys → wasi}/file.md +454 -50
- package/wasi/process.gr +292 -0
- package/{sys → wasi}/process.md +164 -6
- package/wasi/random.gr +77 -0
- package/wasi/random.md +80 -0
- package/{sys → wasi}/time.gr +15 -22
- package/{sys → wasi}/time.md +5 -5
- package/immutablearray.gr +0 -929
- package/immutablearray.md +0 -1038
- package/immutablemap.gr +0 -493
- package/immutablemap.md +0 -479
- package/immutablepriorityqueue.gr +0 -360
- package/immutablepriorityqueue.md +0 -291
- package/immutableset.gr +0 -498
- package/immutableset.md +0 -449
- package/runtime/debug.gr +0 -2
- package/runtime/debug.md +0 -6
- package/runtime/unsafe/errors.gr +0 -36
- package/runtime/unsafe/errors.md +0 -204
- package/sys/process.gr +0 -254
- package/sys/random.gr +0 -79
- package/sys/random.md +0 -66
package/map.md
CHANGED
|
@@ -4,13 +4,15 @@ title: Map
|
|
|
4
4
|
|
|
5
5
|
A Map holds key-value pairs. Any value may be used as a key or value. Operations on a Map mutate the internal state, so it never needs to be re-assigned.
|
|
6
6
|
|
|
7
|
+
An immutable map implementation is available in the `Immutable` submodule.
|
|
8
|
+
|
|
7
9
|
<details disabled>
|
|
8
10
|
<summary tabindex="-1">Added in <code>0.2.0</code></summary>
|
|
9
11
|
No other changes yet.
|
|
10
12
|
</details>
|
|
11
13
|
|
|
12
14
|
```grain
|
|
13
|
-
|
|
15
|
+
from "map" include Map
|
|
14
16
|
```
|
|
15
17
|
|
|
16
18
|
## Types
|
|
@@ -23,28 +25,49 @@ Type declarations included in the Map module.
|
|
|
23
25
|
type Map<k, v>
|
|
24
26
|
```
|
|
25
27
|
|
|
28
|
+
### Map.**InternalMapStats**
|
|
29
|
+
|
|
30
|
+
```grain
|
|
31
|
+
record InternalMapStats {
|
|
32
|
+
currentSize: Number,
|
|
33
|
+
bucketCount: Number,
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Represents the internal state of a map.
|
|
38
|
+
|
|
26
39
|
## Values
|
|
27
40
|
|
|
28
|
-
Functions
|
|
41
|
+
Functions and constants included in the Map module.
|
|
29
42
|
|
|
30
|
-
### Map.**
|
|
43
|
+
### Map.**make**
|
|
31
44
|
|
|
32
|
-
<details
|
|
33
|
-
<summary
|
|
34
|
-
|
|
45
|
+
<details>
|
|
46
|
+
<summary>Added in <code>0.2.0</code></summary>
|
|
47
|
+
<table>
|
|
48
|
+
<thead>
|
|
49
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
50
|
+
</thead>
|
|
51
|
+
<tbody>
|
|
52
|
+
<tr><td><code>0.6.0</code></td><td>Merged with `makeSized`; modified signature to accept size</td></tr>
|
|
53
|
+
</tbody>
|
|
54
|
+
</table>
|
|
35
55
|
</details>
|
|
36
56
|
|
|
37
57
|
```grain
|
|
38
|
-
|
|
58
|
+
make : (?size: Number) => Map<a, b>
|
|
39
59
|
```
|
|
40
60
|
|
|
41
|
-
Creates a new empty map with an initial storage of the given size. As
|
|
61
|
+
Creates a new empty map with an initial storage of the given size. As
|
|
62
|
+
values are added or removed, the internal storage may grow or shrink.
|
|
63
|
+
Generally, you won't need to care about the storage size of your map and
|
|
64
|
+
can use the default size.
|
|
42
65
|
|
|
43
66
|
Parameters:
|
|
44
67
|
|
|
45
68
|
|param|type|description|
|
|
46
69
|
|-----|----|-----------|
|
|
47
|
-
|
|
70
|
+
|`?size`|`Number`|The initial storage size of the map|
|
|
48
71
|
|
|
49
72
|
Returns:
|
|
50
73
|
|
|
@@ -52,25 +75,6 @@ Returns:
|
|
|
52
75
|
|----|-----------|
|
|
53
76
|
|`Map<a, b>`|An empty map with the given initial storage size|
|
|
54
77
|
|
|
55
|
-
### Map.**make**
|
|
56
|
-
|
|
57
|
-
<details disabled>
|
|
58
|
-
<summary tabindex="-1">Added in <code>0.2.0</code></summary>
|
|
59
|
-
No other changes yet.
|
|
60
|
-
</details>
|
|
61
|
-
|
|
62
|
-
```grain
|
|
63
|
-
make : () -> Map<a, b>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Creates a new, empty map.
|
|
67
|
-
|
|
68
|
-
Returns:
|
|
69
|
-
|
|
70
|
-
|type|description|
|
|
71
|
-
|----|-----------|
|
|
72
|
-
|`Map<a, b>`|An empty map|
|
|
73
|
-
|
|
74
78
|
### Map.**set**
|
|
75
79
|
|
|
76
80
|
<details disabled>
|
|
@@ -79,7 +83,7 @@ No other changes yet.
|
|
|
79
83
|
</details>
|
|
80
84
|
|
|
81
85
|
```grain
|
|
82
|
-
set : (a, b, Map<a, b>)
|
|
86
|
+
set : (key: a, value: b, map: Map<a, b>) => Void
|
|
83
87
|
```
|
|
84
88
|
|
|
85
89
|
Adds a new key-value pair to the map. If the key already exists in the map, the value is replaced.
|
|
@@ -100,7 +104,7 @@ No other changes yet.
|
|
|
100
104
|
</details>
|
|
101
105
|
|
|
102
106
|
```grain
|
|
103
|
-
get : (a, Map<a, b>)
|
|
107
|
+
get : (key: a, map: Map<a, b>) => Option<b>
|
|
104
108
|
```
|
|
105
109
|
|
|
106
110
|
Retrieves the value for the given key.
|
|
@@ -126,7 +130,7 @@ No other changes yet.
|
|
|
126
130
|
</details>
|
|
127
131
|
|
|
128
132
|
```grain
|
|
129
|
-
contains : (a, Map<a, b>)
|
|
133
|
+
contains : (key: a, map: Map<a, b>) => Bool
|
|
130
134
|
```
|
|
131
135
|
|
|
132
136
|
Determines if the map contains the given key. In such a case, it will always contain a value for the given key.
|
|
@@ -152,7 +156,7 @@ No other changes yet.
|
|
|
152
156
|
</details>
|
|
153
157
|
|
|
154
158
|
```grain
|
|
155
|
-
remove : (a, Map<a, b>)
|
|
159
|
+
remove : (key: a, map: Map<a, b>) => Void
|
|
156
160
|
```
|
|
157
161
|
|
|
158
162
|
Removes the given key from the map, which also removes the value. If the key pair doesn't exist, nothing happens.
|
|
@@ -172,7 +176,7 @@ No other changes yet.
|
|
|
172
176
|
</details>
|
|
173
177
|
|
|
174
178
|
```grain
|
|
175
|
-
update : (a, (Option<b>
|
|
179
|
+
update : (key: a, fn: (Option<b> => Option<b>), map: Map<a, b>) => Void
|
|
176
180
|
```
|
|
177
181
|
|
|
178
182
|
Updates a value in the map by calling an updater function that receives the previously stored value as an `Option` and returns the new value to be stored as an `Option`. If the key didn't exist previously, the value will be `None`. If `None` is returned from the updater function, the key-value pair is removed.
|
|
@@ -182,7 +186,7 @@ Parameters:
|
|
|
182
186
|
|param|type|description|
|
|
183
187
|
|-----|----|-----------|
|
|
184
188
|
|`key`|`a`|The unique key in the map|
|
|
185
|
-
|`fn`|`Option<b>
|
|
189
|
+
|`fn`|`Option<b> => Option<b>`|The updater function|
|
|
186
190
|
|`map`|`Map<a, b>`|The map to modify|
|
|
187
191
|
|
|
188
192
|
### Map.**size**
|
|
@@ -193,7 +197,7 @@ No other changes yet.
|
|
|
193
197
|
</details>
|
|
194
198
|
|
|
195
199
|
```grain
|
|
196
|
-
size : Map<a, b>
|
|
200
|
+
size : (map: Map<a, b>) => Number
|
|
197
201
|
```
|
|
198
202
|
|
|
199
203
|
Provides the count of key-value pairs stored within the map.
|
|
@@ -218,7 +222,7 @@ No other changes yet.
|
|
|
218
222
|
</details>
|
|
219
223
|
|
|
220
224
|
```grain
|
|
221
|
-
isEmpty : Map<a, b>
|
|
225
|
+
isEmpty : (map: Map<a, b>) => Bool
|
|
222
226
|
```
|
|
223
227
|
|
|
224
228
|
Determines if the map contains no key-value pairs.
|
|
@@ -243,7 +247,7 @@ No other changes yet.
|
|
|
243
247
|
</details>
|
|
244
248
|
|
|
245
249
|
```grain
|
|
246
|
-
clear : Map<a, b>
|
|
250
|
+
clear : (map: Map<a, b>) => Void
|
|
247
251
|
```
|
|
248
252
|
|
|
249
253
|
Resets the map by removing all key-value pairs.
|
|
@@ -269,7 +273,7 @@ Parameters:
|
|
|
269
273
|
</details>
|
|
270
274
|
|
|
271
275
|
```grain
|
|
272
|
-
forEach : (((a, b)
|
|
276
|
+
forEach : (fn: ((a, b) => Void), map: Map<a, b>) => Void
|
|
273
277
|
```
|
|
274
278
|
|
|
275
279
|
Iterates the map, calling an iterator function with each key and value.
|
|
@@ -278,7 +282,7 @@ Parameters:
|
|
|
278
282
|
|
|
279
283
|
|param|type|description|
|
|
280
284
|
|-----|----|-----------|
|
|
281
|
-
|`fn`|`(a, b)
|
|
285
|
+
|`fn`|`(a, b) => Void`|The iterator function to call with each key and value|
|
|
282
286
|
|`map`|`Map<a, b>`|The map to iterate|
|
|
283
287
|
|
|
284
288
|
### Map.**reduce**
|
|
@@ -289,7 +293,7 @@ No other changes yet.
|
|
|
289
293
|
</details>
|
|
290
294
|
|
|
291
295
|
```grain
|
|
292
|
-
reduce : (((a, b, c)
|
|
296
|
+
reduce : (fn: ((a, b, c) => a), init: a, map: Map<b, c>) => a
|
|
293
297
|
```
|
|
294
298
|
|
|
295
299
|
Combines all key-value pairs of a map using a reducer function.
|
|
@@ -298,7 +302,7 @@ Parameters:
|
|
|
298
302
|
|
|
299
303
|
|param|type|description|
|
|
300
304
|
|-----|----|-----------|
|
|
301
|
-
|`fn`|`(a, b, c)
|
|
305
|
+
|`fn`|`(a, b, c) => a`|The reducer function to call on each key and value, where the value returned will be the next accumulator value|
|
|
302
306
|
|`init`|`a`|The initial value to use for the accumulator on the first iteration|
|
|
303
307
|
|`map`|`Map<b, c>`|The map to iterate|
|
|
304
308
|
|
|
@@ -316,7 +320,7 @@ No other changes yet.
|
|
|
316
320
|
</details>
|
|
317
321
|
|
|
318
322
|
```grain
|
|
319
|
-
keys : Map<a, b>
|
|
323
|
+
keys : (map: Map<a, b>) => List<a>
|
|
320
324
|
```
|
|
321
325
|
|
|
322
326
|
Enumerates all keys in the given map.
|
|
@@ -341,7 +345,7 @@ No other changes yet.
|
|
|
341
345
|
</details>
|
|
342
346
|
|
|
343
347
|
```grain
|
|
344
|
-
values : Map<a, b>
|
|
348
|
+
values : (map: Map<a, b>) => List<b>
|
|
345
349
|
```
|
|
346
350
|
|
|
347
351
|
Enumerates all values in the given map.
|
|
@@ -366,7 +370,7 @@ No other changes yet.
|
|
|
366
370
|
</details>
|
|
367
371
|
|
|
368
372
|
```grain
|
|
369
|
-
toList : Map<a, b>
|
|
373
|
+
toList : (map: Map<a, b>) => List<(a, b)>
|
|
370
374
|
```
|
|
371
375
|
|
|
372
376
|
Enumerates all key-value pairs in the given map.
|
|
@@ -391,7 +395,7 @@ No other changes yet.
|
|
|
391
395
|
</details>
|
|
392
396
|
|
|
393
397
|
```grain
|
|
394
|
-
fromList : List<(a, b)>
|
|
398
|
+
fromList : (list: List<(a, b)>) => Map<a, b>
|
|
395
399
|
```
|
|
396
400
|
|
|
397
401
|
Creates a map from a list.
|
|
@@ -416,7 +420,7 @@ No other changes yet.
|
|
|
416
420
|
</details>
|
|
417
421
|
|
|
418
422
|
```grain
|
|
419
|
-
toArray : Map<a, b>
|
|
423
|
+
toArray : (map: Map<a, b>) => Array<(a, b)>
|
|
420
424
|
```
|
|
421
425
|
|
|
422
426
|
Converts a map into an array of its key-value pairs.
|
|
@@ -441,7 +445,7 @@ No other changes yet.
|
|
|
441
445
|
</details>
|
|
442
446
|
|
|
443
447
|
```grain
|
|
444
|
-
fromArray : Array<(a, b)>
|
|
448
|
+
fromArray : (array: Array<(a, b)>) => Map<a, b>
|
|
445
449
|
```
|
|
446
450
|
|
|
447
451
|
Creates a map from an array.
|
|
@@ -466,7 +470,7 @@ No other changes yet.
|
|
|
466
470
|
</details>
|
|
467
471
|
|
|
468
472
|
```grain
|
|
469
|
-
filter : (((a, b)
|
|
473
|
+
filter : (fn: ((a, b) => Bool), map: Map<a, b>) => Void
|
|
470
474
|
```
|
|
471
475
|
|
|
472
476
|
Removes key-value pairs from a map where a predicate function returns `false`.
|
|
@@ -475,7 +479,7 @@ Parameters:
|
|
|
475
479
|
|
|
476
480
|
|param|type|description|
|
|
477
481
|
|-----|----|-----------|
|
|
478
|
-
|`fn`|`(a, b)
|
|
482
|
+
|`fn`|`(a, b) => Bool`|The predicate function to indicate which key-value pairs to remove from the map, where returning `false` indicates the key-value pair should be removed|
|
|
479
483
|
|`map`|`Map<a, b>`|The map to iterate|
|
|
480
484
|
|
|
481
485
|
### Map.**reject**
|
|
@@ -486,7 +490,7 @@ No other changes yet.
|
|
|
486
490
|
</details>
|
|
487
491
|
|
|
488
492
|
```grain
|
|
489
|
-
reject : (((a, b)
|
|
493
|
+
reject : (fn: ((a, b) => Bool), map: Map<a, b>) => Void
|
|
490
494
|
```
|
|
491
495
|
|
|
492
496
|
Removes key-value pairs from a map where a predicate function returns `true`.
|
|
@@ -495,18 +499,25 @@ Parameters:
|
|
|
495
499
|
|
|
496
500
|
|param|type|description|
|
|
497
501
|
|-----|----|-----------|
|
|
498
|
-
|`fn`|`(a, b)
|
|
502
|
+
|`fn`|`(a, b) => Bool`|The predicate function to indicate which key-value pairs to remove from the map, where returning `true` indicates the key-value pair should be removed|
|
|
499
503
|
|`map`|`Map<a, b>`|The map to iterate|
|
|
500
504
|
|
|
501
505
|
### Map.**getInternalStats**
|
|
502
506
|
|
|
503
|
-
<details
|
|
504
|
-
<summary
|
|
505
|
-
|
|
507
|
+
<details>
|
|
508
|
+
<summary>Added in <code>0.2.0</code></summary>
|
|
509
|
+
<table>
|
|
510
|
+
<thead>
|
|
511
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
512
|
+
</thead>
|
|
513
|
+
<tbody>
|
|
514
|
+
<tr><td><code>0.6.0</code></td><td>Return `InternalMapStats` record instead of a tuple</td></tr>
|
|
515
|
+
</tbody>
|
|
516
|
+
</table>
|
|
506
517
|
</details>
|
|
507
518
|
|
|
508
519
|
```grain
|
|
509
|
-
getInternalStats : Map<a, b>
|
|
520
|
+
getInternalStats : (map: Map<a, b>) => InternalMapStats
|
|
510
521
|
```
|
|
511
522
|
|
|
512
523
|
Provides data representing the internal state state of the map.
|
|
@@ -521,5 +532,610 @@ Returns:
|
|
|
521
532
|
|
|
522
533
|
|type|description|
|
|
523
534
|
|----|-----------|
|
|
524
|
-
|`
|
|
535
|
+
|`InternalMapStats`|The internal state of the map|
|
|
536
|
+
|
|
537
|
+
## Map.Immutable
|
|
538
|
+
|
|
539
|
+
An immutable map implementation.
|
|
540
|
+
|
|
541
|
+
<details>
|
|
542
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
543
|
+
<table>
|
|
544
|
+
<thead>
|
|
545
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
546
|
+
</thead>
|
|
547
|
+
<tbody>
|
|
548
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
549
|
+
</tbody>
|
|
550
|
+
</table>
|
|
551
|
+
</details>
|
|
552
|
+
|
|
553
|
+
### Types
|
|
554
|
+
|
|
555
|
+
Type declarations included in the Map.Immutable module.
|
|
556
|
+
|
|
557
|
+
#### Map.Immutable.**Map**
|
|
558
|
+
|
|
559
|
+
```grain
|
|
560
|
+
type Map<k, v>
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### Values
|
|
564
|
+
|
|
565
|
+
Functions and constants included in the Map.Immutable module.
|
|
566
|
+
|
|
567
|
+
#### Map.Immutable.**empty**
|
|
568
|
+
|
|
569
|
+
<details>
|
|
570
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
571
|
+
<table>
|
|
572
|
+
<thead>
|
|
573
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
574
|
+
</thead>
|
|
575
|
+
<tbody>
|
|
576
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
577
|
+
</tbody>
|
|
578
|
+
</table>
|
|
579
|
+
</details>
|
|
580
|
+
|
|
581
|
+
```grain
|
|
582
|
+
empty : Map<a, b>
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
An empty map
|
|
586
|
+
|
|
587
|
+
#### Map.Immutable.**size**
|
|
588
|
+
|
|
589
|
+
<details>
|
|
590
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
591
|
+
<table>
|
|
592
|
+
<thead>
|
|
593
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
594
|
+
</thead>
|
|
595
|
+
<tbody>
|
|
596
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
597
|
+
</tbody>
|
|
598
|
+
</table>
|
|
599
|
+
</details>
|
|
600
|
+
|
|
601
|
+
```grain
|
|
602
|
+
size : (map: Map<a, b>) => Number
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
Provides the count of key-value pairs stored within the map.
|
|
606
|
+
|
|
607
|
+
Parameters:
|
|
608
|
+
|
|
609
|
+
|param|type|description|
|
|
610
|
+
|-----|----|-----------|
|
|
611
|
+
|`map`|`Map<a, b>`|The map to inspect|
|
|
612
|
+
|
|
613
|
+
Returns:
|
|
614
|
+
|
|
615
|
+
|type|description|
|
|
616
|
+
|----|-----------|
|
|
617
|
+
|`Number`|The count of key-value pairs in the map|
|
|
618
|
+
|
|
619
|
+
#### Map.Immutable.**isEmpty**
|
|
620
|
+
|
|
621
|
+
<details>
|
|
622
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
623
|
+
<table>
|
|
624
|
+
<thead>
|
|
625
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
626
|
+
</thead>
|
|
627
|
+
<tbody>
|
|
628
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
629
|
+
</tbody>
|
|
630
|
+
</table>
|
|
631
|
+
</details>
|
|
632
|
+
|
|
633
|
+
```grain
|
|
634
|
+
isEmpty : (map: Map<a, b>) => Bool
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
Determines if the map contains no key-value pairs.
|
|
638
|
+
|
|
639
|
+
Parameters:
|
|
640
|
+
|
|
641
|
+
|param|type|description|
|
|
642
|
+
|-----|----|-----------|
|
|
643
|
+
|`map`|`Map<a, b>`|The map to inspect|
|
|
644
|
+
|
|
645
|
+
Returns:
|
|
646
|
+
|
|
647
|
+
|type|description|
|
|
648
|
+
|----|-----------|
|
|
649
|
+
|`Bool`|`true` if the given map is empty or `false` otherwise|
|
|
650
|
+
|
|
651
|
+
#### Map.Immutable.**set**
|
|
652
|
+
|
|
653
|
+
<details>
|
|
654
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
655
|
+
<table>
|
|
656
|
+
<thead>
|
|
657
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
658
|
+
</thead>
|
|
659
|
+
<tbody>
|
|
660
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
661
|
+
</tbody>
|
|
662
|
+
</table>
|
|
663
|
+
</details>
|
|
664
|
+
|
|
665
|
+
```grain
|
|
666
|
+
set : (key: a, value: b, map: Map<a, b>) => Map<a, b>
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
Produces a new map containing a new key-value pair. If the key already exists in the map, the value is replaced.
|
|
670
|
+
|
|
671
|
+
Parameters:
|
|
672
|
+
|
|
673
|
+
|param|type|description|
|
|
674
|
+
|-----|----|-----------|
|
|
675
|
+
|`key`|`a`|The unique key in the map|
|
|
676
|
+
|`value`|`b`|The value to store|
|
|
677
|
+
|`map`|`Map<a, b>`|The base map|
|
|
678
|
+
|
|
679
|
+
Returns:
|
|
680
|
+
|
|
681
|
+
|type|description|
|
|
682
|
+
|----|-----------|
|
|
683
|
+
|`Map<a, b>`|A new map containing the new key-value pair|
|
|
684
|
+
|
|
685
|
+
#### Map.Immutable.**get**
|
|
686
|
+
|
|
687
|
+
<details>
|
|
688
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
689
|
+
<table>
|
|
690
|
+
<thead>
|
|
691
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
692
|
+
</thead>
|
|
693
|
+
<tbody>
|
|
694
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
695
|
+
</tbody>
|
|
696
|
+
</table>
|
|
697
|
+
</details>
|
|
698
|
+
|
|
699
|
+
```grain
|
|
700
|
+
get : (key: a, map: Map<a, b>) => Option<b>
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
Retrieves the value for the given key.
|
|
704
|
+
|
|
705
|
+
Parameters:
|
|
706
|
+
|
|
707
|
+
|param|type|description|
|
|
708
|
+
|-----|----|-----------|
|
|
709
|
+
|`key`|`a`|The key to access|
|
|
710
|
+
|`map`|`Map<a, b>`|The map to access|
|
|
711
|
+
|
|
712
|
+
Returns:
|
|
713
|
+
|
|
714
|
+
|type|description|
|
|
715
|
+
|----|-----------|
|
|
716
|
+
|`Option<b>`|`Some(value)` if the key exists in the map or `None` otherwise|
|
|
717
|
+
|
|
718
|
+
#### Map.Immutable.**contains**
|
|
719
|
+
|
|
720
|
+
<details>
|
|
721
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
722
|
+
<table>
|
|
723
|
+
<thead>
|
|
724
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
725
|
+
</thead>
|
|
726
|
+
<tbody>
|
|
727
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
728
|
+
</tbody>
|
|
729
|
+
</table>
|
|
730
|
+
</details>
|
|
731
|
+
|
|
732
|
+
```grain
|
|
733
|
+
contains : (key: a, map: Map<a, b>) => Bool
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
Determines if the map contains the given key. In such a case, it will always contain a value for the given key.
|
|
737
|
+
|
|
738
|
+
Parameters:
|
|
739
|
+
|
|
740
|
+
|param|type|description|
|
|
741
|
+
|-----|----|-----------|
|
|
742
|
+
|`key`|`a`|The key to search for|
|
|
743
|
+
|`map`|`Map<a, b>`|The map to search|
|
|
744
|
+
|
|
745
|
+
Returns:
|
|
746
|
+
|
|
747
|
+
|type|description|
|
|
748
|
+
|----|-----------|
|
|
749
|
+
|`Bool`|`true` if the map contains the given key or `false` otherwise|
|
|
750
|
+
|
|
751
|
+
#### Map.Immutable.**remove**
|
|
752
|
+
|
|
753
|
+
<details>
|
|
754
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
755
|
+
<table>
|
|
756
|
+
<thead>
|
|
757
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
758
|
+
</thead>
|
|
759
|
+
<tbody>
|
|
760
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
761
|
+
</tbody>
|
|
762
|
+
</table>
|
|
763
|
+
</details>
|
|
764
|
+
|
|
765
|
+
```grain
|
|
766
|
+
remove : (key: a, map: Map<a, b>) => Map<a, b>
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
Produces a new map without the key-value pair corresponding to the given
|
|
770
|
+
key. If the key doesn't exist in the map, the map will be returned unmodified.
|
|
771
|
+
|
|
772
|
+
Parameters:
|
|
773
|
+
|
|
774
|
+
|param|type|description|
|
|
775
|
+
|-----|----|-----------|
|
|
776
|
+
|`key`|`a`|The key to exclude|
|
|
777
|
+
|`map`|`Map<a, b>`|The map to exclude from|
|
|
778
|
+
|
|
779
|
+
Returns:
|
|
780
|
+
|
|
781
|
+
|type|description|
|
|
782
|
+
|----|-----------|
|
|
783
|
+
|`Map<a, b>`|A new map without the given key|
|
|
784
|
+
|
|
785
|
+
#### Map.Immutable.**update**
|
|
786
|
+
|
|
787
|
+
<details>
|
|
788
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
789
|
+
<table>
|
|
790
|
+
<thead>
|
|
791
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
792
|
+
</thead>
|
|
793
|
+
<tbody>
|
|
794
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
795
|
+
</tbody>
|
|
796
|
+
</table>
|
|
797
|
+
</details>
|
|
798
|
+
|
|
799
|
+
```grain
|
|
800
|
+
update : (key: a, fn: (Option<b> => Option<b>), map: Map<a, b>) => Map<a, b>
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
Produces a new map by calling an updater function that receives the
|
|
804
|
+
previously stored value as an `Option` and returns the new value to be
|
|
805
|
+
stored as an `Option`. If the key didn't exist previously, the value
|
|
806
|
+
will be `None`. If `None` is returned from the updater function, the
|
|
807
|
+
key-value pair is excluded.
|
|
808
|
+
|
|
809
|
+
Parameters:
|
|
810
|
+
|
|
811
|
+
|param|type|description|
|
|
812
|
+
|-----|----|-----------|
|
|
813
|
+
|`key`|`a`|The unique key in the map|
|
|
814
|
+
|`fn`|`Option<b> => Option<b>`|The updater function|
|
|
815
|
+
|`map`|`Map<a, b>`|The base map|
|
|
816
|
+
|
|
817
|
+
Returns:
|
|
818
|
+
|
|
819
|
+
|type|description|
|
|
820
|
+
|----|-----------|
|
|
821
|
+
|`Map<a, b>`|A new map with the value at the given key modified according to the function's output|
|
|
822
|
+
|
|
823
|
+
#### Map.Immutable.**forEach**
|
|
824
|
+
|
|
825
|
+
<details>
|
|
826
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
827
|
+
<table>
|
|
828
|
+
<thead>
|
|
829
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
830
|
+
</thead>
|
|
831
|
+
<tbody>
|
|
832
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
833
|
+
</tbody>
|
|
834
|
+
</table>
|
|
835
|
+
</details>
|
|
836
|
+
|
|
837
|
+
```grain
|
|
838
|
+
forEach : (fn: ((a, b) => Void), map: Map<a, b>) => Void
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
Iterates the map, calling an iterator function with each key and value.
|
|
842
|
+
|
|
843
|
+
Parameters:
|
|
844
|
+
|
|
845
|
+
|param|type|description|
|
|
846
|
+
|-----|----|-----------|
|
|
847
|
+
|`fn`|`(a, b) => Void`|The iterator function to call with each key and value|
|
|
848
|
+
|`map`|`Map<a, b>`|The map to iterate|
|
|
849
|
+
|
|
850
|
+
#### Map.Immutable.**reduce**
|
|
851
|
+
|
|
852
|
+
<details>
|
|
853
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
854
|
+
<table>
|
|
855
|
+
<thead>
|
|
856
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
857
|
+
</thead>
|
|
858
|
+
<tbody>
|
|
859
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
860
|
+
</tbody>
|
|
861
|
+
</table>
|
|
862
|
+
</details>
|
|
863
|
+
|
|
864
|
+
```grain
|
|
865
|
+
reduce : (fn: ((a, b, c) => a), init: a, map: Map<b, c>) => a
|
|
866
|
+
```
|
|
867
|
+
|
|
868
|
+
Combines all key-value pairs of a map using a reducer function.
|
|
869
|
+
|
|
870
|
+
Parameters:
|
|
871
|
+
|
|
872
|
+
|param|type|description|
|
|
873
|
+
|-----|----|-----------|
|
|
874
|
+
|`fn`|`(a, b, c) => a`|The reducer function to call on each key and value, where the value returned will be the next accumulator value|
|
|
875
|
+
|`init`|`a`|The initial value to use for the accumulator on the first iteration|
|
|
876
|
+
|`map`|`Map<b, c>`|The map to iterate|
|
|
877
|
+
|
|
878
|
+
Returns:
|
|
879
|
+
|
|
880
|
+
|type|description|
|
|
881
|
+
|----|-----------|
|
|
882
|
+
|`a`|The final accumulator returned from `fn`|
|
|
883
|
+
|
|
884
|
+
#### Map.Immutable.**keys**
|
|
885
|
+
|
|
886
|
+
<details>
|
|
887
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
888
|
+
<table>
|
|
889
|
+
<thead>
|
|
890
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
891
|
+
</thead>
|
|
892
|
+
<tbody>
|
|
893
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
894
|
+
</tbody>
|
|
895
|
+
</table>
|
|
896
|
+
</details>
|
|
897
|
+
|
|
898
|
+
```grain
|
|
899
|
+
keys : (map: Map<a, b>) => List<a>
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
Enumerates all keys in the given map.
|
|
903
|
+
|
|
904
|
+
Parameters:
|
|
905
|
+
|
|
906
|
+
|param|type|description|
|
|
907
|
+
|-----|----|-----------|
|
|
908
|
+
|`map`|`Map<a, b>`|The map to enumerate|
|
|
909
|
+
|
|
910
|
+
Returns:
|
|
911
|
+
|
|
912
|
+
|type|description|
|
|
913
|
+
|----|-----------|
|
|
914
|
+
|`List<a>`|A list containing all keys from the given map|
|
|
915
|
+
|
|
916
|
+
#### Map.Immutable.**values**
|
|
917
|
+
|
|
918
|
+
<details>
|
|
919
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
920
|
+
<table>
|
|
921
|
+
<thead>
|
|
922
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
923
|
+
</thead>
|
|
924
|
+
<tbody>
|
|
925
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
926
|
+
</tbody>
|
|
927
|
+
</table>
|
|
928
|
+
</details>
|
|
929
|
+
|
|
930
|
+
```grain
|
|
931
|
+
values : (map: Map<a, b>) => List<b>
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
Enumerates all values in the given map.
|
|
935
|
+
|
|
936
|
+
Parameters:
|
|
937
|
+
|
|
938
|
+
|param|type|description|
|
|
939
|
+
|-----|----|-----------|
|
|
940
|
+
|`map`|`Map<a, b>`|The map to enumerate|
|
|
941
|
+
|
|
942
|
+
Returns:
|
|
943
|
+
|
|
944
|
+
|type|description|
|
|
945
|
+
|----|-----------|
|
|
946
|
+
|`List<b>`|A list containing all values from the given map|
|
|
947
|
+
|
|
948
|
+
#### Map.Immutable.**filter**
|
|
949
|
+
|
|
950
|
+
<details>
|
|
951
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
952
|
+
<table>
|
|
953
|
+
<thead>
|
|
954
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
955
|
+
</thead>
|
|
956
|
+
<tbody>
|
|
957
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
958
|
+
</tbody>
|
|
959
|
+
</table>
|
|
960
|
+
</details>
|
|
961
|
+
|
|
962
|
+
```grain
|
|
963
|
+
filter : (fn: ((a, b) => Bool), map: Map<a, b>) => Map<a, b>
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
Produces a new map excluding the key-value pairs where a predicate function returns `false`.
|
|
967
|
+
|
|
968
|
+
Parameters:
|
|
969
|
+
|
|
970
|
+
|param|type|description|
|
|
971
|
+
|-----|----|-----------|
|
|
972
|
+
|`fn`|`(a, b) => Bool`|The predicate function to indicate which key-value pairs to exclude from the map, where returning `false` indicates the key-value pair should be excluded|
|
|
973
|
+
|`map`|`Map<a, b>`|The map to iterate|
|
|
974
|
+
|
|
975
|
+
Returns:
|
|
976
|
+
|
|
977
|
+
|type|description|
|
|
978
|
+
|----|-----------|
|
|
979
|
+
|`Map<a, b>`|A new map excluding the key-value pairs not fulfilling the predicate|
|
|
980
|
+
|
|
981
|
+
#### Map.Immutable.**reject**
|
|
982
|
+
|
|
983
|
+
<details>
|
|
984
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
985
|
+
<table>
|
|
986
|
+
<thead>
|
|
987
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
988
|
+
</thead>
|
|
989
|
+
<tbody>
|
|
990
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
991
|
+
</tbody>
|
|
992
|
+
</table>
|
|
993
|
+
</details>
|
|
994
|
+
|
|
995
|
+
```grain
|
|
996
|
+
reject : (fn: ((a, b) => Bool), map: Map<a, b>) => Map<a, b>
|
|
997
|
+
```
|
|
998
|
+
|
|
999
|
+
Produces a new map excluding the key-value pairs where a predicate function returns `true`.
|
|
1000
|
+
|
|
1001
|
+
Parameters:
|
|
1002
|
+
|
|
1003
|
+
|param|type|description|
|
|
1004
|
+
|-----|----|-----------|
|
|
1005
|
+
|`fn`|`(a, b) => Bool`|The predicate function to indicate which key-value pairs to exclude from the map, where returning `true` indicates the key-value pair should be excluded|
|
|
1006
|
+
|`map`|`Map<a, b>`|The map to iterate|
|
|
1007
|
+
|
|
1008
|
+
Returns:
|
|
1009
|
+
|
|
1010
|
+
|type|description|
|
|
1011
|
+
|----|-----------|
|
|
1012
|
+
|`Map<a, b>`|A new map excluding the key-value pairs fulfilling the predicate|
|
|
1013
|
+
|
|
1014
|
+
#### Map.Immutable.**fromList**
|
|
1015
|
+
|
|
1016
|
+
<details>
|
|
1017
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
1018
|
+
<table>
|
|
1019
|
+
<thead>
|
|
1020
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
1021
|
+
</thead>
|
|
1022
|
+
<tbody>
|
|
1023
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
1024
|
+
</tbody>
|
|
1025
|
+
</table>
|
|
1026
|
+
</details>
|
|
1027
|
+
|
|
1028
|
+
```grain
|
|
1029
|
+
fromList : (list: List<(a, b)>) => Map<a, b>
|
|
1030
|
+
```
|
|
1031
|
+
|
|
1032
|
+
Creates a map from a list.
|
|
1033
|
+
|
|
1034
|
+
Parameters:
|
|
1035
|
+
|
|
1036
|
+
|param|type|description|
|
|
1037
|
+
|-----|----|-----------|
|
|
1038
|
+
|`list`|`List<(a, b)>`|The list to convert|
|
|
1039
|
+
|
|
1040
|
+
Returns:
|
|
1041
|
+
|
|
1042
|
+
|type|description|
|
|
1043
|
+
|----|-----------|
|
|
1044
|
+
|`Map<a, b>`|A map containing all key-value pairs from the list|
|
|
1045
|
+
|
|
1046
|
+
#### Map.Immutable.**toList**
|
|
1047
|
+
|
|
1048
|
+
<details>
|
|
1049
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
1050
|
+
<table>
|
|
1051
|
+
<thead>
|
|
1052
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
1053
|
+
</thead>
|
|
1054
|
+
<tbody>
|
|
1055
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
1056
|
+
</tbody>
|
|
1057
|
+
</table>
|
|
1058
|
+
</details>
|
|
1059
|
+
|
|
1060
|
+
```grain
|
|
1061
|
+
toList : (map: Map<a, b>) => List<(a, b)>
|
|
1062
|
+
```
|
|
1063
|
+
|
|
1064
|
+
Enumerates all key-value pairs in the given map.
|
|
1065
|
+
|
|
1066
|
+
Parameters:
|
|
1067
|
+
|
|
1068
|
+
|param|type|description|
|
|
1069
|
+
|-----|----|-----------|
|
|
1070
|
+
|`map`|`Map<a, b>`|The map to enumerate|
|
|
1071
|
+
|
|
1072
|
+
Returns:
|
|
1073
|
+
|
|
1074
|
+
|type|description|
|
|
1075
|
+
|----|-----------|
|
|
1076
|
+
|`List<(a, b)>`|A list containing all key-value pairs from the given map|
|
|
1077
|
+
|
|
1078
|
+
#### Map.Immutable.**fromArray**
|
|
1079
|
+
|
|
1080
|
+
<details>
|
|
1081
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
1082
|
+
<table>
|
|
1083
|
+
<thead>
|
|
1084
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
1085
|
+
</thead>
|
|
1086
|
+
<tbody>
|
|
1087
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
1088
|
+
</tbody>
|
|
1089
|
+
</table>
|
|
1090
|
+
</details>
|
|
1091
|
+
|
|
1092
|
+
```grain
|
|
1093
|
+
fromArray : (array: Array<(a, b)>) => Map<a, b>
|
|
1094
|
+
```
|
|
1095
|
+
|
|
1096
|
+
Creates a map from an array.
|
|
1097
|
+
|
|
1098
|
+
Parameters:
|
|
1099
|
+
|
|
1100
|
+
|param|type|description|
|
|
1101
|
+
|-----|----|-----------|
|
|
1102
|
+
|`array`|`Array<(a, b)>`|The array to convert|
|
|
1103
|
+
|
|
1104
|
+
Returns:
|
|
1105
|
+
|
|
1106
|
+
|type|description|
|
|
1107
|
+
|----|-----------|
|
|
1108
|
+
|`Map<a, b>`|A map containing all key-value pairs from the array|
|
|
1109
|
+
|
|
1110
|
+
#### Map.Immutable.**toArray**
|
|
1111
|
+
|
|
1112
|
+
<details>
|
|
1113
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
1114
|
+
<table>
|
|
1115
|
+
<thead>
|
|
1116
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
1117
|
+
</thead>
|
|
1118
|
+
<tbody>
|
|
1119
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutablemap"` module</td></tr>
|
|
1120
|
+
</tbody>
|
|
1121
|
+
</table>
|
|
1122
|
+
</details>
|
|
1123
|
+
|
|
1124
|
+
```grain
|
|
1125
|
+
toArray : (map: Map<a, b>) => Array<(a, b)>
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
Converts a map into an array of its key-value pairs.
|
|
1129
|
+
|
|
1130
|
+
Parameters:
|
|
1131
|
+
|
|
1132
|
+
|param|type|description|
|
|
1133
|
+
|-----|----|-----------|
|
|
1134
|
+
|`map`|`Map<a, b>`|The map to convert|
|
|
1135
|
+
|
|
1136
|
+
Returns:
|
|
1137
|
+
|
|
1138
|
+
|type|description|
|
|
1139
|
+
|----|-----------|
|
|
1140
|
+
|`Array<(a, b)>`|An array containing all key-value pairs from the given map|
|
|
525
1141
|
|