- dependent
- target
- object
composable property descriptors.
defers to native Object.defineProperty
when suitable.
by calling set
and get
, much of what is provided by Object.defineProperty
can be achieved.
value
and writable
can be set.
var value = 'value',
it = compose.create(Subject, {
foo: Subject.defineProperty({
value: value,
writable: false
})
});
it.set('foo', 'abc'); // throws a TypeError
calling set
for a property without a setter throws an Error.
var it = compose.create(Subject, {
foo: Subject.defineProperty({
get: function (key) {
// ...
}
})
});
it.set('foo', 'abc'); // throws a TypeError
get
and set
from the property descriptor are used as the getter and setter
var it = compose.create(Subject, {
foo: Subject.defineProperty({
get: function (key) {
// called when get('foo') is called
},
set: function (key, value) {
// called when set('foo', value) is called
}
})
});
it.set('foo', 'abc'); // calls set from the property descriptor
*NOTE: configurable
and enumerable
are not supported when not deferring to Object.defineProperty
BSD Copyright (c) 2011, Ben Hockey