sval 0.6.9 → 0.6.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(git pull:*)",
5
+ "Bash(npm run:*)",
6
+ "Bash(npm publish:*)",
7
+ "Bash(npm whoami:*)"
8
+ ]
9
+ }
10
+ }
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # Sval · [![npm](https://img.shields.io/npm/v/sval.svg?style=flat-square)](https://www.npmjs.com/package/sval) [![coveralls](https://img.shields.io/coveralls/github/Siubaak/sval.svg?style=flat-square)](https://coveralls.io/github/Siubaak/sval) [![gh-actions](https://img.shields.io/github/actions/workflow/status/Siubaak/sval/coverage.yml?style=flat-square)](https://github.com/Siubaak/sval/actions/workflows/coverage.yml) [![prs-welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
2
2
 
3
- A JavaScript interpreter writen in JavaScript, based on parser [Acorn](https://github.com/acornjs/acorn).
3
+ A JavaScript interpreter written in JavaScript, based on the [Acorn](https://github.com/acornjs/acorn) parser.
4
4
 
5
- - **Running on ES5, supporting ES latest features**
6
- - **Both invasived and sandbox modes available**
5
+ - **Runs on ES5, supporting the latest ES features**
6
+ - **Both invasive and sandbox modes are available**
7
7
 
8
- It's useful to evaluate the code of higher ECMAScript editions, or for the environment with disabled `eval`, `setTimeout` and `new Function`.
8
+ It is useful for evaluating code targeting higher ECMAScript editions, or for environments where `eval`, `setTimeout`, and `new Function` are disabled.
9
9
 
10
10
  [Try Sval on the playground.](https://jsbin.com/kehahiqono/edit?js,console)
11
11
 
@@ -21,7 +21,7 @@ npm install sval
21
21
 
22
22
  ### Browser
23
23
 
24
- Simply source from [unpkg](https://unpkg.com/sval). Or, download from [releases](https://github.com/Siubaak/sval/releases), get minimized file `dist/min/sval.min.js`, and source at your html page. You can access a global variable **Sval** directly.
24
+ Simply include it from [unpkg](https://unpkg.com/sval). Alternatively, download from [releases](https://github.com/Siubaak/sval/releases), get the minified file `dist/min/sval.min.js`, and include it in your HTML page. The global variable **Sval** will then be accessible directly.
25
25
 
26
26
  ```html
27
27
  <script type="text/javascript" src="https://unpkg.com/sval"></script>
@@ -32,7 +32,7 @@ Simply source from [unpkg](https://unpkg.com/sval). Or, download from [releases]
32
32
  ```js
33
33
  import Sval from 'sval'
34
34
 
35
- // Create a interpreter
35
+ // Create an interpreter
36
36
  const interpreter = new Sval({
37
37
  // ECMA Version of the code
38
38
  // 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15
@@ -54,42 +54,42 @@ interpreter.run(`
54
54
 
55
55
  ## Usage
56
56
 
57
- Sval constructor has three options: **ecmaVer**, **sourceType** and **sandBox**.
57
+ The Sval constructor accepts three options: **ecmaVer**, **sourceType**, and **sandBox**.
58
58
 
59
- - **ecmaVer** is the ECMAScript edition of the code. Currently, 3, 5, 6(2015), 7(2016), 8(2017), 9(2018), 10(2019), 11(2020), 12(2021), 13(2022), 14(2023), 15(2024) and "latest" are supported, and the default edition is "latest".
59
+ - **ecmaVer** specifies the ECMAScript edition of the code. Currently, 3, 5, 6(2015), 7(2016), 8(2017), 9(2018), 10(2019), 11(2020), 12(2021), 13(2022), 14(2023), 15(2024), and "latest" are supported, and the default value is "latest".
60
60
 
61
- - **sourceType** is ethier "script" or "module", which is to declare how Sval handle the code. The "script" means the code will be treated as a normal script, while the "module" means the code will be treated as an ES module with global strict mode and parsing of import and export declarations. The default type is "script".
61
+ - **sourceType** is either "script" or "module", which declares how Sval handles the code. A value of "script" means the code will be treated as a normal script, while "module" means the code will be treated as an ES module with global strict mode and support for import and export declarations. The default type is "script".
62
62
 
63
- - **sandBox** is true for sandbox mode or false for invasived mode. Sandbox mode will run code in an isolated sandbox and won't pollute your global scope. Invasived mode allows you run code in the same global scope of your current environment. The default setting is true.
63
+ - **sandBox** is true for sandbox mode or false for invasive mode. Sandbox mode runs the code in an isolated environment and will not pollute your global scope. Invasive mode allows you to run code in the same global scope as your current environment. The default setting is true.
64
64
 
65
- Sval instance has two main methods: **parse** and **run**.
65
+ A Sval instance has two main methods: **parse** and **run**.
66
66
 
67
- - **parse** is to parse the code with internal [Acorn](https://github.com/acornjs/acorn) or custom parser, to get the corresponding AST, like `parse(code: string)` or `parse(code: string, parser: (code: string, options: SvalOptions) => estree.Node`.
67
+ - **parse** parses the code with the internal [Acorn](https://github.com/acornjs/acorn) or a custom parser to get the corresponding AST, as in `parse(code: string)` or `parse(code: string, parser: (code: string, options: SvalOptions) => estree.Node)`.
68
68
 
69
- - **run** is to evaluate the code inputed, expecting a string as argument like `run(code: string)`, or an AST followed ESTree Spec as argument like `run(ast: estree.Node)`.
69
+ - **run** evaluates the provided code, accepting either a string like `run(code: string)` or an AST conforming to the ESTree spec like `run(ast: estree.Node)`.
70
70
 
71
- Besides, Sval instance also has one method, **import**, and one object, **exports**, for modularization.
71
+ In addition, a Sval instance has one method, **import**, and one object, **exports**, for modularization.
72
72
 
73
- - **import** is to import modules into your Sval instance scope. This method has different behaviors for different `sourceType`.
73
+ - **import** is used to import modules into the Sval instance scope. This method behaves differently depending on the `sourceType`.
74
74
 
75
- For "script", this method expecting a name and a module as arguments like `import(name: string, mod: any)`, or an object which contains the modules as argument like `import({ [name: string]: any })`. The modules will be automatically declared as global variables in Sval instance scope. This method is more likely to be used in sandbox mode.
75
+ For "script", this method expects a name and a module as arguments like `import(name: string, mod: any)`, or an object containing the modules like `import({ [name: string]: any })`. The modules will be automatically declared as global variables in the Sval instance scope. This method is most commonly used in sandbox mode.
76
76
 
77
- For "module", this method expecting a path and a module declaration as arguments like `import(path: string, mod: Module)`, or an object which contains the module declarations as argument like `import({ [path: string]: Module })`. The `Module` is either an ES module exported object like `{ default?: any, [name: string]: any }` or a function returning an ES module exported object like `() => ({ default?: any, [name: string]: any })`. The `Module` can also be a promise or a function returning a promise if importing a module by dynamic import. The modules will not be automatically declared as global variables in Sval instance scope, and the code should use import declarations to import the module.
77
+ For "module", this method expects a path and a module declaration as arguments like `import(path: string, mod: Module)`, or an object containing the module declarations like `import({ [path: string]: Module })`. The `Module` is either an ES module export object like `{ default?: any, [name: string]: any }` or a function returning one like `() => ({ default?: any, [name: string]: any })`. The `Module` can also be a promise or a function returning a promise for use with dynamic imports. The modules will not be automatically declared as global variables in the Sval instance scope, and the code should use import declarations to import them.
78
78
 
79
- - **exports** is to get what you exported from runs, merged if several runs have exports. Also, this object has different behaviors for different `sourceType`.
79
+ - **exports** holds what was exported from runs, merged across multiple runs if applicable. This object also behaves differently depending on the `sourceType`.
80
80
 
81
- For "script", this object will be automatically declared as global variables in Sval instance scope, and the code can just simple mount properties on it for export.
81
+ For "script", this object is automatically declared as a global variable in the Sval instance scope, and the code can simply mount properties on it to export values.
82
82
 
83
- For "module", this object will not be automatically declared as global variables in Sval instance scope, and the code needs to use export declarations for export.
83
+ For "module", this object is not automatically declared as a global variable in the Sval instance scope, and the code must use export declarations to export values.
84
84
 
85
- Here are examples for **import** and **exports** below:
85
+ Here are examples for **import** and **exports**:
86
86
 
87
87
  Example for "script":
88
88
 
89
89
  ```js
90
90
  import Sval from 'sval'
91
91
 
92
- // Create a interpreter for script
92
+ // Create an interpreter for script
93
93
  const scriptInterpreter = new Sval({ sourceType: 'script' })
94
94
 
95
95
  // Add global modules in interpreter
@@ -110,7 +110,7 @@ Example for "module":
110
110
  ```js
111
111
  import Sval from 'sval'
112
112
 
113
- // Create a interpreter for module
113
+ // Create an interpreter for module
114
114
  const moduleInterpreter = new Sval({ sourceType: 'module' })
115
115
 
116
116
  // Add ES modules in interpreter
@@ -141,7 +141,7 @@ console.log(moduleInterpreter.exports.mod) // Get 'AllKindsOfStuffs'
141
141
 
142
142
  ## Related
143
143
 
144
- - [sval-rhino-gs](https://github.com/Patrick-ring-motive/sval-rhino-gs)
144
+ - [sval-rhino-gs](https://github.com/Patrick-ring-motive/sval-rhino-gs)
145
145
 
146
146
  ## License
147
147
 
@@ -21,3 +21,4 @@ export declare const DEADZONE: string;
21
21
  export declare const OPTCHAIN: string;
22
22
  export declare const IMPORT: string;
23
23
  export declare const EXPORTS: string;
24
+ export declare const STRICT: string;