| 29 | static std::vector<uint16_t> ToVector(const std::string &value); |
| 30 | |
| 31 | inline static std::string ToString(v8::Isolate *isolate, const v8::Local<v8::Value> &value) { |
| 32 | if (value.IsEmpty()) { |
| 33 | return std::string(); |
| 34 | } |
| 35 | |
| 36 | if (value->IsStringObject()) { |
| 37 | v8::Local<v8::String> obj = value.As<v8::StringObject>()->ValueOf(); |
| 38 | return ToString(isolate, obj); |
| 39 | } |
| 40 | |
| 41 | v8::String::Utf8Value result(isolate, value); |
| 42 | |
| 43 | const char *val = *result; |
| 44 | if (val == nullptr) { |
| 45 | return std::string(); |
| 46 | } |
| 47 | |
| 48 | return std::string(*result, result.length()); |
| 49 | } |
| 50 | |
| 51 | }; |
| 52 | |