JSPM

object.defineproperties

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 338
  • Score
    100M100P100Q101304F
  • License MIT

ES spec-compliant `Object.defineProperties` shim/polyfill/replacement that works as far down as ES3

Package Exports

  • object.defineproperties
  • object.defineproperties/auto
  • object.defineproperties/implementation
  • object.defineproperties/package.json
  • object.defineproperties/polyfill
  • object.defineproperties/shim

Readme

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