@babel/helper-annotate-as-pure
Version:
Helper function to annotate paths and nodes with #__PURE__ comment
20 lines (17 loc) • 498 B
JavaScript
import * as _t from '@babel/types';
const {
addComment
} = _t;
const PURE_ANNOTATION = "#__PURE__";
const isPureAnnotated = ({
leadingComments
}) => !!leadingComments && leadingComments.some(comment => /[@#]__PURE__/.test(comment.value));
function annotateAsPure(pathOrNode) {
const node = pathOrNode.node || pathOrNode;
if (isPureAnnotated(node)) {
return;
}
addComment(node, "leading", PURE_ANNOTATION);
}
export { annotateAsPure as default };
//# sourceMappingURL=index.js.map