mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
24 lines
516 B
JavaScript
24 lines
516 B
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = annotateAsPure;
|
|
|
|
var t = require("@babel/types");
|
|
|
|
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;
|
|
}
|
|
|
|
t.addComment(node, "leading", PURE_ANNOTATION);
|
|
} |