SmartStorage/node_modules/has-property-descriptors/index.js

23 lines
588 B
JavaScript
Raw Normal View History

2023-12-24 13:23:39 +08:00
'use strict';
2024-12-02 17:23:01 +08:00
var $defineProperty = require('es-define-property');
2023-12-24 13:23:39 +08:00
var hasPropertyDescriptors = function hasPropertyDescriptors() {
2024-12-02 17:23:01 +08:00
return !!$defineProperty;
2023-12-24 13:23:39 +08:00
};
hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() {
// node v0.6 has a bug where array lengths can be Set but not Defined
2024-12-02 17:23:01 +08:00
if (!$defineProperty) {
2023-12-24 13:23:39 +08:00
return null;
}
try {
return $defineProperty([], 'length', { value: 1 }).length !== 1;
} catch (e) {
// In Firefox 4-22, defining length on an array throws an exception.
return true;
}
};
module.exports = hasPropertyDescriptors;