1 |
3a515b92
|
cagy
|
## Script
|
2 |
|
|
|
3 |
|
|
NAN 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 |
|
|
|
12 |
|
|
A wrapper around [`v8::ScriptCompiler::Compile()`](https://v8docs.nodesource.com/node-8.11/da/da5/classv8_1_1_script_compiler.html#a93f5072a0db55d881b969e9fc98e564b).
|
13 |
|
|
|
14 |
|
|
Note that `Nan::BoundScript` is an alias for `v8::Script`.
|
15 |
|
|
|
16 |
|
|
Signature:
|
17 |
|
|
|
18 |
|
|
```c++
|
19 |
|
|
Nan::MaybeLocal<Nan::BoundScript> Nan::CompileScript(
|
20 |
|
|
v8::Local<v8::String> s,
|
21 |
|
|
const v8::ScriptOrigin& origin);
|
22 |
|
|
Nan::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 |
|
|
|
29 |
|
|
Calls `script->Run()` or `script->BindToCurrentContext()->Run(Nan::GetCurrentContext())`.
|
30 |
|
|
|
31 |
|
|
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.
|
32 |
|
|
|
33 |
|
|
Signature:
|
34 |
|
|
|
35 |
|
|
```c++
|
36 |
|
|
Nan::MaybeLocal<v8::Value> Nan::RunScript(v8::Local<Nan::UnboundScript> script)
|
37 |
|
|
Nan::MaybeLocal<v8::Value> Nan::RunScript(v8::Local<Nan::BoundScript> script)
|
38 |
|
|
```
|