1 # is-descriptor [![NPM version](https://img.shields.io/npm/v/is-descriptor.svg?style=flat)](https://www.npmjs.com/package/is-descriptor) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-descriptor.svg?style=flat)](https://npmjs.org/package/is-descriptor) [![NPM total downloads](https://img.shields.io/npm/dt/is-descriptor.svg?style=flat)](https://npmjs.org/package/is-descriptor) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/is-descriptor.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/is-descriptor)
3 > Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for data descriptors and accessor descriptors.
7 Install with [npm](https://www.npmjs.com/):
10 $ npm install --save is-descriptor
16 var isDescriptor = require('is-descriptor');
18 isDescriptor({value: 'foo'})
20 isDescriptor({get: function(){}, set: function(){}})
22 isDescriptor({get: 'foo', set: function(){}})
26 You may also check for a descriptor by passing an object as the first argument and property name (`string`) as the second argument.
32 Object.defineProperty(obj, 'bar', {
36 isDescriptor(obj, 'foo');
38 isDescriptor(obj, 'bar');
46 `false` when not an object
59 `true` when the object has valid properties with valid values.
62 isDescriptor({value: 'foo'});
64 isDescriptor({value: noop});
68 `false` when the object has invalid properties
71 isDescriptor({value: 'foo', bar: 'baz'});
73 isDescriptor({value: 'foo', bar: 'baz'});
75 isDescriptor({value: 'foo', get: noop});
77 isDescriptor({get: noop, value: noop});
81 `false` when a value is not the correct type
84 isDescriptor({value: 'foo', enumerable: 'foo'});
86 isDescriptor({value: 'foo', configurable: 'foo'});
88 isDescriptor({value: 'foo', writable: 'foo'});
92 ### accessor descriptor
94 `true` when the object has valid properties with valid values.
97 isDescriptor({get: noop, set: noop});
99 isDescriptor({get: noop});
101 isDescriptor({set: noop});
105 `false` when the object has invalid properties
108 isDescriptor({get: noop, set: noop, bar: 'baz'});
110 isDescriptor({get: noop, writable: true});
112 isDescriptor({get: noop, value: true});
116 `false` when an accessor is not a function
119 isDescriptor({get: noop, set: 'baz'});
121 isDescriptor({get: 'foo', set: noop});
123 isDescriptor({get: 'foo', bar: 'baz'});
125 isDescriptor({get: 'foo', set: 'baz'});
129 `false` when a value is not the correct type
132 isDescriptor({get: noop, set: noop, enumerable: 'foo'});
134 isDescriptor({set: noop, configurable: 'foo'});
136 isDescriptor({get: noop, configurable: 'foo'});
144 * [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. | [homepage](https://github.com/jonschlinkert/is-accessor-descriptor "Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.")
145 * [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. | [homepage](https://github.com/jonschlinkert/is-data-descriptor "Returns true if a value has the characteristics of a valid JavaScript data descriptor.")
146 * [is-descriptor](https://www.npmjs.com/package/is-descriptor): Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for… [more](https://github.com/jonschlinkert/is-descriptor) | [homepage](https://github.com/jonschlinkert/is-descriptor "Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for data descriptors and accessor descriptors.")
147 * [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.")
151 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
155 | **Commits** | **Contributor** |
157 | 24 | [jonschlinkert](https://github.com/jonschlinkert) |
158 | 1 | [doowb](https://github.com/doowb) |
159 | 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
163 _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
165 To generate the readme, run the following command:
168 $ npm install -g verbose/verb#dev verb-generate-readme && verb
173 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:
176 $ npm install && npm test
183 * [github/jonschlinkert](https://github.com/jonschlinkert)
184 * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
188 Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
189 Released under the [MIT License](LICENSE).
193 _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 22, 2017._