object.defineproperties

1.0.3 • Public • Published

object.defineproperties Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

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

/object.defineproperties/

    Package Sidebar

    Install

    npm i object.defineproperties

    Weekly Downloads

    357

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    17.3 kB

    Total Files

    18

    Last publish

    Collaborators

    • ljharb