@@ -3,11 +3,6 @@ A mutable dictionary with string keys.
33
44Compiles to a regular JavaScript object.*/
55
6- /**
7- Type representing a dictionary of value `'a`.
8- */
9- type t <'a > = Js .Dict .t <'a >
10-
116/**
127`getUnsafe(dict, key)` Returns the `value` at the provided `key`.
138
@@ -23,7 +18,7 @@ Console.log(value) // value1
2318```
2419*/
2520@get_index
26- external getUnsafe : (t <'a >, string ) => 'a = ""
21+ external getUnsafe : (dict <'a >, string ) => 'a = ""
2722
2823/**
2924Returns the value at the provided key, if it exists. Returns an option.
@@ -39,7 +34,7 @@ switch dict->Dict.get("someKey") {
3934```
4035*/
4136@get_index
42- external get : (t <'a >, string ) => option <'a > = ""
37+ external get : (dict <'a >, string ) => option <'a > = ""
4338
4439/**
4540`set(dictionary, key, value)` sets the value at the provided key to the provided value.
@@ -52,7 +47,7 @@ dict->Dict.set("someKey", "someValue")
5247```
5348*/
5449@set_index
55- external set : (t <'a >, string , 'a ) => unit = ""
50+ external set : (dict <'a >, string , 'a ) => unit = ""
5651
5752/**
5853`delete(dictionary, key)` deletes the value at `key`, if it exists.
@@ -64,21 +59,21 @@ let dict = Dict.fromArray([("someKey", "someValue")])
6459dict->Dict.delete("someKey")
6560```
6661*/
67- let delete : (t <'a >, string ) => unit
62+ let delete : (dict <'a >, string ) => unit
6863
6964/**
7065`make()` creates a new, empty dictionary.
7166
7267## Examples
7368```rescript
74- let dict1: Dict.t <int> = Dict.make() // You can annotate the type of the values of your dict yourself if you want
69+ let dict1: dict <int> = Dict.make() // You can annotate the type of the values of your dict yourself if you want
7570
7671let dict2 = Dict.make() // Or you can let ReScript infer it via usage.
7772dict2->Dict.set("someKey", 12)
7873```
7974*/
8075@obj
81- external make : unit => t <'a > = ""
76+ external make : unit => dict <'a > = ""
8277
8378/**
8479`fromArray(entries)` creates a new dictionary from the provided array of key/value pairs.
@@ -89,7 +84,7 @@ let dict = Dict.fromArray([("key1", "value1"), ("key2", "value2")])
8984```
9085*/
9186@val
92- external fromArray : array <(string , 'a )> => t <'a > = "Object.fromEntries"
87+ external fromArray : array <(string , 'a )> => dict <'a > = "Object.fromEntries"
9388
9489/**
9590`fromIterator(entries)` creates a new dictionary from the provided iterator of key/value pairs.
@@ -99,11 +94,11 @@ external fromArray: array<(string, 'a)> => t<'a> = "Object.fromEntries"
9994// Pretend we have an iterator of the correct shape
10095@val external someIterator: Iterator.t<(string, int)> = "someIterator"
10196
102- let dict = Dict.fromIterator(someIterator) // Dict.t <int>
97+ let dict = Dict.fromIterator(someIterator) // dict <int>
10398```
10499*/
105100@val
106- external fromIterator : Iterator .t <(string , 'a )> => t <'a > = "Object.fromEntries"
101+ external fromIterator : Iterator .t <(string , 'a )> => dict <'a > = "Object.fromEntries"
107102
108103/**
109104`toArray(dictionary)` returns an array of all the key/value pairs of the dictionary.
@@ -118,7 +113,7 @@ Console.log(asArray) // Logs `[["someKey", 1], ["someKey2", 2]]` to the console
118113```
119114*/
120115@val
121- external toArray : t <'a > => array <(string , 'a )> = "Object.entries"
116+ external toArray : dict <'a > => array <(string , 'a )> = "Object.entries"
122117
123118/**
124119`keysToArray(dictionary)` returns an array of all the keys of the dictionary.
@@ -133,7 +128,7 @@ Console.log(keys) // Logs `["someKey", "someKey2"]` to the console
133128```
134129*/
135130@val
136- external keysToArray : t <'a > => array <string > = "Object.keys"
131+ external keysToArray : dict <'a > => array <string > = "Object.keys"
137132
138133/**
139134`valuesToArray(dictionary)` returns an array of all the values of the dictionary.
@@ -148,7 +143,7 @@ Console.log(values) // Logs `[1, 2]` to the console
148143```
149144*/
150145@val
151- external valuesToArray : t <'a > => array <'a > = "Object.values"
146+ external valuesToArray : dict <'a > => array <'a > = "Object.values"
152147
153148/**
154149`assign(dictionary1, dictionary2)` [shallowly](https://developer.mozilla.org/en-US/docs/Glossary/Shallow_copy) merges dictionary2 into dictionary1, and returns dictionary1.
@@ -172,7 +167,7 @@ Console.log(dict1->Dict.keysToArray) // Logs `["firstKey", "someKey", "someKey2"
172167```
173168*/
174169@val
175- external assign : (t <'a >, t <'a >) => t <'a > = "Object.assign"
170+ external assign : (dict <'a >, dict <'a >) => dict <'a > = "Object.assign"
176171
177172/**
178173`copy(dictionary)` [shallowly copies](https://developer.mozilla.org/en-US/docs/Glossary/Shallow_copy) the provided dictionary to a new dictionary.
@@ -187,7 +182,7 @@ Console.log2(dict->Dict.keysToArray, dict2->Dict.keysToArray)
187182```
188183*/
189184@val
190- external copy : (@as (json ` {}` ) _ , t <'a >) => t <'a > = "Object.assign"
185+ external copy : (@as (json ` {}` ) _ , dict <'a >) => dict <'a > = "Object.assign"
191186
192187/**
193188`forEach(dictionary, f)` iterates through all values of the dict.
@@ -203,7 +198,7 @@ dict->Dict.forEach(value => {
203198})
204199```
205200*/
206- let forEach : (t <'a >, 'a => unit ) => unit
201+ let forEach : (dict <'a >, 'a => unit ) => unit
207202
208203/**
209204`forEachWithKey(dictionary, f)` iterates through all values of the dict, including the key for each value.
@@ -217,7 +212,7 @@ dict->Dict.forEachWithKey((value, key) => {
217212})
218213```
219214*/
220- let forEachWithKey : (t <'a >, ('a , string ) => unit ) => unit
215+ let forEachWithKey : (dict <'a >, ('a , string ) => unit ) => unit
221216
222217/**
223218`mapValues(dictionary, f)` returns a new dictionary with the same keys, and `f` applied to each value in the original dictionary.
@@ -231,4 +226,4 @@ dict->Dict.mapValues(v => v + 10)->Dict.toArray // [("key1", 11), ("key2", 12)]
231226dict->Dict.mapValues(v => Int.toString(v))->Dict.toArray // [("key1", "1"), ("key2", "2")]
232227```
233228*/
234- let mapValues : (t <'a >, 'a => 'b ) => t <'b >
229+ let mapValues : (dict <'a >, 'a => 'b ) => dict <'b >
0 commit comments