Détail du package

object.defineproperties

es-shims1.4kMIT1.0.3

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

javascript, ecmascript, polyfill, 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

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v1.0.3 - 2024-03-17

Commits

  • [Dev Deps] update aud, call-bind, has-property-descriptors, mock-property, npmignore, tape 66040e2
  • [Refactor] replace es-abstract with es-object-atoms when possible; update define-properties, es-abstract 1d955f1

v1.0.2 - 2023-08-28

Commits

  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, object.entries, object.hasown, tape cd6f95a
  • [Deps] update define-properties, es-abstract, f01da6d

v1.0.1 - 2022-11-05

Commits

  • [Tests] increase coverage c285d10
  • [Tests] handle weird nyc-only failure in node 0.8 5ea3745
  • [Tests] increase coverage 4183cc7
  • [actions] update rebase action to use reusable workflow a691bfa
  • [Deps] update es-abstract 8c35b36
  • [Dev Deps] update aud, es-value-fixtures, tape df90fed

v1.0.0 - 2022-05-05

Commits