MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / Finish

Method Finish

node/opencc.cc:231–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229 }
230
231 Napi::Value Finish(const Napi::CallbackInfo& info) {
232 Napi::Env env = info.Env();
233 if (info.Length() >= 1 && !info[0].IsBuffer() && !info[0].IsString()) {
234 Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
235 return env.Undefined();
236 }
237
238 try {
239 if (info.Length() >= 1 && info[0].IsBuffer()) {
240 Napi::Buffer<char> input = info[0].As<Napi::Buffer<char>>();
241 return Napi::String::New(
242 env, stream_->Finish({input.Data(), input.Length()}));
243 }
244 if (info.Length() >= 1) {
245 const std::string input = ToUtf8String(info[0]);
246 return Napi::String::New(env, stream_->Finish(input));
247 }
248 return Napi::String::New(env, stream_->Finish());
249 } catch (opencc::Exception& e) {
250 Napi::Error::New(env, e.what()).ThrowAsJavaScriptException();
251 return env.Undefined();
252 }
253 }
254
255 static Napi::Object Init(Napi::Env env, Napi::Object exports) {
256 Napi::Function cons = DefineClass(

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
ToUtf8StringFunction · 0.85
LengthMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected