node_api_symbol_for
napi_status node_api_symbol_for(napi_env env,
const char* utf8description,
size_t length,
napi_value* result) -
[in] env:调用 API 的环境。¥
[in] env: The environment that the API is invoked under. -
[in] utf8description:UTF-8 C 字符串,表示用作符号描述的文本。¥
[in] utf8description: UTF-8 C string representing the text to be used as the description for the symbol. -
[in] length:描述字符串的长度(以字节为单位),如果它以 null 结尾则为NAPI_AUTO_LENGTH。¥
[in] length: The length of the description string in bytes, orNAPI_AUTO_LENGTHif it is null-terminated. -
[out] result:代表 JavaScriptsymbol的napi_value。¥
[out] result: Anapi_valuerepresenting a JavaScriptsymbol.
如果 API 成功,则返回 napi_ok。
¥Returns napi_ok if the API succeeded.
此 API 在全局注册表中搜索具有给定描述的现有符号。如果该符号已经存在,它将被返回,否则将在注册表中创建一个新符号。
¥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.
JavaScript symbol 类型在 ECMAScript 语言规范的 符号类型部分 中进行了描述。
¥The JavaScript symbol type is described in Section symbol type of the ECMAScript
Language Specification.