@@ -21,19 +21,21 @@ Value EchoString(const CallbackInfo& info) {
21
21
22
22
Value CreateString (const CallbackInfo& info) {
23
23
String encoding = info[0 ].As <String>();
24
- Number length = info[1 ]. As <Number>() ;
24
+ Value length = info[1 ];
25
25
26
26
if (encoding.Utf8Value () == " utf8" ) {
27
27
if (length.IsUndefined ()) {
28
28
return String::New (info.Env (), testValueUtf8);
29
29
} else {
30
- return String::New (info.Env (), testValueUtf8, length.Uint32Value ());
30
+ return String::New (
31
+ info.Env (), testValueUtf8, length.As <Number>().Uint32Value ());
31
32
}
32
33
} else if (encoding.Utf8Value () == " utf16" ) {
33
34
if (length.IsUndefined ()) {
34
35
return String::New (info.Env (), testValueUtf16);
35
36
} else {
36
- return String::New (info.Env (), testValueUtf16, length.Uint32Value ());
37
+ return String::New (
38
+ info.Env (), testValueUtf16, length.As <Number>().Uint32Value ());
37
39
}
38
40
} else {
39
41
Error::New (info.Env (), " Invalid encoding." ).ThrowAsJavaScriptException ();
@@ -44,20 +46,20 @@ Value CreateString(const CallbackInfo& info) {
44
46
Value CheckString (const CallbackInfo& info) {
45
47
String value = info[0 ].As <String>();
46
48
String encoding = info[1 ].As <String>();
47
- Number length = info[2 ]. As <Number>() ;
49
+ Value length = info[2 ];
48
50
49
51
if (encoding.Utf8Value () == " utf8" ) {
50
52
std::string testValue = testValueUtf8;
51
53
if (!length.IsUndefined ()) {
52
- testValue = testValue.substr (0 , length.Uint32Value ());
54
+ testValue = testValue.substr (0 , length.As <Number>(). Uint32Value ());
53
55
}
54
56
55
57
std::string stringValue = value;
56
58
return Boolean::New (info.Env (), stringValue == testValue);
57
59
} else if (encoding.Utf8Value () == " utf16" ) {
58
60
std::u16string testValue = testValueUtf16;
59
61
if (!length.IsUndefined ()) {
60
- testValue = testValue.substr (0 , length.Uint32Value ());
62
+ testValue = testValue.substr (0 , length.As <Number>(). Uint32Value ());
61
63
}
62
64
63
65
std::u16string stringValue = value;
@@ -69,10 +71,10 @@ Value CheckString(const CallbackInfo& info) {
69
71
}
70
72
71
73
Value CreateSymbol (const CallbackInfo& info) {
72
- String description = info[0 ]. As <String>() ;
74
+ Value description = info[0 ];
73
75
74
76
if (!description.IsUndefined ()) {
75
- return Symbol::New (info.Env (), description);
77
+ return Symbol::New (info.Env (), description. As <String>() );
76
78
} else {
77
79
return Symbol::New (info.Env ());
78
80
}
0 commit comments