Sha256: a2bac90ae7284dbdff11f30cc643a3b6bf1c2f7a1641214315f09c068cae069a

Contents?: true

Size: 1.44 KB

Versions: 13

Compression:

Stored size: 1.44 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = annotateAsPure;

var t = _interopRequireWildcard(require("@babel/types"));

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

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);
}

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/@babel/helper-annotate-as-pure/lib/index.js
tang-0.2.1 spec/tang_app/node_modules/@babel/helper-annotate-as-pure/lib/index.js
tang-0.2.0 spec/tang_app/node_modules/@babel/helper-annotate-as-pure/lib/index.js
tang-0.1.0 spec/tang_app/node_modules/@babel/helper-annotate-as-pure/lib/index.js
tang-0.0.9 spec/tang_app/node_modules/@babel/helper-annotate-as-pure/lib/index.js
enju_library-0.3.8 spec/dummy/node_modules/@babel/helper-annotate-as-pure/lib/index.js
condenser-0.3 lib/condenser/processors/node_modules/@babel/helper-annotate-as-pure/lib/index.js
condenser-0.2 lib/condenser/processors/node_modules/@babel/helper-annotate-as-pure/lib/index.js
condenser-0.1 lib/condenser/processors/node_modules/@babel/helper-annotate-as-pure/lib/index.js
condenser-0.0.12 lib/condenser/processors/node_modules/@babel/helper-annotate-as-pure/lib/index.js
condenser-0.0.11 lib/condenser/processors/node_modules/@babel/helper-annotate-as-pure/lib/index.js
condenser-0.0.10 lib/condenser/processors/node_modules/@babel/helper-annotate-as-pure/lib/index.js
condenser-0.0.9 lib/condenser/processors/node_modules/@babel/helper-annotate-as-pure/lib/index.js