0.1.0 • Published 7 years ago

accretion v0.1.0

Weekly downloads
6
License
SEE LICENSE IN LI...
Repository
-
Last release
7 years ago

An accretion is an extensible object used an an alternative to this, class, and new.

const {create} = require('accretion');

const a = create({
    foo: 'default value'
});

// b shallow copies a and overrides properties
const b = a.extend({
    foo: 'overriding value',
    bar: 'new property'
});

// c shallow copies b, and lets b override provided values.
const c = b.spread({
    foo: 'new default value'
});

delete b.foo;

const d = b.spread({
    foo: 'new default value if property is not already specified'
});

// {foo: 'default value', spread: [Function], extend: [Function] }
console.log(a);

// {foo: 'overriding value', bar: 'new property', spread, extend }
console.log(b);

// {foo: 'overriding value', bar: 'new property', spread, extend }
console.log(c);

// {foo: 'new default value', bar: 'new property', spread, extend }
console.log(d);
0.1.0

7 years ago

0.0.1

7 years ago