carpenter-nodejs

0.0.7 • Public • Published

Carpenter npm version license type codecov

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('leolewan@gmail.com')
      .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.

Package Sidebar

Install

npm i carpenter-nodejs

Weekly Downloads

0

Version

0.0.7

License

MIT

Unpacked Size

3.48 kB

Total Files

5

Last publish

Collaborators

  • llewan