Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
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.
is-accessor-descriptor
Advanced tools
Package description
The is-accessor-descriptor npm package is used to check if an object property descriptor defines an accessor descriptor. An accessor descriptor is one that includes getter and/or setter functions, as opposed to a data descriptor which contains a value and is writable.
Check if a descriptor is an accessor descriptor
This feature allows you to verify if a given property descriptor from an object is an accessor descriptor. It returns true if the descriptor has a get or set key, and false otherwise.
{"isAccessorDescriptor": require('is-accessor-descriptor');
var descriptor = Object.getOwnPropertyDescriptor({get foo() {}}, 'foo');
console.log(isAccessorDescriptor(descriptor)); //=> true
}
Check if an object is an accessor descriptor
This feature allows you to check if a plain object mimics the structure of an accessor descriptor. It is useful for validation purposes when you have an object that should represent a descriptor and you want to ensure it is an accessor descriptor.
{"isAccessorDescriptor": require('is-accessor-descriptor');
console.log(isAccessorDescriptor({get: function() {}})); //=> true
console.log(isAccessorDescriptor({set: function() {}})); //=> true
console.log(isAccessorDescriptor({value: 123})); //=> false
}
This package is similar to is-accessor-descriptor but checks for data descriptors instead. A data descriptor is an object with a value property and optionally writable, enumerable, and configurable properties. It is the counterpart to is-accessor-descriptor, which checks for accessor descriptors.
is-descriptor is a more general package that checks if an object is a valid property descriptor, which can be either a data descriptor or an accessor descriptor. It is a superset of is-accessor-descriptor and is-data-descriptor functionalities.
While not specifically for checking descriptors, is-plain-object can be used to determine if an object is plain (i.e., created by the Object constructor or one with a null prototype). This can be a preliminary check before further validation as a descriptor.
Readme
Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
$ npm install --save is-accessor-descriptor
const isAccessor = require('is-accessor-descriptor');
const obj = {
get foo() {},
bar: {get: function() {}}
};
isAccessor(obj, 'foo'); //=> true
isAccessor(obj, 'bar'); //=> false
// or, if you already have the descriptor you can pass it directly
const foo = Object.getOwnPropertyDescriptor(obj, 'foo');
isAccessor(foo); //=> true
const bar = Object.getOwnPropertyDescriptor(obj, 'bar');
isAccessor(bar); //=> false
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
You might also be interested in these projects:
Object
constructor. | homepageCommits | Contributor |
---|---|
29 | jonschlinkert |
2 | realityking |
Jon Schlinkert
Copyright © 2018, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.8.0, on December 13, 2018.
FAQs
Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.
The npm package is-accessor-descriptor receives a total of 24,443,105 weekly downloads. As such, is-accessor-descriptor popularity was classified as popular.
We found that is-accessor-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.
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.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.