This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
eval.d.ts
50 lines (47 loc) · 1.52 KB
/
eval.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/// <reference types="node" />
import { Script } from "vm";
/**
* A simple way to evaluate a module content in the same way as require() but
* without loading it from a file. Effectively, it mimicks the javascript evil
* `eval` function but leverages Node's VM module instead.
*/
declare const nodeEval: {
(
/** The content to be evaluated. */
content: string | Buffer | Script,
): unknown;
(
/** The content to be evaluated. */
content: string | Buffer | Script,
/**
* Optional flag to allow/disallow global variables (and require) to be
* supplied to the content (default=false).
*/
includeGlobals?: boolean,
): unknown;
(
/** The content to be evaluated. */
content: string | Buffer | Script,
/** Optional scope properties are provided as variables to the content. */
scope?: Record<string, unknown>,
/**
* Optional flag to allow/disallow global variables (and require) to be
* supplied to the content (default=false).
*/
includeGlobals?: boolean,
): unknown;
(
/** The content to be evaluated. */
content: string | Buffer | Script,
/** Optional dummy name to be given (used in stacktraces). */
filename?: string,
/** Optional scope properties are provided as variables to the content. */
scope?: Record<string, unknown>,
/**
* Optional flag to allow/disallow global variables (and require) to be
* supplied to the content (default=false).
*/
includeGlobals?: boolean,
): unknown;
};
export = nodeEval;