Package Exports
- vigour-base
- vigour-base/lib/index.js
- vigour-base/lib/iterator
- vigour-base/lib/iterator/browser.js
- vigour-base/lib/iterator/index.js
- vigour-base/lib/method/lookUp
- vigour-base/lib/method/lookUp.js
- vigour-base/lib/method/serialize
- vigour-base/lib/method/serialize.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vigour-base) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
vigour-base
Extendable object constructors, build for speed, low memory consumption and simplicity
set method
easy extendable property defintions
deep, memory efficient prototypes
parent and key fields
types (easy inheritance)
inject pattern
###Properties The properties field is used to add property definitions for certain keys within set objects.
There are 4 types of property definitions:
trueclears any special base behaviour for the keyfunctioncalls the function when the key is set instead of the normal behaviournullremoves property definition and any existing instancesanything elseuses the set function
basic
var base = new Base({
properties: {
normal: true,
special: (val, stamp) {
this.special = val * 10
},
base: { nested: true }
}
})
base.set({
normal: 'hello', // → 'hello'
special: 10, // → 100
base: 'a base' // → Base { val: 'a base', nested: true }
})
base.set({
properties: {
normal: null
// removes property defintion and removes "normal"
}
})set
var special = new Base({
type: 'special'
})
var base = new Base({
properties: {
// uses "noReference" for a base
special: special
}
})
base.set({
special: 10 // → Special 10
})
// add something to the "special" property
base.set({
properties: {
special: {
aField: true
}
}
})
// → base.special.aField.val === true, inherits from the propertydefine
Allows for extra customisation of property definitions.
It has 3 options:
:keywhen a property is set uses this key to store its value:resetresets a previously defined property:valproperty value
var base = new Base({
properties: {
define: {
x: { key: 'y' },
something: {
key: 'else',
val: {
a: true,
b: true
}
},
hello: {
key: 'bye',
val: 100
}
}
},
x: 10 // → z: 10
something: { c: true }, // → else: Base { a: true, b: true, c: true }
hello: { field: true } // → bye: Base { val: 100, field: true }
})
base.set({
properties: {
define: {
something: {
// removes the "else" field on base
// creates a new property definition for "something"
reset: true,
val: 'hello'
},
x: {
key: 'z',
reset: false // will not move "y"
},
hello: {
// moves "bye" → "hello"
key: null
}
}
}
})