Miss any of our Open RFC calls?Watch the recordings here! »

builder-pattern-es6

1.1.4 • Public • Published

builder-pattern-es6

Create a builder pattern for ES6 classes.

Installation

npm i builder-pattern-es6
yarn add builder-pattern-es6

Usage

const builderES6 = require("builder-pattern-es6");

class Pizza {
  get name() {
    return this._name;
  }

  set name(value) {
    this._name = value;
  }

  get meatQuantity() {
    return this._meatQuantity;
  }

  set meatQuantity(value) {
    this._meatQuantity = value;
  }

  get withOregano() {
    return this._withOregano;
  }

  set withOregano(value) {
    this._withOregano = value;
  }
}

builderES6(Pizza);

const pizza = Pizza.Builder()
  .name("Capricciosa")
  .meatQuantity(100)
  .withOregano(true)
  .build();
console.log(pizza);
// Pizza { _name: 'Capricciosa', _meatQuantity: 100, _withOregano: true }

License

This project is licensed under the MIT License - see the LICENSE file for details

Install

npm i builder-pattern-es6

DownloadsWeekly Downloads

0

Version

1.1.4

License

ISC

Unpacked Size

5.35 kB

Total Files

8

Last publish

Collaborators

  • avatar