UNPKG

574 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = annotateAsPure;
7var _t = require("@babel/types");
8const {
9 addComment
10} = _t;
11const PURE_ANNOTATION = "#__PURE__";
12const isPureAnnotated = ({
13 leadingComments
14}) => !!leadingComments && leadingComments.some(comment => /[@#]__PURE__/.test(comment.value));
15function annotateAsPure(pathOrNode) {
16 const node = pathOrNode["node"] || pathOrNode;
17 if (isPureAnnotated(node)) {
18 return;
19 }
20 addComment(node, "leading", PURE_ANNOTATION);
21}
22
23//# sourceMappingURL=index.js.map