{"name":"is-descriptor","version":"0.1.7","description":"Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for data descriptors and accessor descriptors.","main":"index.js","exports":{".":"./index.js","./package.json":"./package.json"},"scripts":{"prepack":"npmignore --auto --commentLines=autogenerated","prepublishOnly":"safe-publish-latest","prepublish":"not-in-publish || npm run prepublishOnly","prelint":"evalmd README.md","lint":"eslint --ext=js,mjs .","pretest":"npm run lint","tests-only":"nyc tape 'test/**/*.js'","test":"npm run tests-only","posttest":"aud --production","version":"auto-changelog && git add CHANGELOG.md","postversion":"auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""},"repository":{"type":"git","url":"git+https://github.com/inspect-js/is-descriptor.git"},"keywords":["accessor","check","data","descriptor","get","getter","is","keys","object","properties","property","set","setter","type","valid","value"],"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"license":"MIT","bugs":{"url":"https://github.com/inspect-js/is-descriptor/issues"},"homepage":"https://github.com/inspect-js/is-descriptor","contributors":[{"name":"Brian Woodward","url":"https://twitter.com/doowb"},{"name":"Jon Schlinkert","url":"http://twitter.com/jonschlinkert"},{"url":"https://github.com/wtgtybhertgeghgtwtg"}],"dependencies":{"is-accessor-descriptor":"^1.0.1","is-data-descriptor":"^1.0.1"},"devDependencies":{"@ljharb/eslint-config":"^21.1.0","aud":"^2.0.3","auto-changelog":"^2.4.0","eslint":"=8.8.0","evalmd":"^0.0.19","in-publish":"^2.0.1","npmignore":"^0.3.0","nyc":"^10.3.2","safe-publish-latest":"^2.0.0","tape":"^5.7.2"},"engines":{"node":">= 0.4"},"auto-changelog":{"output":"CHANGELOG.md","template":"keepachangelog","unreleased":false,"commitLimit":false,"backfillLimit":false,"hideCredit":true},"publishConfig":{"ignore":[".github/workflows"]},"_id":"is-descriptor@0.1.7","readme":"# is-descriptor <sup>[![Version Badge][npm-version-svg]][package-url]</sup>\n\n[![github actions][actions-image]][actions-url]\n[![coverage][codecov-image]][codecov-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[![npm badge][npm-badge-png]][package-url]\n\n> Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for data descriptors and accessor descriptors.\n\n## Usage\n\n```js\nconst isDescriptor = require('is-descriptor');\nconst assert = require('assert');\n\nassert.equal(isDescriptor({ value: 'foo' }), true);\nassert.equal(isDescriptor({ get() {}, set() {} }), true);\nassert.equal(isDescriptor({ get: 'foo', set() {} }), false);\n```\n\nYou may also check for a descriptor by passing an object as the first argument and property name (`string`) as the second argument.\n\n```js\nconst obj = { foo: 'abc' };\n\nObject.defineProperty(obj, 'bar', {\n  value: 'xyz'\n});\n\nassert.equal(isDescriptor(obj, 'foo'), true);\nassert.equal(isDescriptor(obj, 'bar'), true);\n```\n\n## Examples\n\n### value type\n\n`false` when not an object\n\n```js\nassert.equal(isDescriptor('a'), false);\nassert.equal(isDescriptor(null), false);\nassert.equal(isDescriptor([]), false);\n```\n\n### data descriptor\n\n`true` when the object has valid properties with valid values.\n\n```js\nassert.equal(isDescriptor({ value: 'foo' }), true);\nassert.equal(isDescriptor({ value() {} }), true);\n```\n\n`false` when the object has invalid properties\n\n```js\nassert.equal(isDescriptor({ value: 'foo', enumerable: 'baz' }), false);\nassert.equal(isDescriptor({ value: 'foo', configurable: 'baz' }), false);\nassert.equal(isDescriptor({ value: 'foo', get() {} }), false);\nassert.equal(isDescriptor({ get() {}, value() {} }), false);\n```\n\n`false` when a value is not the correct type\n\n```js\nassert.equal(isDescriptor({ value: 'foo', enumerable: 'foo' }), false);\nassert.equal(isDescriptor({ value: 'foo', configurable: 'foo' }), false);\nassert.equal(isDescriptor({ value: 'foo', writable: 'foo' }), false);\n```\n\n### accessor descriptor\n\n`true` when the object has valid properties with valid values.\n\n```js\nassert.equal(isDescriptor({ get() {}, set() {} }), true);\nassert.equal(isDescriptor({ get() {} }), true);\nassert.equal(isDescriptor({ set() {} }), true);\n```\n\n`false` when the object has invalid properties\n\n```js\nassert.equal(isDescriptor({ get() {}, set() {}, enumerable: 'baz' }), false);\nassert.equal(isDescriptor({ get() {}, writable: true }), false);\nassert.equal(isDescriptor({ get() {}, value: true }), false);\n```\n\n`false` when an accessor is not a function\n\n```js\nassert.equal(isDescriptor({ get() {}, set: 'baz' }), false);\nassert.equal(isDescriptor({ get: 'foo', set() {} }), false);\nassert.equal(isDescriptor({ get: 'foo', bar: 'baz' }), false);\nassert.equal(isDescriptor({ get: 'foo', set: 'baz' }), false);\n```\n\n`false` when a value is not the correct type\n\n```js\nassert.equal(isDescriptor({ get() {}, set() {}, enumerable: 'foo' }), false);\nassert.equal(isDescriptor({ set() {}, configurable: 'foo' }), false);\nassert.equal(isDescriptor({ get() {}, configurable: 'foo' }), false);\n```\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [is-accessor-descriptor](https://www.npmjs.com/package/is-accessor-descriptor): Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.\n* [is-data-descriptor](https://www.npmjs.com/package/is-data-descriptor): Returns true if a value has the characteristics of a valid JavaScript data descriptor.\n* [is-object](https://www.npmjs.com/package/is-object): Returns true if the value is an object and not an array or null.\n\n## Tests\nSimply clone the repo, `npm install`, and run `npm test`\n\n[package-url]: https://npmjs.org/package/is-descriptor\n[npm-version-svg]: https://versionbadg.es/inspect-js/is-descriptor.svg\n[deps-svg]: https://david-dm.org/inspect-js/is-descriptor.svg\n[deps-url]: https://david-dm.org/inspect-js/is-descriptor\n[dev-deps-svg]: https://david-dm.org/inspect-js/is-descriptor/dev-status.svg\n[dev-deps-url]: https://david-dm.org/inspect-js/is-descriptor#info=devDependencies\n[npm-badge-png]: https://nodei.co/npm/is-descriptor.png?downloads=true&stars=true\n[license-image]: https://img.shields.io/npm/l/is-descriptor.svg\n[license-url]: LICENSE\n[downloads-image]: https://img.shields.io/npm/dm/is-descriptor.svg\n[downloads-url]: https://npm-stat.com/charts.html?package=is-descriptor\n[codecov-image]: https://codecov.io/gh/inspect-js/is-descriptor/branch/main/graphs/badge.svg\n[codecov-url]: https://app.codecov.io/gh/inspect-js/is-descriptor/\n[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-descriptor\n[actions-url]: https://github.com/inspect-js/is-descriptor/actions\n","readmeFilename":"README.md","gitHead":"839ee8f13f3e6e53226132d8828073d8c2b4a543","_nodeVersion":"21.0.0","_npmVersion":"10.2.0","dist":{"integrity":"sha512-C3grZTvObeN1xud4cRWl366OMXZTj0+HGyk4hvfpx4ZHt1Pb60ANSXqCK7pdOTeUQpRzECBSTphqvD7U+l22Eg==","shasum":"2727eb61fd789dcd5bdf0ed4569f551d2fe3be33","tarball":"https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.7.tgz","fileCount":11,"unpackedSize":22882,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHh7R9hQ2n3AmYzmK3qjp3VSN4zPWEMN068reHhkOg2bAiEA4j/S25lKEwp/Wgkvfq2wYUusVG0ZSjgHpZPRtEGa458="}]},"_npmUser":{"name":"ljharb","email":"ljharb@gmail.com"},"directories":{},"maintainers":[{"name":"ljharb","email":"ljharb@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/is-descriptor_0.1.7_1698382146081_0.47166455843042976"},"_hasShrinkwrap":false}