diff options
author | Shelley Vohr <shelley.vohr@gmail.com> | 2020-09-25 22:11:13 -0700 |
---|---|---|
committer | Myles Borins <mylesborins@github.com> | 2020-11-16 11:57:59 -0500 |
commit | 5faaa603d84af583ddd3c68d64183e9531008b84 (patch) | |
tree | dce1876b63d97cecd8d58246b52a94b3355dc543 /doc | |
parent | 6952c4520215fca4a5adb916f70bd5c74bd4cc2a (diff) | |
download | node-new-5faaa603d84af583ddd3c68d64183e9531008b84.tar.gz |
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 a8620c209c..5cfebd60dc 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -4092,6 +4092,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 |