1.0.0 • Published 4 years ago

factoize.js v1.0.0

Weekly downloads
2
License
ISC
Repository
-
Last release
4 years ago

Factorize.js

A simple utily for creating functions on objects

Code examples

const factory = require('factorize.js');
const Proto = {}; // Could be a class' / function's prototype
const Factory = new factory(Proto);
Factory.addFactory(`multiply`, [`fs`], ({ fs, path, number }) => {
    return fs.writeFileSync(path, number * 2);
}, ["path", "number"]);
// The first param is the name
// The second parram is the dependencies to require
// The third param is the run function with all params and dependencies
// The fourth param is delcaring the params
// Usage:
Proto.multiply(`./index.txt`, 5) // Would write to index.txt - 10

I hope this can help you.