41 lines
No EOL
1.1 KiB
JavaScript
41 lines
No EOL
1.1 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License.
|
|
*/
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.makeRevocable = exports.shallowCopy = void 0;
|
|
/**
|
|
* @private
|
|
*/
|
|
function shallowCopy(value) {
|
|
if (Array.isArray(value)) {
|
|
return value.slice(0);
|
|
}
|
|
if (typeof value === 'object') {
|
|
return Object.assign({}, value);
|
|
}
|
|
return value;
|
|
}
|
|
exports.shallowCopy = shallowCopy;
|
|
/**
|
|
* @private
|
|
* @param target a thing that will be made revocable
|
|
* @param handler an object that defines the way the new revocable object works
|
|
*/
|
|
function makeRevocable(target, handler) {
|
|
// Ensure proxy supported (some browsers don't)
|
|
if (typeof Proxy !== 'undefined' && Proxy.revocable) {
|
|
return Proxy.revocable(target, handler || {});
|
|
}
|
|
else {
|
|
return {
|
|
proxy: target,
|
|
revoke: () => {
|
|
// noop
|
|
},
|
|
};
|
|
}
|
|
}
|
|
exports.makeRevocable = makeRevocable;
|
|
//# sourceMappingURL=internal.js.map
|