Comparing version 1.1.3 to 2.0.0
{ | ||
"name": "eshost", | ||
"version": "1.1.3", | ||
"description": "Run scripts in any ECMAScript host", | ||
"bin": { | ||
"eshost": "bin/eshost.js" | ||
"version": "2.0.0", | ||
"description": "Invoke ECMAScript scripts in any command line JS engine.", | ||
"main": "lib/eshost.js", | ||
"scripts": { | ||
"test": "mocha test/*", | ||
"lint": "eslint lib/* bin/* test/*" | ||
}, | ||
"dependencies": { | ||
"chalk": "^1.1.1", | ||
"cli-table": "^0.3.1", | ||
"configstore": "^1.4.0", | ||
"es-host-wrapper": "^1.2.0", | ||
"nconf": "^0.8.2", | ||
"temp": "^0.8.3", | ||
"yargs": "^3.31.0" | ||
"author": "Brian Terlson", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"eslint": "^1.10.2", | ||
"mocha": "^2.3.4" | ||
}, | ||
"devDependencies": {}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
@@ -25,13 +20,9 @@ "type": "git", | ||
}, | ||
"keywords": [ | ||
"javascript", | ||
"ecmascript", | ||
"host" | ||
], | ||
"author": "Brian Terlson", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/bterlson/eshost/issues" | ||
"dependencies": { | ||
"error-stack-parser": "^1.3.3", | ||
"server-destroy": "^1.0.1", | ||
"socket.io": "^1.3.7", | ||
"temp": "^0.8.3" | ||
}, | ||
"homepage": "https://github.com/bterlson/eshost" | ||
} |
115
README.md
@@ -1,50 +0,101 @@ | ||
## ESHost | ||
## es-host-wrapper | ||
ESHost makes it easy to run and compare ECMAScript code uniformly across a number of runtimes. Support for runtimes is provided by the library [es-host-wrapper](https://github.com/bterlson/es-host-wrapper). Every host is initialized with the [es-host-wrapper runtime API](https://github.com/bterlson/es-host-wrapper#runtime-library) available which provides a uniform way to print, create realms, and eval code. | ||
Es-host-wrapper is a library for executing ECMAScript code uniformly across any ECMAScript host environment. Es-host-wrapper consists of a wrapper around the various ways of executing a host and processing its output (called a Runner) and a runtime library for host-agnostic scripts to use. | ||
See es-host-wrapper's [supported hosts](https://github.com/bterlson/es-host-wrapper#supported-hosts) for a list of hosts, download/build locations, and other information. | ||
For a CLI tool that uses this library to make comparing ECMAScript hosts super easy, see [eshost](https://github.com/bterlson/eshost). | ||
### Usage | ||
### Installation | ||
Manage hosts with `eshost host`. Run files across all hosts using `eshost file.js`. Run a quick script using `eshost -e "script"`. | ||
``` | ||
npm install es-host-wrapper | ||
``` | ||
#### Examples | ||
### Supported Hosts | ||
| Host | Supported Platforms | Download | Notes | | ||
|------|---------------------|----------|-------| | ||
| browser | Any | | Errors reported from Microsoft Edge are all of type Error. | | ||
| node | Any | https://nodejs.org | | | ||
| ch | Windows | Built [from source](https://github.com/microsoft/chakracore)| Chakra console host. | | ||
| d8 | Any | Built [from source](https://github.com/v8/v8) | v8 console host. Errors are reported on stdout. Use $.getGlobal and $.setGlobal to get and set properties of global objects in other realms. | | ||
| jsshell | Any | [Download](https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/) | SpiderMonkey console host. | | ||
| jsc | Mac | Built [from source](http://trac.webkit.org/wiki/JavaScriptCore)¹ | | | ||
| nashorn | Any | Built [from source](https://wiki.openjdk.java.net/display/Nashorn/Building+Nashorn) | | | ||
1: Also available on your Mac system at `/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc`. | ||
### Examples | ||
```js | ||
const runner = js.getRunner('path/to/d8.exe', 'd8'); | ||
runner.exec(` | ||
print(1+1); | ||
`).then(result => console.log(result.stdout)); | ||
``` | ||
npm install -g eshost | ||
eshost --help | ||
eshost host --help | ||
eshost host --add <name> <type> <path to host executable> --args <optional arguments> | ||
eshost -e "print(Map.length)" | ||
## chakra-es6 | ||
0 | ||
## Documentation | ||
## d8 | ||
0 | ||
### es-host-wrapper API | ||
## chakra | ||
0 | ||
#### getRunner(path, type, arguments) | ||
Gets an instance of a runner for a particular host type. Supported host types: | ||
## spidermonkey | ||
1 | ||
* browser | ||
* node | ||
* d8 | ||
* jsshell | ||
* ch | ||
## node | ||
0 | ||
Creating a runner may start the host (eg. for the browser, creating the host executes the browser process). | ||
You can pass command line arguments to the host process using the arguments option. It is an array of strings as you might pass to Node's spawn API. | ||
### Runner API | ||
#### exec(code) | ||
Executes `code` in the host. Returns a result object. | ||
##### Result Object | ||
An object with the following keys: | ||
* stdout: anything printed to stdout (mostly what you print using `print`). | ||
* stderr: anything printed to stderr | ||
* error: if the script threw an error, it will be an error object. Else, it will be null. | ||
The error object is similar to the error object you get in the host itself. Namely, it has the following keys: | ||
* name: Error name (eg. SyntaxError, TypeError, etc.) | ||
* message: Error message | ||
* stack: An array of stack frames. | ||
### Runtime Library | ||
#### print(str) | ||
Prints `str` to stdout. | ||
#### $.global | ||
A reference to the global object. | ||
#### $.createRealm(globals) | ||
Creates a new realm, returning that realm's runtime library ($). | ||
For example, creating two nested realms: | ||
```js | ||
$sub = $.createRealm(); | ||
$subsub = $sub.createRealm(); | ||
``` | ||
### Managing Hosts | ||
#### $.evalInNewRealm(code, onError) | ||
Creates a new realm and evals `code` in that realm. If an error is thrown, it will be passed to the onError callback. | ||
The command `host` is used for managing hosts (see above for some examples). You can --add, --list, and --delete them. Adding a host requires a name, type, and path to the runtime executable. You can optionally pass arguments using --args. The same host can be added multiple times with different --args which makes it easy to compare the output of runtimes given different options (eg. by turning language features on and off). | ||
#### $.evalInNewScript(code, onError) | ||
Creates a new script and evals `code` in that realm. If an error is thrown, it will be passed to the onError callback. | ||
Console hosts are either provided by the browser vendors or, more likely, built from source. | ||
Scripts are different from eval in that lexical bindings go into the global lexical contour rather than being scoped to the eval. | ||
Host types are [those provided by es-host-wrapper](https://github.com/bterlson/es-host-wrapper#supported-hosts), namely: | ||
#### $.getGlobal(name) | ||
Gets a global property name. | ||
* ch | ||
* jsshell | ||
* d8 | ||
* jsc | ||
* nashorn | ||
* node | ||
* browser | ||
#### $.setGlobal(name, value) | ||
Sets a global property name to value. |
@@ -1,2 +0,5 @@ | ||
print('hello!'); | ||
throw new Error("fail"); | ||
var vm = require('vm'); | ||
var obj = {}; | ||
var context = vm.createContext({console: console}); | ||
vm.runInContext('var x = 1', context); | ||
vm.runInContext('console.log(x)', context); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 18 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
47927919
4
59
1166
0
102
2
710
1
16
23
+ Addederror-stack-parser@^1.3.3
+ Addedserver-destroy@^1.0.1
+ Addedsocket.io@^1.3.7
- Removedchalk@^1.1.1
- Removedcli-table@^0.3.1
- Removedconfigstore@^1.4.0
- Removedes-host-wrapper@^1.2.0
- Removednconf@^0.8.2
- Removedyargs@^3.31.0
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedasync@1.5.2(transitive)
- Removedcamelcase@2.1.1(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcli-table@0.3.11(transitive)
- Removedcliui@3.2.0(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedcolors@1.0.3(transitive)
- Removedconfigstore@1.4.0(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removedes-host-wrapper@1.2.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedimurmurhash@0.1.4(transitive)
- Removedini@1.3.8(transitive)
- Removedinvert-kv@1.0.0(transitive)
- Removedis-fullwidth-code-point@1.0.0(transitive)
- Removedlcid@1.0.0(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removednconf@0.8.5(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedos-locale@1.4.0(transitive)
- Removedos-tmpdir@1.0.2(transitive)
- Removedosenv@0.1.5(transitive)
- Removedsecure-keys@1.0.0(transitive)
- Removedslide@1.1.6(transitive)
- Removedstring-width@1.0.2(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removeduuid@2.0.3(transitive)
- Removedwindow-size@0.1.4(transitive)
- Removedwrap-ansi@2.1.0(transitive)
- Removedwrite-file-atomic@1.3.4(transitive)
- Removedxdg-basedir@2.0.0(transitive)
- Removedy18n@3.2.2(transitive)
- Removedyargs@3.32.0(transitive)