You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
806 B

2 months ago
'use strict';
var hasOwn = require('hasown');
// data descriptor properties
var data = {
__proto__: null,
configurable: 'boolean',
enumerable: 'boolean',
writable: 'boolean',
};
module.exports = function isDataDescriptor(obj, prop) {
if (!obj || 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))
|| 'get' in obj
|| 'set' in obj
) {
return false;
}
for (var key in obj) { // eslint-disable-line no-restricted-syntax
if (
key !== 'value'
&& hasOwn(obj, key)
&& hasOwn(data, key)
&& typeof obj[key] !== data[key]
&& typeof obj[key] !== 'undefined'
) {
return false;
}
}
return true;
};