Files
2023-08-01 13:49:46 +02:00

71 lines
2.3 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.cloneDescriptor = cloneDescriptor;
exports.clearDescriptor = clearDescriptor;
exports.copyDescriptor = copyDescriptor;
exports.equalDescriptors = equalDescriptors;
function cloneDescriptor(d) {
if (d === undefined) return undefined;
var clone = {};
copyDescriptor(d, clone);
return clone;
} /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
function clearDescriptor(d) {
delete d.writable;
delete d.enumerable;
delete d.configurable;
delete d.value;
delete d.get;
delete d.set;
}
function copyDescriptor(from, to) {
if (from.hasOwnProperty("writable")) to.writable = from.writable;
if (from.hasOwnProperty("enumerable")) to.enumerable = from.enumerable;
if (from.hasOwnProperty("configurable")) to.configurable = from.configurable;
if (from.hasOwnProperty("value")) {
if (from.value instanceof Array) to.value = from.value.slice();else to.value = from.value;
}
if (from.hasOwnProperty("get")) to.get = from.get;
if (from.hasOwnProperty("set")) to.set = from.set;
}
// does not check if the contents of value properties are the same
function equalDescriptors(d1, d2) {
if (d1.hasOwnProperty("writable")) {
if (!d2.hasOwnProperty("writable")) return false;
if (d1.writable !== d2.writable) return false;
}
if (d1.hasOwnProperty("enumerable")) {
if (!d2.hasOwnProperty("enumerable")) return false;
if (d1.enumerable !== d2.enumerable) return false;
}
if (d1.hasOwnProperty("configurable")) {
if (!d2.hasOwnProperty("configurable")) return false;
if (d1.configurable !== d2.configurable) return false;
}
if (d1.hasOwnProperty("value")) {
if (!d2.hasOwnProperty("value")) return false;
}
if (d1.hasOwnProperty("get")) {
if (!d2.hasOwnProperty("get")) return false;
if (d1.get !== d2.get) return false;
}
if (d1.hasOwnProperty("set")) {
if (!d2.hasOwnProperty("set")) return false;
if (d1.set !== d2.set) return false;
}
return true;
}
//# sourceMappingURL=descriptor.js.map