babel-helper-decorate-react
Version:
Babel Helper for custom decorator for React Component
20 lines (19 loc) • 507 B
JavaScript
export const isScopeDepthPassed = (path, detectScopeDepth) => {
if (detectScopeDepth == null || detectScopeDepth < 0) {
return true;
}
let t = detectScopeDepth;
let scope = path.scope;
do {
scope = scope.parent;
if (t === 0 && !scope) {
return true;
}
t--;
} while (t >= 0 && scope);
return false;
};
export const replaceAdvancedWith = (path, replacement) => {
const rlt = path.replaceWith(replacement);
return rlt;
};