New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

define-prop

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

define-prop

Easy and type safe custom object property define

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by800%
Maintainers
1
Weekly downloads
 
Created
Source

#define-prop

###Easy and type safe custom object property define

  • object descriptors in a space seperated string for fast inline value creation
  • dynamically type checked

###Usage:

<object> defineProperty( <object> obj, <string>/<number> key, <any type> value, <string> descriptorNames )

Default, the enumerable, configurable and writable descriptor values are set to false, which is the default behaviour of Object.defineProperty. You can set them individually to true by passing their names as last argument in a space seperated string.

var defineProperty= require( 'define-prop' );

var obj= {};

// let's define obj.hello and give it the value 'world!', it will be 
// immutable by default, we only set enumerable to be able to log it now
defineProperty( obj, 'hello', 'world!', 'enumerable' );
obj.hello= 'into a black hole';

console.log( obj );
//	{ hello: 'world!' }

// define a getter and setter as you would with Object.defineProperty
defineProperty( obj, 'count', {
	 get: () => obj.value
	,set: ( value ) => obj.value= value
});

obj.count= 0;
console.log( ++obj.count );
// 1

change log

--

0.0.3

  • changed license to MIT

--

###license

MIT

Keywords

FAQs

Package last updated on 13 Sep 2016

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