1.0.2 • Published 1 year ago

metabuilder-js v1.0.2

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

MetaBuilderJS

A TypeScript-friendly factory that creates a working builder in JavaScript/TypeScript

Installation:

Simply run the command npm i metabuilder-js if using npm or yarn add metabuilder-js to add the dependency to your project

How to use:

To use the builder, call the createObjectBuilder method with an object of your choosing to create the builder

import { createObjectBuilder } from 'metabuilder-js';

const helloWorldBuilder = createObjectBuilder({ hello: 'world', iMade: 'A builder' });

The parameter that createObjectBuilder takes is the default object that any instance of the builder you create will start out with.

This method generates a builder that contains helper methods withPropName where PropName is one of the properties specified on the object.

For example, using the builder we just created you can set the hello and iMade props:

const myObject = helloWorldBuilder()
  .withHello('a different value')
  .withIMade('different builder')
  .build();

console.log(myObject); // { hello: 'a different value', iMade: 'different builder' } 
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago