object.defineproperties
v1.0.3
Published
ES spec-compliant `Object.defineProperties` shim/polyfill/replacement that works as far down as ES3
Downloads
2,998
Maintainers
Readme
object.defineproperties
An ES spec-compliant Object.defineProperties
shim. Invoke its "shim" method to shim Object.defineProperties
if it is unavailable or noncompliant.
This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec.
Most common usage:
var assert = require('assert');
var defineProperties = require('object.defineproperties');
var descriptors = {
a: {
value: 2
},
c: {
configurable: true,
enumerable: true,
value: 3,
writable: true
}
};
var obj = { a: 1, b: 2 };
var result = defineProperties(obj, descriptors);
assert.equal(obj, result); // same object
assert.deepEqual(obj, { a: 2, b: 2, c: 3 });
defineProperties.shim();
assert.deepEqual(
Object.defineProperties({ a: 1, b: 2 }, descriptors),
defineProperties({ a: 1, b: 2 }, descriptors)
);
Tests
Simply clone the repo, npm install
, and run npm test