es-worker

javascript AST calcuter.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
es-worker
0.6.174 years ago7 years agoMinified + gzip package size for es-worker in KB

Readme

ES-Worker
javascript AST calcuter.

how to use

  • NPM
npm install es-worker
const esworker = require( "es-worker" );
import * as esworker from "es-worker";
  • HTML
<script type="text/javascript" src="./dest/browser/esworker.min.js"></script>
<script type="text/javascript">
	const ew = window.esworker;

</script>
  • ESM
import * as esworker from "./src/module.js";

exsample

const esworker = require( "es-worker" );
const esprima = require( "esprima" );

const scope = Object.create( null );

esworker.exec( "1 + 1",
{
	"scopes": [ scope ],
	"parser": esprima,

	callback ( event )
	{
		const { result } = event;

	}

	onerror ( error )
	{
		throw error;

	}

} );

use native API

const esworker = require( "es-worker" );
const esprima = require( "esprima" );

const scope = Object.create( null );

esworker.exec( "console.log( 'Hello World!' )",
{
	"scopes": [ window/*←deep*/, scope/*shallow→*/ ],
	"parser": esprima

} );

use es6 module

const esworker = require( "es-worker" );
const esprima = require( "esprima" );

const scope = Object.create( null );

esworker.exec( "import { add } from './script/add.js'; add( 1, 2 );",
{
	"scopes": [ scope ],
	"parser": esprima

} );