script.md 1.3 KB

Script

NAN provides a v8::Script helpers as the API has changed over the supported versions of V8.

Nan::CompileScript()

A wrapper around v8::ScriptCompiler::Compile().

Note that Nan::BoundScript is an alias for v8::Script.

Signature:

Nan::MaybeLocal<Nan::BoundScript> Nan::CompileScript(
    v8::Local<v8::String> s,
    const v8::ScriptOrigin& origin);
Nan::MaybeLocal<Nan::BoundScript> Nan::CompileScript(v8::Local<v8::String> s);

Nan::RunScript()

Calls script->Run() or script->BindToCurrentContext()->Run(Nan::GetCurrentContext()).

Note that Nan::BoundScript is an alias for v8::Script and Nan::UnboundScript is an alias for v8::UnboundScript where available and v8::Script on older versions of V8.

Signature:

Nan::MaybeLocal<v8::Value> Nan::RunScript(v8::Local<Nan::UnboundScript> script)
Nan::MaybeLocal<v8::Value> Nan::RunScript(v8::Local<Nan::BoundScript> script)