No description, website, or topics provided.
Switch branches/tags
Nothing to show
Pull request Compare This branch is even with neonstalwart:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
Cell.js
CellTest.js
LICENSE
List.js
ListTest.js
README.md
Subject.js
SubjectTest.js
package.json
test.js

README.md

Subject

  • dependent
  • target
  • object

Description

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.

Examples

support for data descriptors.

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

support for accessor descriptors

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

LICENSE

BSD Copyright (c) 2011, Ben Hockey