Thanks to visit codestin.com
Credit goes to github.com

Skip to content

steelsojka/esbox

 
 

Repository files navigation

📦 esbox

NPM version Linux Build Status Windows Build Status Dependency Status

ES.next in a box™

Zero-config REPL for experimenting with next-generation JavaScript.

It automatically compiles and re-runs your script every time you save. Think of it as a JSBin-like setup for your local editor and terminal – with full access to Node APIs and modules.

demo-gif

As well as for experimenting, esbox may be useful in situations like workshops and screencasts – it makes it easy to do live code demos in ES2016 and beyond, without getting bogged down in build systems.

Install

> npm install -g esbox

Usage

To run script.js in a box:

> esbox script.js

Every time you save the file, esbox clears the terminal display and runs your script again. Any uncaught errors get pretty-printed for easy debugging.

For more options, see esbox --help.

Automatic Babel compilation

You can use any proposed ECMAScript features that Babel supports (stage-0 and above), including async/await, destructuring, rest/spread, etc.

Magic imports

For a number of popular libraries, you can just import them without the need to install them first.

This includes lodash, bluebird, chalk, chai, express, request – and anything else listed under dependencies in esbox's own package.json.

This is made possible by rewiring require() to use esbox's own node_modules folder as an extra possible module source. (Your own locally installed modules still take precedence if found.)

For example, a script like this just works in esbox:

import cheerio from 'cheerio';
import fetch from 'isomorphic-fetch';
import { cyan } from 'chalk';

(async () => {
  const result = await fetch('https://www.nytimes.com');
  console.assert(result.ok);

  const $ = cheerio.load(await result.text());

  console.log('The New York Times headlines:');

  $('.story-heading').each((i, element) => {
    console.log(' ', cyan($(element).text().trim()));
  });
})();

License

MIT © Callum Locke

About

📦 ES.next in a box

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%