Skip to content

Commit 25aa2a6

Browse files
glennslillusionalsagacity
authored andcommitted
Rename Object.empty to Object.make (rescript-lang#193)
* refactor(object): empty -> make * docs: update changelog
1 parent 246f9a3 commit 25aa2a6

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- BREAKING: Fixes the type of `RegExp.Result.t` to be `array<option<string>>` instead of `array<string>`. https://github.com/rescript-association/rescript-core/pull/233.
66
- Add `Dict.forEach`, `Dict.forEachWithKey` and `Dict.mapValues` https://github.com/rescript-association/rescript-core/pull/181
7+
- Remove internal xxxU helper functions that are not needed anymore in uncurried mode. https://github.com/rescript-association/rescript-core/pull/191
8+
- Rename `Object.empty` to `Object.make` for consistency.
79

810
## 0.7.0
911

src/Core__Object.res

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/**
2-
`empty` create a new object that inherits the properties and methods from the standard built-in Object, such as `toString`. See [Object on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
2+
`make` create a new object that inherits the properties and methods from the standard built-in Object, such as `toString`. See [Object on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
33
44
## Examples
55
66
```rescript
7-
let x = Object.empty()
7+
let x = Object.make()
88
x->Object.keysToArray->Array.length // 0
99
x->Object.get("toString")->Option.isSome // true
1010
```
1111
*/
1212
@obj
13-
external empty: unit => {..} = ""
13+
external make: unit => {..} = ""
1414

1515
/**
1616
`is` determines if two objects are identical in all contexts. Objects, arrays, records, and other non-primitives are only identical if they reference the **exact** same object in memory. Primitives like ints, floats, and strings are identical if they have the same value. `+0` and `-0` are distinct. NaN is equal to itself. See [Object.is on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
@@ -117,7 +117,7 @@ external get: ({..}, string) => option<'a> = ""
117117
118118
```rescript
119119
let fruit = Symbol.make("fruit")
120-
let x = Object.empty()
120+
let x = Object.make()
121121
x->Object.setSymbol(fruit, "banana")
122122
x->Object.getSymbol(fruit) // Some("banana")
123123
```
@@ -152,7 +152,7 @@ or [Object.keys on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/
152152
```rescript
153153
{"a": 1, "b": 2}->Object.keysToArray // ["a", "b"]
154154
{"a": None}->Object.keysToArray // ["a"]
155-
Object.empty()->Object.keysToArray // []
155+
Object.make()->Object.keysToArray // []
156156
```
157157
*/
158158
@val

test/ObjectTests.res

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Test.run(__POS_OF__("is: date"), Object.is(d, d), eq, true)
4040
let x = {"a": 1}
4141
Test.run(__POS_OF__("is: objects"), Object.is(x, x), eq, true)
4242
Test.run(__POS_OF__("is: objects"), Object.is({"a": 1}, {"a": 1}), eq, false)
43-
Test.run(__POS_OF__("is: objects"), Object.is(Object.empty(), Object.empty()), eq, false) // hmm...
43+
Test.run(__POS_OF__("is: objects"), Object.is(Object.make(), Object.make()), eq, false) // hmm...
4444
Test.run(__POS_OF__("is: === and == operator"), x === x, eq, true)
4545
Test.run(__POS_OF__("is: === and == operator"), x == x, eq, true)
4646
Test.run(__POS_OF__("is: === and == operator"), {"a": 1} == {"a": 1}, eq, true)
@@ -142,7 +142,7 @@ let runGetTest = i =>
142142
// ===== getSymbol =====
143143

144144
let getSymbolTestWhenExists = () => {
145-
let obj = Object.empty()
145+
let obj = Object.make()
146146
let fruit = Symbol.make("fruit")
147147
obj->Object.setSymbol(fruit, "banana")
148148
let retrieved = obj->Object.getSymbol(fruit)
@@ -157,7 +157,7 @@ getSymbolTestWhenExists()
157157

158158
Test.run(
159159
__POS_OF__(`Object.getSymbol when not exists return it as None`),
160-
Object.empty()->Object.getSymbol(Symbol.make("fruit")),
160+
Object.make()->Object.getSymbol(Symbol.make("fruit")),
161161
eq,
162162
None,
163163
)

test/Test.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ${codeFrame}
3939
`
4040
Console.log(errorMessage)
4141
// API: https://nodejs.org/api/errors.html#errors_error_capturestacktrace_targetobject_constructoropt
42-
let obj = Object.empty()
42+
let obj = Object.make()
4343
captureStackTrace(obj)
4444
// clean up stack trace! Stack format: https://nodejs.org/api/errors.html#errors_error_stack
4545
obj["stack"]

0 commit comments

Comments
 (0)