diff options
author | Darshan Sen <darshan.sen@postman.com> | 2021-12-26 15:00:56 +0300 |
---|---|---|
committer | Michael Dawson <mdawson@devrus.com> | 2022-01-25 00:35:07 +0300 |
commit | 726711fe4e2de7992b2ecc6921d3b083be41f950 (patch) | |
tree | 72d411f62e3690c48f397ad6e355d36cd511e49a /doc | |
parent | 3657c14598866e69f2fd97a5565cabf17d5ec675 (diff) |
node-api: add node_api_symbol_for()
Fixes: https://github.com/nodejs/node/issues/41294
Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/41329
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/n-api.md | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 7955d0442b5..e7b061cf079 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -2492,6 +2492,38 @@ This API creates a JavaScript `symbol` value from a UTF8-encoded C string. The JavaScript `symbol` type is described in [Section 19.4][] of the ECMAScript Language Specification. +#### `node_api_symbol_for` + +<!-- YAML +added: REPLACEME +napiVersion: REPLACEME +--> + +> Stability: 1 - Experimental + +```c +napi_status node_api_symbol_for(napi_env env, + const char* utf8description, + size_t length, + napi_value* result) +``` + +* `[in] env`: The environment that the API is invoked under. +* `[in] utf8description`: UTF-8 C string representing the text to be used as the + description for the symbol. +* `[in] length`: The length of the description string in bytes, or + `NAPI_AUTO_LENGTH` if it is null-terminated. +* `[out] result`: A `napi_value` representing a JavaScript `symbol`. + +Returns `napi_ok` if the API succeeded. + +This API searches in the global registry for an existing symbol with the given +description. If the symbol already exists it will be returned, otherwise a new +symbol will be created in the registry. + +The JavaScript `symbol` type is described in [Section 19.4][] of the ECMAScript +Language Specification. + #### `napi_create_typedarray` <!-- YAML |