Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

define-properties

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

define-properties

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

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
44M
increased by17.98%
Maintainers
1
Weekly downloads
 
Created

What is define-properties?

The define-properties npm package is used to define new properties on an object, including any necessary descriptors. It provides a simple API to define multiple properties at once while ensuring compatibility with older JavaScript engines that may not fully support ES5.

What are define-properties's main functionalities?

Defining multiple properties

This feature allows you to define multiple properties on an object with their descriptors. The 'enumerable' predicate ensures that the property will only be defined if the value is truthy.

{"object": {}, "properties": {"prop1": {"value": 42, "enumerable": true}, "prop2": {"value": 'hello', "enumerable": false}}, "predicates": {"enumerable": function(val) { return !!val; }}}

Defining properties with shared descriptors

This feature allows you to define properties with a shared descriptor. The predicate function can be used to conditionally define properties based on the key or value.

{"object": {}, "propertyNames": ["prop1", "prop2"], "descriptor": {"enumerable": true}, "predicate": function(key, value) { return key === 'prop1' || value > 10; }}

Other packages similar to define-properties

Keywords

FAQs

Package last updated on 02 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc