UNPKG

1.29 kBMarkdownView Raw
1## Script
2
3NAN provides a `v8::Script` helpers as the API has changed over the supported versions of V8.
4
5 - <a href="#api_nan_compile_script"><b><code>Nan::CompileScript()</code></b></a>
6 - <a href="#api_nan_run_script"><b><code>Nan::RunScript()</code></b></a>
7
8
9<a name="api_nan_compile_script"></a>
10### Nan::CompileScript()
11
12A wrapper around [`v8::ScriptCompiler::Compile()`](https://v8docs.nodesource.com/node-8.11/da/da5/classv8_1_1_script_compiler.html#a93f5072a0db55d881b969e9fc98e564b).
13
14Note that `Nan::BoundScript` is an alias for `v8::Script`.
15
16Signature:
17
18```c++
19Nan::MaybeLocal<Nan::BoundScript> Nan::CompileScript(
20 v8::Local<v8::String> s,
21 const v8::ScriptOrigin& origin);
22Nan::MaybeLocal<Nan::BoundScript> Nan::CompileScript(v8::Local<v8::String> s);
23```
24
25
26<a name="api_nan_run_script"></a>
27### Nan::RunScript()
28
29Calls `script->Run()` or `script->BindToCurrentContext()->Run(Nan::GetCurrentContext())`.
30
31Note 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.
32
33Signature:
34
35```c++
36Nan::MaybeLocal<v8::Value> Nan::RunScript(v8::Local<Nan::UnboundScript> script)
37Nan::MaybeLocal<v8::Value> Nan::RunScript(v8::Local<Nan::BoundScript> script)
38```