Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
define-prop
Advanced tools
#define-prop
###Easy and type safe custom object property define
###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 arguments or in a space seperated string.
var defineProp= require( 'define-prop' );
var obj= {};
// 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
defineProp( obj, 'hello', 'world!', 'enumerable' );
obj.hello= 'cannot be set..';
console.log( obj );
// { hello: 'world!' }
// define a getter and setter similar to native Object.defineProperty
defineProp( obj, 'count', ( () => {
var count= 0;
return {
get: () => count
,set: ( value ) => count= value
};
})(), 'enumerable' );
obj.count++;
console.log( obj.count );
// 1
// define an object to be deeply immutable
defineProp( obj, 'protected', {
notWritable : 'this is a frozen object'
,test : true
}, 'enumerable' );
obj.protected.cannotAssign = 'when "writable" is not set';
obj.protected.test = 'futile';
console.log( obj );
// { hello: 'world!',
// count: [Getter/Setter],
// protected: { notWritable: 'this is a frozen object', test: true } }
// have custom input error handler
defineProp.log= ( err ) => {
// do something with err?
};
0.0.5
--
0.0.4
--
0.0.3
--
###license
MIT
FAQs
Easy and type safe custom object property define
The npm package define-prop receives a total of 9 weekly downloads. As such, define-prop popularity was classified as not popular.
We found that define-prop demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.