Skip to content

Instantly share code, notes, and snippets.

@jkantr

jkantr/.js Secret

Created November 30, 2018 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkantr/b1a7763405037b4c38158b22ccce3c3d to your computer and use it in GitHub Desktop.
Save jkantr/b1a7763405037b4c38158b22ccce3c3d to your computer and use it in GitHub Desktop.
const { createFoo } = require('@foo-bar/core');
// option 1: have the factory/constructor take a 'blueprint' object
const myFoo = createFoo({
fooProp: 123,
barProp: 'abc',
fooFn() {
// ...
},
barFn() {
// ...
},
});
// option 2: create a blank Thing (or minimal options Thing) and then append to it
const myFoo = createFoo({ barProp: 'abc' });
myFoo.fooFn = function() {
// ...
}
myFoo.barFn = function() {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment