Skip to content

Latest commit

 

History

History
53 lines (39 loc) · 1.33 KB

stampit.md

File metadata and controls

53 lines (39 loc) · 1.33 KB

Stampit

https://github.com/stampit-org/stampit/

Alternatives

Cheatsheet

const ExampleStamp = stampit()
  // Map of property names and values to be mixed into each new object using shallow merge
  .refs({
    propertyName: 'propertyVal'
  })
  
  // An object deeply merged into each newly stamped object
  // Will not change any refs data
  .props({
    propertyName: 'propertyVal'
  })

  .methods({
    doSomething: function() {}
  })

  // Run when instance is created
  init((context) => {
    // context = { instance, stamp, args }
    context.instance.something = {};
  })

  // Mix together methods, refs, init, etc
  .compose(Stamp1, Stamp2, etc);

// First param sets properties, remaining params injected into `init.args`
const exampleInstance = ExampleStamp({ property: 'value' }, 'arg1', 'arg2');

Instead of functions, can all be set within object;

stampit({
  methods:
  refs:
  etc:
});