Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
is-data-descriptor
Advanced tools
Package description
The is-data-descriptor npm package is used to determine if an object is a valid data descriptor. Data descriptors are object keys that have attributes like value, writable, enumerable, and configurable. This package checks if a given object conforms to the specification of a data descriptor.
Check if an object is a data descriptor
This feature allows you to verify if a given object is a valid data descriptor by checking its properties and their respective values.
const isDataDescriptor = require('is-data-descriptor');
const descriptor = {value: 'value', writable: true, enumerable: true, configurable: true};
const result = isDataDescriptor(descriptor); // result is true
This package is more general than is-data-descriptor. It checks if an object is any kind of descriptor, including data and accessor descriptors. It is a superset of is-data-descriptor functionality.
Similar to is-data-descriptor, but specifically checks if an object is a valid accessor descriptor, which includes properties like get, set, enumerable, and configurable.
While not limited to descriptors, this utility module can check the type of any JavaScript value, including whether it is a descriptor. It is more versatile but less specialized than is-data-descriptor.
Readme
Returns true if a value has the characteristics of a valid JavaScript data descriptor.
Install with npm
$ npm i is-data-descriptor --save
var isDataDesc = require('is-data-descriptor');
true
when the descriptor has valid properties with valid values.
// `value` can be anything
isDataDesc({value: 'foo'})
isDataDesc({value: function() {}})
isDataDesc({value: true})
//=> true
false
when not an object
isDataDesc('a')
//=> false
isDataDesc(null)
//=> false
isDataDesc([])
//=> false
false
when the object has invalid properties
isDataDesc({value: 'foo', bar: 'baz'})
//=> false
isDataDesc({value: 'foo', bar: 'baz'})
//=> false
isDataDesc({value: 'foo', get: function(){}})
//=> false
isDataDesc({get: function(){}, value: 'foo'})
//=> false
false
when a value is not the correct type
isDataDesc({value: 'foo', enumerable: 'foo'})
//=> false
isDataDesc({value: 'foo', configurable: 'foo'})
//=> false
isDataDesc({value: 'foo', writable: 'foo'})
//=> false
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on October 04, 2015.
FAQs
Returns true if a value has the characteristics of a valid JavaScript data descriptor.
The npm package is-data-descriptor receives a total of 23,964,585 weekly downloads. As such, is-data-descriptor popularity was classified as popular.
We found that is-data-descriptor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.