Urara-Blog/node_modules/.pnpm-store/v3/files/23/d966fec93420194b1da13b16e73a7514187e47a0d5c2cbf0fbc39a7a5330dce0cbf258b3741daae04f80abcd1737a5a69e5730def0302c36393e92b92b2531
2022-08-14 01:14:53 +08:00

45 lines
960 B
Text

/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
let currentTypes = null;
export function wrapWithTypes(types, fn) {
return function (...args) {
const oldTypes = currentTypes;
currentTypes = types;
try {
return fn.apply(this, args);
} finally {
currentTypes = oldTypes;
}
};
}
export function getTypes() {
return currentTypes;
}
export function runtimeProperty(name) {
const t = getTypes();
return t.memberExpression(
t.identifier("regeneratorRuntime"),
t.identifier(name),
false
);
}
export function isReference(path) {
return path.isReferenced() || path.parentPath.isAssignmentExpression({ left: path.node });
}
export function replaceWithOrRemove(path, replacement) {
if (replacement) {
path.replaceWith(replacement)
} else {
path.remove();
}
}