UNPKG

babel-core

Version:

Turn ES6 code into readable vanilla ES5 with source maps

22 lines (16 loc) 429 B
"use strict"; var t = require("../../types"); exports.has = function (node) { var first = node.body[0]; return t.isExpressionStatement(first) && t.isLiteral(first.expression, { value: "use strict" }); }; exports.wrap = function (node, callback) { var useStrictNode; if (exports.has(node)) { useStrictNode = node.body.shift(); } callback(); if (useStrictNode) { node.body.unshift(useStrictNode); } };