11#include " napi.h"
22
3+ #include < string_view>
4+
35using namespace Napi ;
46
57const char * testValueUtf8 = " 123456789" ;
@@ -43,6 +45,10 @@ Value CreateString(const CallbackInfo& info) {
4345 }
4446}
4547
48+ Value CreateStringFromStringView (const CallbackInfo& info) {
49+ return String::New (info.Env (), std::string_view (" hello1" ));
50+ }
51+
4652Value CheckString (const CallbackInfo& info) {
4753 String value = info[0 ].As <String>();
4854 String encoding = info[1 ].As <String>();
@@ -80,6 +86,10 @@ Value CreateSymbol(const CallbackInfo& info) {
8086 }
8187}
8288
89+ Value CreateSymbolFromStringView (const CallbackInfo& info) {
90+ return Symbol::New (info.Env (), std::string_view (" hello2" ));
91+ }
92+
8393Value CheckSymbol (const CallbackInfo& info) {
8494 return Boolean::New (info.Env (), info[0 ].Type () == napi_symbol);
8595}
@@ -99,11 +109,15 @@ Object InitName(Env env) {
99109
100110 exports[" echoString" ] = Function::New (env, EchoString);
101111 exports[" createString" ] = Function::New (env, CreateString);
112+ exports[" createStringFromStringView" ] =
113+ Function::New (env, CreateStringFromStringView);
102114 exports[" nullStringShouldThrow" ] = Function::New (env, NullStringShouldThrow);
103115 exports[" nullString16ShouldThrow" ] =
104116 Function::New (env, NullString16ShouldThrow);
105117 exports[" checkString" ] = Function::New (env, CheckString);
106118 exports[" createSymbol" ] = Function::New (env, CreateSymbol);
119+ exports[" createSymbolFromStringView" ] =
120+ Function::New (env, CreateSymbolFromStringView);
107121 exports[" checkSymbol" ] = Function::New (env, CheckSymbol);
108122
109123 return exports;
0 commit comments