Socket
Socket
Sign inDemoInstall

is-data-descriptor

Package Overview
Dependencies
1
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0

64

index.js

@@ -1,49 +0,29 @@

/*!
* is-data-descriptor <https://github.com/jonschlinkert/is-data-descriptor>
*
* Copyright (c) 2015-2017, Jon Schlinkert.
* Released under the MIT License.
*/
'use strict';
var typeOf = require('kind-of');
const hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
const isObject = val => {
return val !== null && typeof val === 'object' && !Array.isArray(val);
};
module.exports = function isDataDescriptor(obj, prop) {
// data descriptor properties
var data = {
configurable: 'boolean',
enumerable: 'boolean',
writable: 'boolean'
};
if (typeOf(obj) !== 'object') {
return false;
}
if (typeof prop === 'string') {
var val = Object.getOwnPropertyDescriptor(obj, prop);
return typeof val !== 'undefined';
}
if (!('value' in obj) && !('writable' in obj)) {
return false;
}
for (var key in obj) {
if (key === 'value') continue;
if (!data.hasOwnProperty(key)) {
continue;
const isDescriptor = (obj, key) => {
if (!isObject(obj)) return false;
let desc = key ? Object.getOwnPropertyDescriptor(obj, key) : obj;
if (isObject(desc)) {
let booleans = ['configurable', 'enumerable', 'writable'];
if (!hasOwn(desc, 'value') || hasOwn(desc, 'get') || hasOwn(desc, 'set')) {
return false;
}
if (typeOf(obj[key]) === data[key]) {
continue;
for (let key of Object.keys(desc)) {
if (booleans.includes(key) && typeof desc[key] !== 'boolean') {
return false;
}
if (!booleans.includes(key) && key !== 'value') {
return false;
}
}
if (typeof obj[key] !== 'undefined') {
return false;
}
return true;
}
return true;
return false;
};
module.exports = isDescriptor;
{
"name": "is-data-descriptor",
"description": "Returns true if a value has the characteristics of a valid JavaScript data descriptor.",
"version": "1.0.0",
"version": "2.0.0",
"homepage": "https://github.com/jonschlinkert/is-data-descriptor",

@@ -21,3 +21,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"engines": {
"node": ">=0.10.0"
"node": ">=6"
},

@@ -24,0 +24,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

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