Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShelley Vohr <shelley.vohr@gmail.com>2020-09-26 08:11:13 +0300
committerShelley Vohr <shelley.vohr@gmail.com>2020-10-07 18:31:43 +0300
commit19f14517c7637b0e277b4fc3fdfe4473e5cc1262 (patch)
tree491c0bb12fc386b26b2a3e5b85c0d55ab32a7f27 /doc/api/n-api.md
parentc208a20f9c4bdf4d8dc57d14629dd296b8681327 (diff)
n-api: support for object freeze/seal
PR-URL: https://github.com/nodejs/node/pull/35359 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'doc/api/n-api.md')
-rw-r--r--doc/api/n-api.md47
1 files changed, 47 insertions, 0 deletions
diff --git a/doc/api/n-api.md b/doc/api/n-api.md
index c7ec9a14d3f..7ee1fd2e942 100644
--- a/doc/api/n-api.md
+++ b/doc/api/n-api.md
@@ -4227,6 +4227,53 @@ this API will set the properties on the object one at a time, as defined by
`DefineOwnProperty()` (described in [Section 9.1.6][] of the ECMA-262
specification).
+#### napi_object_freeze
+<!-- YAML
+added: REPLACEME
+-->
+
+> Stability: 1 - Experimental
+
+```c
+napi_status napi_object_freeze(napi_env env,
+ napi_value object);
+```
+
+* `[in] env`: The environment that the N-API call is invoked under.
+* `[in] object`: The object to freeze.
+
+Returns `napi_ok` if the API succeeded.
+
+This method freezes a given object. This prevents new properties from
+being added to it, existing properties from being removed, prevents
+changing the enumerability, configurability, or writability of existing
+properties, and prevents the values of existing properties from being changed.
+It also prevents the object's prototype from being changed. This is described
+in [Section 19.1.2.6](https://tc39.es/ecma262/#sec-object.freeze) of the
+ECMA-262 specification.
+
+#### napi_object_seal
+<!-- YAML
+added: REPLACEME
+-->
+
+> Stability: 1 - Experimental
+
+```c
+napi_status napi_object_seal(napi_env env,
+ napi_value object);
+```
+
+* `[in] env`: The environment that the N-API call is invoked under.
+* `[in] object`: The object to seal.
+
+Returns `napi_ok` if the API succeeded.
+
+This method seals a given object. This prevents new properties from being
+added to it, as well as marking all existing properties as non-configurable.
+This is described in [Section 19.1.2.20](https://tc39.es/ecma262/#sec-object.seal)
+of the ECMA-262 specification.
+
## Working with JavaScript functions
N-API provides a set of APIs that allow JavaScript code to