is-descriptor
Advanced tools
Comparing version 0.1.3 to 0.1.4
12
index.js
@@ -12,6 +12,10 @@ /*! | ||
module.exports = function isDescriptor(obj) { | ||
if (utils.typeOf(obj) !== 'object') return false; | ||
if ('value' in obj) return utils.isData(obj); | ||
return utils.isAccessor(obj); | ||
module.exports = function isDescriptor(obj, key) { | ||
if (utils.typeOf(obj) !== 'object') { | ||
return false; | ||
} | ||
if ('get' in obj) { | ||
return utils.isAccessor(obj, key); | ||
} | ||
return utils.isData(obj, key); | ||
}; |
{ | ||
"name": "is-descriptor", | ||
"description": "Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for data descriptors and accessor descriptors.", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"homepage": "https://github.com/jonschlinkert/is-descriptor", | ||
@@ -24,4 +24,4 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"dependencies": { | ||
"is-accessor-descriptor": "^0.1.4", | ||
"is-data-descriptor": "^0.1.3", | ||
"is-accessor-descriptor": "^0.1.6", | ||
"is-data-descriptor": "^0.1.4", | ||
"kind-of": "^3.0.2", | ||
@@ -31,4 +31,3 @@ "lazy-cache": "^1.0.3" | ||
"devDependencies": { | ||
"mocha": "*", | ||
"should": "*" | ||
"mocha": "*" | ||
}, | ||
@@ -35,0 +34,0 @@ "keywords": [ |
@@ -7,3 +7,3 @@ # is-descriptor [![NPM version](https://img.shields.io/npm/v/is-descriptor.svg)](https://www.npmjs.com/package/is-descriptor) [![Build Status](https://img.shields.io/travis/jonschlinkert/is-descriptor.svg)](https://travis-ci.org/jonschlinkert/is-descriptor) | ||
Install with [npm](https://www.npmjs.com/) | ||
Install with [npm](https://www.npmjs.com/): | ||
@@ -27,2 +27,18 @@ ```sh | ||
You may also check for a descriptor by passing an object as the first argument and property name (`string`) as the second argument. | ||
```js | ||
var obj = {}; | ||
obj.foo = 'abc'; | ||
Object.defineProperty(obj, 'bar', { | ||
value: 'xyz' | ||
}); | ||
isDescriptor(obj, 'foo'); | ||
//=> true | ||
isDescriptor(obj, 'bar'); | ||
//=> true | ||
``` | ||
## Examples | ||
@@ -158,2 +174,2 @@ | ||
_This file was generated by [verb](https://github.com/verbose/verb) on December 20, 2015._ | ||
_This file was generated by [verb](https://github.com/verbose/verb) on December 28, 2015._ |
@@ -10,2 +10,7 @@ 'use strict'; | ||
require = utils; | ||
/** | ||
* Utils | ||
*/ | ||
require('kind-of', 'typeOf'); | ||
@@ -12,0 +17,0 @@ require('is-accessor-descriptor', 'isAccessor'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7232
1
35
172
Updatedis-data-descriptor@^0.1.4