|
22 | 22 |
|
23 | 23 | @val external hasOwnProperty: ({..}, string) => bool = "Object.prototype.hasOwnProperty.call"
|
24 | 24 |
|
25 |
| -@val external seal: 'a => 'a = "Object.seal" |
| 25 | +/** |
| 26 | +`seal` seals an object. Sealing an object prevents extensions and makes existing properties non-configurable. A sealed object has a fixed set of properties. Unlike `freeze`, values of existing properties can still be changed as long as they are writable. `seal` returns the same object that was passed in. |
| 27 | + |
| 28 | +Any attempt to delete or add properties to a sealed object will fail, either silently or by throwing an error. |
| 29 | +
|
| 30 | +Rescript usually [disallows modifying objects](https://rescript-lang.org/docs/manual/latest/object#update) regardless of whether they are sealed. |
| 31 | +
|
| 32 | +## Examples |
| 33 | +
|
| 34 | +```rescript |
| 35 | +let point = {"x": 1, "y": 3}->Object.seal |
| 36 | +let pointIsSealed = point->Object.isSealed // true |
| 37 | +let fruit = {"name": "Apple" } |
| 38 | +let fruitIsSealed = fruit->Object.isSealed // false |
| 39 | +``` |
| 40 | +## Specifications |
| 41 | +- [Updating objects in Rescript](https://rescript-lang.org/docs/manual/latest/object#update) |
| 42 | +- [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.seal) |
| 43 | +- [Object.seal on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal) |
| 44 | +*/ |
| 45 | +@val |
| 46 | +external seal: 'a => 'a = "Object.seal" |
26 | 47 | @val external preventExtensions: 'a => 'a = "Object.preventExtensions"
|
27 | 48 | @val external freeze: 'a => 'a = "Object.freeze"
|
28 | 49 |
|
29 |
| -@val external isSealed: 'a => bool = "Object.isSealed" |
| 50 | +/** |
| 51 | + `isSealed` determines if an object is sealed. A sealed object has a fixed set of properties. |
| 52 | +
|
| 53 | + ## Examples |
| 54 | +
|
| 55 | + ```rescript |
| 56 | + let point = {"x": 1, "y": 3}->Object.seal |
| 57 | + let pointIsSealed = point->Object.isSealed // true |
| 58 | + let fruit = {"name": "Apple" } |
| 59 | + let fruitIsSealed = fruit->Object.isSealed // false |
| 60 | + ``` |
| 61 | + ## Specifications |
| 62 | + - [Updating objects in Rescript](https://rescript-lang.org/docs/manual/latest/object#update) |
| 63 | + - [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.issealed) |
| 64 | + - [Object.isSealed on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed) |
| 65 | + */ |
| 66 | +@val |
| 67 | +external isSealed: 'a => bool = "Object.isSealed" |
30 | 68 | @val external isFrozen: 'a => bool = "Object.isFrozen"
|
31 | 69 | @val external isExtensible: 'a => bool = "Object.isExtensible"
|
0 commit comments