diff options
author | Shelley Vohr <shelley.vohr@gmail.com> | 2020-09-26 08:11:13 +0300 |
---|---|---|
committer | Beth Griggs <Bethany.Griggs@uk.ibm.com> | 2020-10-14 01:58:03 +0300 |
commit | c995242068f364292bf90c6f5a5fa6bda662896d (patch) | |
tree | 3dd6a013a796e52833fcc0ffe48790ac76f984b9 /doc | |
parent | 887743053085a0378d5c7f8000f51abef30568b3 (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')
-rw-r--r-- | doc/api/n-api.md | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/doc/api/n-api.md b/doc/api/n-api.md index e6ff1f393fb..3867f9f4375 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -4209,6 +4209,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 |