From 0d602fc9aa7be629fa3e0f751d4ff2df4072806d Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Sat, 1 Jan 2022 12:55:20 +0530 Subject: [PATCH] src: add napi_get_symbol_to_string_tag Fixes: https://github.com/nodejs/node/issues/41358 Signed-off-by: Darshan Sen --- doc/api/n-api.md | 24 ++++++++++++ src/js_native_api.h | 4 ++ src/js_native_api_v8.cc | 11 ++++++ test/js-native-api/test_properties/test.js | 10 ++--- .../test_properties/test_properties.c | 6 +++ test/js-native-api/test_reference/test.js | 7 ++++ .../test_reference/test_reference.c | 8 ++++ test/js-native-api/test_symbol/test4.js | 39 +++++++++++++++++++ test/js-native-api/test_symbol/test_symbol.c | 8 ++++ 9 files changed, 111 insertions(+), 6 deletions(-) create mode 100644 test/js-native-api/test_symbol/test4.js diff --git a/doc/api/n-api.md b/doc/api/n-api.md index c146a6d661dddb..1b7f51a3c8b7f1 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -2492,6 +2492,30 @@ 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. +#### `napi_get_symbol_to_string_tag` + + + +> Stability: 1 - Experimental + +```c +napi_status napi_get_symbol_to_string_tag(napi_env env, + napi_value* result) +``` + +* `[in] env`: The environment that the API is invoked under. +* `[out] result`: A `napi_value` representing a JavaScript `symbol`. + +Returns `napi_ok` if the API succeeded. + +This API returns the JavaScript well-known symbol, `Symbol.toStringTag`. + +The JavaScript `symbol` type is described in [Section 19.4][] +of the ECMAScript Language Specification. + #### `napi_create_typedarray`