Socket
Socket
Sign inDemoInstall

is-accessor-descriptor

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-accessor-descriptor

Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.


Version published
Weekly downloads
26M
decreased by-17.48%
Maintainers
1
Install size
9.29 kB
Created
Weekly downloads
 

Package description

What is is-accessor-descriptor?

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.

What are is-accessor-descriptor's main functionalities?

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
}

Other packages similar to is-accessor-descriptor

Changelog

Source

v3.0.1 - 2018-12-13

Commits

  • cleanup readme 5cce1d2
  • remove unnecessary check 288d4b9

Readme

Source

is-accessor-descriptor NPM version NPM monthly downloads NPM total downloads Linux Build Status

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

Install with npm:

$ npm install --save is-accessor-descriptor

Usage

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

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Running Tests

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
Building docs

(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:

Contributors

CommitsContributor
29jonschlinkert
2realityking

Author

Jon Schlinkert

License

Copyright © 2018, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.8.0, on December 13, 2018.

Keywords

FAQs

Last updated on 14 Dec 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc