carpenter-nodejs
v0.0.7
Published
Creates a builder pattern for NodeJS using ES6 proxy.
Downloads
2
Maintainers
Readme
Carpenter
Creates a builder pattern for NodeJS using ES6 proxy.
Installation
npm install --save carpenter-nodejs
And then import it:
// ES6 modules
import { Builder, BuilderType } from 'carpenter-nodejs';
// commonjs
const { Builder, BuilderType } = require('carpenter-nodejs');
Usage
Specify a template object which allows to define the API and the dataType for each field.
const template = {
id: BuilderType.number,
first_name: BuilderType.string,
email: BuilderType.string,
};
const built = Builder(template)
.id(1)
.firstName('Leo')
.email('[email protected]')
.build();
Note
- It accepts the build function on camelCase as well
Questions or suggestions?
Feel free to contact me on Twitter or open an issue.