update, text, response
This commit is contained in:
95
node_modules/is-accessor-descriptor/index.js
generated
vendored
95
node_modules/is-accessor-descriptor/index.js
generated
vendored
@@ -1,69 +1,50 @@
|
||||
/*!
|
||||
* is-accessor-descriptor <https://github.com/jonschlinkert/is-accessor-descriptor>
|
||||
*
|
||||
* Copyright (c) 2015-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var typeOf = require('kind-of');
|
||||
var hasOwn = require('hasown');
|
||||
|
||||
// accessor descriptor properties
|
||||
var accessor = {
|
||||
get: 'function',
|
||||
set: 'function',
|
||||
configurable: 'boolean',
|
||||
enumerable: 'boolean'
|
||||
__proto__: null,
|
||||
configurable: 'boolean',
|
||||
enumerable: 'boolean',
|
||||
get: 'function',
|
||||
set: 'function'
|
||||
};
|
||||
|
||||
function isAccessorDescriptor(obj, prop) {
|
||||
if (typeof prop === 'string') {
|
||||
var val = Object.getOwnPropertyDescriptor(obj, prop);
|
||||
return typeof val !== 'undefined';
|
||||
}
|
||||
module.exports = function isAccessorDescriptor(obj, prop) {
|
||||
if (typeof prop === 'string') {
|
||||
var val = Object.getOwnPropertyDescriptor(obj, prop);
|
||||
return typeof val !== 'undefined';
|
||||
}
|
||||
|
||||
if (typeOf(obj) !== 'object') {
|
||||
return false;
|
||||
}
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (has(obj, 'value') || has(obj, 'writable')) {
|
||||
return false;
|
||||
}
|
||||
if (hasOwn(obj, 'value') || hasOwn(obj, 'writable')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!has(obj, 'get') || typeof obj.get !== 'function') {
|
||||
return false;
|
||||
}
|
||||
// one of them must be a function
|
||||
if (
|
||||
(!hasOwn(obj, 'get') || typeof obj.get !== 'function')
|
||||
&& (!hasOwn(obj, 'set') || typeof obj.set !== 'function')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// tldr: it's valid to have "set" be undefined
|
||||
// "set" might be undefined if `Object.getOwnPropertyDescriptor`
|
||||
// was used to get the value, and only `get` was defined by the user
|
||||
if (has(obj, 'set') && typeof obj[key] !== 'function' && typeof obj[key] !== 'undefined') {
|
||||
return false;
|
||||
}
|
||||
// both of them must be a function or undefined
|
||||
if (
|
||||
(hasOwn(obj, 'get') && typeof obj.get !== 'function' && typeof obj.get !== 'undefined')
|
||||
|| (hasOwn(obj, 'set') && typeof obj.set !== 'function' && typeof obj.set !== 'undefined')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var key in obj) {
|
||||
if (!accessor.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeOf(obj[key]) === accessor[key]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof obj[key] !== 'undefined') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function has(obj, key) {
|
||||
return {}.hasOwnProperty.call(obj, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose `isAccessorDescriptor`
|
||||
*/
|
||||
|
||||
module.exports = isAccessorDescriptor;
|
||||
for (var key in obj) { // eslint-disable-line no-restricted-syntax
|
||||
if (hasOwn(obj, key) && hasOwn(accessor, key) && typeof obj[key] !== accessor[key] && typeof obj[key] !== 'undefined') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user