gmod

0.0.1 • Public • Published

gmod

Generator-based Module System

  • use yield to import module
  • use throw to throw error
  • use return to export module

Installation

$ npm install gmod

Usage

In foo.js:

var foo = "Hi, I am foo."
return foo; // export foo

In bar.js:

var foo = yield './foo.js'; // import from `foo.js`
 
console.log(foo);
 
return "Hi, I am bar";

In main.js (regular node.js file):

var gmod = require('gmod');

// import will return a Promise instance
gmod.import(__dirname + '/bar.js')
    .then(function (bar) {
        console.log("bar:", bar);
    }, function (err) {
        console.log("err:", err);
    });

Readme

Keywords

none

Package Sidebar

Install

npm i gmod

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • gyson