8000 GitHub - jcraftsman/nodeit: A simple tool that wraps functions from js files and export them as a node module.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jcraftsman/nodeit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nodeit

Node.js CI

Synopsis

A simple tool that wraps functions from js files and export them as a node module.

Install

All you need is to add nodeit to your devDependencies in package.json file. you can use your package manager to do so:

npm install --save-dev nodeit

or

yarn add --dev nodeit

How it works

Supposing, you have a file src/Calculator.js that contains the following code:

function sum (a, b) {
    return a+b;
}
const calculator = require('nodeit')
    .compile('src/Calculator');

describe('Calculator', () => {
    it('should return 4 as sum(1,3)',()=>{
        expect(calculator.sum(2,2)).toEqual(4);
    })``
});

Inject dependencies

If the js you want to node has some dependencies, you can inject them with 3 methods:

External dependencies

const calculator = require('nodeit')
    .include("_", "lodash")
    .compile('src/Calculator');

Static dependencies

const calculator = require('nodeit')
    .dependsOnStatic("StaticClass", "staticMethodName")
    .compile('src/Calculator');

Custom dependencies

const calculator = require('nodeit')
    .dependsOn(dependency, "dependencyName")
    .compile('src/Calculator');

About

A simple tool that wraps functions from js files and export them as a node module.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0