Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inDemoInstall

define-properties

Package Overview
Dependencies
2
Maintainers
1
Versions
8
Issues
File Explorer

Advanced tools

define-properties

Define multiple non-enumerable properties at once. Uses `Object.defineProperty` when available; falls back to standard assignment in older engines.

    1.1.4latest
    Github

Version published
Maintainers
1
Weekly downloads
25,999,251
decreased by-18.13%

Weekly downloads

Readme

Source

define-properties Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Define multiple non-enumerable properties at once. Uses Object.defineProperty when available; falls back to standard assignment in older engines. Existing properties are not overridden. Accepts a map of property names to a predicate that, when true, force-overrides.

Example

var define = require('define-properties'); var assert = require('assert'); var obj = define({ a: 1, b: 2 }, { a: 10, b: 20, c: 30 }); assert(obj.a === 1); assert(obj.b === 2); assert(obj.c === 30); if (define.supportsDescriptors) { assert.deepEqual(Object.keys(obj), ['a', 'b']); assert.deepEqual(Object.getOwnPropertyDescriptor(obj, 'c'), { configurable: true, enumerable: false, value: 30, writable: false }); }

Then, with predicates:

var define = require('define-properties'); var assert = require('assert'); var obj = define({ a: 1, b: 2, c: 3 }, { a: 10, b: 20, c: 30 }, { a: function () { return false; }, b: function () { return true; } }); assert(obj.a === 1); assert(obj.b === 20); assert(obj.c === 3); if (define.supportsDescriptors) { assert.deepEqual(Object.keys(obj), ['a', 'c']); assert.deepEqual(Object.getOwnPropertyDescriptor(obj, 'b'), { configurable: true, enumerable: false, value: 20, writable: false }); }

Tests

Simply clone the repo, npm install, and run npm test

Keywords

FAQs

What is define-properties?

Define multiple non-enumerable properties at once. Uses `Object.defineProperty` when available; falls back to standard assignment in older engines.

Is define-properties popular?

The npm package define-properties receives a total of 20,835,686 weekly downloads. As such, define-properties popularity was classified as popular.

Is define-properties well maintained?

We found that define-properties demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 15 Apr 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket[email protected]

Product

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc