You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.0 KiB

Script

NAN provides 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)

Nan::ScriptOrigin

A class transparently extending v8::ScriptOrigin to provide backwards compatibility. Only the listed methods are guaranteed to be available on all versions of Node.

Declaration:

class Nan::ScriptOrigin : public v8::ScriptOrigin {
 public:
  ScriptOrigin(v8::Local<v8::Value> name, v8::Local<v8::Integer> line = v8::Local<v8::Integer>(), v8::Local<v8::Integer> column = v8::Local<v8::Integer>())
  v8::Local<v8::Value> ResourceName() const;
  v8::Local<v8::Integer> ResourceLineOffset() const;
  v8::Local<v8::Integer> ResourceColumnOffset() const;
}