mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 20:30:04 +02:00
add some babel stuff
This commit is contained in:
56
node_modules/define-properties/index.js
generated
vendored
Normal file
56
node_modules/define-properties/index.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
var keys = require('object-keys');
|
||||
var foreach = require('foreach');
|
||||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
|
||||
|
||||
var toStr = Object.prototype.toString;
|
||||
|
||||
var isFunction = function (fn) {
|
||||
return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
|
||||
};
|
||||
|
||||
var arePropertyDescriptorsSupported = function () {
|
||||
var obj = {};
|
||||
try {
|
||||
Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
|
||||
/* eslint-disable no-unused-vars, no-restricted-syntax */
|
||||
for (var _ in obj) { return false; }
|
||||
/* eslint-enable no-unused-vars, no-restricted-syntax */
|
||||
return obj.x === obj;
|
||||
} catch (e) { /* this is IE 8. */
|
||||
return false;
|
||||
}
|
||||
};
|
||||
var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();
|
||||
|
||||
var defineProperty = function (object, name, value, predicate) {
|
||||
if (name in object && (!isFunction(predicate) || !predicate())) {
|
||||
return;
|
||||
}
|
||||
if (supportsDescriptors) {
|
||||
Object.defineProperty(object, name, {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: value,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
object[name] = value;
|
||||
}
|
||||
};
|
||||
|
||||
var defineProperties = function (object, map) {
|
||||
var predicates = arguments.length > 2 ? arguments[2] : {};
|
||||
var props = keys(map);
|
||||
if (hasSymbols) {
|
||||
props = props.concat(Object.getOwnPropertySymbols(map));
|
||||
}
|
||||
foreach(props, function (name) {
|
||||
defineProperty(object, name, map[name], predicates[name]);
|
||||
});
|
||||
};
|
||||
|
||||
defineProperties.supportsDescriptors = !!supportsDescriptors;
|
||||
|
||||
module.exports = defineProperties;
|
Reference in New Issue
Block a user