diff --git a/bin/6to5/index.js b/bin/6to5/index.js index 14b99e724b..48c3d0f8f9 100755 --- a/bin/6to5/index.js +++ b/bin/6to5/index.js @@ -4,7 +4,8 @@ var commander = require("commander"); var transform = require("../../lib/6to5/transformation/transform"); var util = require("../../lib/6to5/util"); var fs = require("fs"); -var _ = require("lodash"); +var each = require("lodash/collection/each"); +var keys = require("lodash/object/keys"); commander.option("-t, --source-maps-inline", "Append sourceMappingURL comment to bottom of code"); commander.option("-s, --source-maps", "Save source map alongside the compiled code"); @@ -30,7 +31,7 @@ commander.on("--help", function () { console.log(" " + title + ":"); console.log(); - _.each(_.keys(obj).sort(), function (key) { + each(keys(obj).sort(), function (key) { if (key[0] === "_") return; if (obj[key].optional) { @@ -58,7 +59,7 @@ var errors = []; var filenames = commander.args; -_.each(filenames, function (filename) { +each(filenames, function (filename) { if (!fs.existsSync(filename)) { errors.push(filename + " doesn't exist"); } diff --git a/lib/6to5/file.js b/lib/6to5/file.js index 06f423065c..3cd89c2cf7 100644 --- a/lib/6to5/file.js +++ b/lib/6to5/file.js @@ -4,13 +4,16 @@ module.exports = File; var SHEBANG_REGEX = /^\#\!.*/; -var transform = require("./transformation/transform"); -var generate = require("./generation/generator"); -var clone = require("./helpers/clone"); -var Scope = require("./traverse/scope"); -var util = require("./util"); -var t = require("./types"); -var _ = require("lodash"); +var transform = require("./transformation/transform"); +var generate = require("./generation/generator"); +var clone = require("./helpers/clone"); +var Scope = require("./traverse/scope"); +var util = require("./util"); +var t = require("./types"); +var contains = require("lodash/collection/contains"); +var each = require("lodash/collection/each"); +var defaults = require("lodash/object/defaults"); +var isFunction = require("lodash/lang/isFunction"); function File(opts) { this.dynamicImportIds = {}; @@ -87,7 +90,7 @@ File.normaliseOptions = function (opts) { } } - _.defaults(opts, { + defaults(opts, { keepModuleIdExtensions: false, experimental: false, reactCompat: false, @@ -114,23 +117,23 @@ File.normaliseOptions = function (opts) { opts.optional = util.arrayify(opts.optional); opts.loose = util.arrayify(opts.loose); - if (_.contains(opts.loose, "all")) { + if (contains(opts.loose, "all")) { opts.loose = Object.keys(transform.transformers); } - _.defaults(opts, { + defaults(opts, { moduleRoot: opts.sourceRoot }); - _.defaults(opts, { + defaults(opts, { sourceRoot: opts.moduleRoot }); - _.defaults(opts, { + defaults(opts, { filenameRelative: opts.filename }); - _.defaults(opts, { + defaults(opts, { sourceFileName: opts.filenameRelative, sourceMapName: opts.filenameRelative }); @@ -148,7 +151,7 @@ File.normaliseOptions = function (opts) { }; File.prototype.isLoose = function (key) { - return _.contains(this.opts.loose, key); + return contains(this.opts.loose, key); }; File.prototype.buildTransformers = function () { @@ -159,7 +162,7 @@ File.prototype.buildTransformers = function () { var secondaryStack = []; var stack = []; - _.each(transform.transformers, function (transformer, key) { + each(transform.transformers, function (transformer, key) { var pass = transformers[key] = transformer.buildPass(file); if (pass.canRun(file)) { @@ -195,7 +198,7 @@ File.prototype.toArray = function (node, i) { }; File.prototype.getModuleFormatter = function (type) { - var ModuleFormatter = _.isFunction(type) ? type : transform.moduleFormatters[type]; + var ModuleFormatter = isFunction(type) ? type : transform.moduleFormatters[type]; if (!ModuleFormatter) { var loc = util.resolve(type); @@ -264,7 +267,7 @@ File.prototype.isConsequenceExpressionStatement = function (node) { }; File.prototype.addHelper = function (name) { - if (!_.contains(File.helpers, name)) { + if (!contains(File.helpers, name)) { throw new ReferenceError("unknown declaration " + name); } @@ -331,14 +334,14 @@ File.prototype.transform = function (ast) { this.moduleFormatter = this.getModuleFormatter(this.opts.modules); var astRun = function (key) { - _.each(self.transformerStack, function (pass) { + each(self.transformerStack, function (pass) { pass.astRun(key); }); }; astRun("enter"); - _.each(this.transformerStack, function (pass) { + each(this.transformerStack, function (pass) { pass.transform(); }); diff --git a/lib/6to5/generation/buffer.js b/lib/6to5/generation/buffer.js index 3db36a65ad..224c5468a3 100644 --- a/lib/6to5/generation/buffer.js +++ b/lib/6to5/generation/buffer.js @@ -2,8 +2,10 @@ module.exports = Buffer; -var util = require("../util"); -var _ = require("lodash"); +var util = require("../util"); +var isNumber = require("lodash/lang/isNumber"); +var isBoolean = require("lodash/lang/isBoolean"); +var contains = require("lodash/collection/contains"); function Buffer(position, format) { this.position = position; @@ -75,7 +77,7 @@ Buffer.prototype.newline = function (i, removeLast) { removeLast = removeLast || false; - if (_.isNumber(i)) { + if (isNumber(i)) { if (this.endsWith("{\n")) i--; if (this.endsWith(util.repeat(i, "\n"))) return; @@ -85,7 +87,7 @@ Buffer.prototype.newline = function (i, removeLast) { return; } - if (_.isBoolean(i)) { + if (isBoolean(i)) { removeLast = i; } @@ -155,7 +157,7 @@ Buffer.prototype.isLast = function (cha, trimRight) { var last = buf[buf.length - 1]; if (Array.isArray(cha)) { - return _.contains(cha, last); + return contains(cha, last); } else { return cha === last; } diff --git a/lib/6to5/generation/generator.js b/lib/6to5/generation/generator.js index 8850d1fcbc..95113d2254 100644 --- a/lib/6to5/generation/generator.js +++ b/lib/6to5/generation/generator.js @@ -15,7 +15,9 @@ var Buffer = require("./buffer"); var util = require("../util"); var n = require("./node"); var t = require("../types"); -var _ = require("lodash"); +var each = require("lodash/collection/each"); +var extend = require("lodash/object/extend"); +var merge = require("lodash/object/merge"); function CodeGenerator(ast, opts, code) { opts = opts || {}; @@ -31,7 +33,7 @@ function CodeGenerator(ast, opts, code) { this.buffer = new Buffer(this.position, this.format); } -_.each(Buffer.prototype, function (fn, key) { +each(Buffer.prototype, function (fn, key) { CodeGenerator.prototype[key] = function () { return fn.apply(this.buffer, arguments); }; @@ -42,7 +44,7 @@ CodeGenerator.normaliseOptions = function (code, opts) { var style = indent.indent; if (!style || style === " ") style = " "; - return _.merge({ + return merge({ parentheses: true, comments: opts.comments == null || opts.comments, compact: false, @@ -69,8 +71,8 @@ CodeGenerator.generators = { jsx: require("./generators/jsx") }; -_.each(CodeGenerator.generators, function (generator) { - _.extend(CodeGenerator.prototype, generator); +each(CodeGenerator.generators, function (generator) { + extend(CodeGenerator.prototype, generator); }); CodeGenerator.prototype.generate = function () { @@ -79,7 +81,7 @@ CodeGenerator.prototype.generate = function () { this.print(ast); var comments = []; - _.each(ast.comments, function (comment) { + each(ast.comments, function (comment) { if (!comment._displayed) comments.push(comment); }); this._printComments(comments); @@ -208,7 +210,7 @@ CodeGenerator.prototype.printJoin = function (print, nodes, opts) { if (opts.indent) self.indent(); - _.each(nodes, function (node, i) { + each(nodes, function (node, i) { print(node, { statement: opts.statement, after: function () { @@ -273,7 +275,7 @@ CodeGenerator.prototype.getComments = function (key, node, parent) { nodes.push(node.argument); } - _.each(nodes, function (node) { + each(nodes, function (node) { comments = comments.concat(self._getComments(key, node)); }); @@ -291,11 +293,11 @@ CodeGenerator.prototype._printComments = function (comments) { var self = this; - _.each(comments, function (comment) { + each(comments, function (comment) { var skip = false; // find the original comment in the ast and set it as displayed - _.each(self.ast.comments, function (origComment) { + each(self.ast.comments, function (origComment) { if (origComment.start === comment.start) { // comment has already been output if (origComment._displayed) skip = true; diff --git a/lib/6to5/generation/generators/expressions.js b/lib/6to5/generation/generators/expressions.js index 2f1a2adb5b..f7376d97b4 100644 --- a/lib/6to5/generation/generators/expressions.js +++ b/lib/6to5/generation/generators/expressions.js @@ -1,8 +1,8 @@ "use strict"; -var util = require("../../util"); -var t = require("../../types"); -var _ = require("lodash"); +var util = require("../../util"); +var t = require("../../types"); +var isNumber = require("lodash/lang/isNumber"); exports.UnaryExpression = function (node, print) { var hasSpace = /[a-z]$/.test(node.operator); @@ -133,7 +133,7 @@ exports.MemberExpression = function (node, print) { } var computed = node.computed; - if (t.isLiteral(node.property) && _.isNumber(node.property.value)) { + if (t.isLiteral(node.property) && isNumber(node.property.value)) { computed = true; } diff --git a/lib/6to5/generation/generators/jsx.js b/lib/6to5/generation/generators/jsx.js index e4175839a6..8696bfd6ed 100644 --- a/lib/6to5/generation/generators/jsx.js +++ b/lib/6to5/generation/generators/jsx.js @@ -1,7 +1,7 @@ "use strict"; -var t = require("../../types"); -var _ = require("lodash"); +var t = require("../../types"); +var each = require("lodash/collection/each"); exports.JSXAttribute = function (node, print) { print(node.name); @@ -47,7 +47,7 @@ exports.JSXElement = function (node, print) { if (open.selfClosing) return; this.indent(); - _.each(node.children, function (child) { + each(node.children, function (child) { if (t.isLiteral(child)) { self.push(child.value); } else { diff --git a/lib/6to5/generation/generators/modules.js b/lib/6to5/generation/generators/modules.js index 16cff50fcc..9b8aa4ef36 100644 --- a/lib/6to5/generation/generators/modules.js +++ b/lib/6to5/generation/generators/modules.js @@ -1,7 +1,7 @@ "use strict"; -var t = require("../../types"); -var _ = require("lodash"); +var t = require("../../types"); +var each = require("lodash/collection/each"); exports.ImportSpecifier = function (node, print) { if (t.isSpecifierDefault(node)) { @@ -66,7 +66,7 @@ exports.ImportDeclaration = function (node, print) { if (specfiers && specfiers.length) { var foundImportSpecifier = false; - _.each(node.specifiers, function (spec, i) { + each(node.specifiers, function (spec, i) { if (+i > 0) { self.push(", "); } diff --git a/lib/6to5/generation/generators/playground.js b/lib/6to5/generation/generators/playground.js index d11aa04ee6..cc107283d0 100644 --- a/lib/6to5/generation/generators/playground.js +++ b/lib/6to5/generation/generators/playground.js @@ -1,8 +1,8 @@ "use strict"; -var _ = require("lodash"); +var each = require("lodash/collection/each"); -_.each(["BindMemberExpression", "BindFunctionExpression"], function (type) { +each(["BindMemberExpression", "BindFunctionExpression"], function (type) { exports[type] = function () { throw new ReferenceError("Trying to render non-standard playground node " + JSON.stringify(type)); }; diff --git a/lib/6to5/generation/generators/template-literals.js b/lib/6to5/generation/generators/template-literals.js index 4bda97505f..f662a9eb9a 100644 --- a/lib/6to5/generation/generators/template-literals.js +++ b/lib/6to5/generation/generators/template-literals.js @@ -1,6 +1,6 @@ "use strict"; -var _ = require("lodash"); +var each = require("lodash/collection/each"); exports.TaggedTemplateExpression = function (node, print) { print(node.tag); @@ -18,7 +18,7 @@ exports.TemplateLiteral = function (node, print) { var self = this; var len = quasis.length; - _.each(quasis, function (quasi, i) { + each(quasis, function (quasi, i) { print(quasi); if (i + 1 < len) { diff --git a/lib/6to5/generation/generators/types.js b/lib/6to5/generation/generators/types.js index ea824c5c1a..51ec82daad 100644 --- a/lib/6to5/generation/generators/types.js +++ b/lib/6to5/generation/generators/types.js @@ -1,6 +1,6 @@ "use strict"; -var _ = require("lodash"); +var each = require("lodash/collection/each"); exports.Identifier = function (node) { this.push(node.name); @@ -62,7 +62,7 @@ exports.ArrayPattern = function (node, print) { this.push("["); - _.each(elems, function (elem, i) { + each(elems, function (elem, i) { if (!elem) { // If the array expression ends with a hole, that hole // will be ignored by the interpreter, but if it ends with diff --git a/lib/6to5/generation/node/index.js b/lib/6to5/generation/node/index.js index ba6cc61f78..0ded23714b 100644 --- a/lib/6to5/generation/node/index.js +++ b/lib/6to5/generation/node/index.js @@ -5,7 +5,8 @@ module.exports = Node; var whitespace = require("./whitespace"); var parens = require("./parentheses"); var t = require("../../types"); -var _ = require("lodash"); +var each = require("lodash/collection/each"); +var some = require("lodash/collection/some"); var find = function (obj, node, parent) { if (!obj) return; @@ -44,7 +45,7 @@ Node.needsWhitespace = function (node, parent, type) { var lines = find(whitespace[type].nodes, node, parent); if (lines) return lines; - _.each(find(whitespace[type].list, node, parent), function (expr) { + each(find(whitespace[type].list, node, parent), function (expr) { lines = Node.needsWhitespace(expr, node, type); if (lines) return false; }); @@ -65,7 +66,7 @@ Node.needsParens = function (node, parent) { if (t.isNewExpression(parent) && parent.callee === node) { if (t.isCallExpression(node)) return true; - var hasCall = _.some(node, function (val) { + var hasCall = some(node, function (val) { return t.isCallExpression(val); }); if (hasCall) return true; @@ -94,7 +95,7 @@ Node.needsParensNoLineTerminator = function (node, parent) { return false; }; -_.each(Node, function (fn, key) { +each(Node, function (fn, key) { Node.prototype[key] = function () { // Avoid leaking arguments to prevent deoptimization var args = new Array(arguments.length + 2); diff --git a/lib/6to5/generation/node/parentheses.js b/lib/6to5/generation/node/parentheses.js index 2311c9f2c7..92b555e893 100644 --- a/lib/6to5/generation/node/parentheses.js +++ b/lib/6to5/generation/node/parentheses.js @@ -1,11 +1,11 @@ "use strict"; -var t = require("../../types"); -var _ = require("lodash"); +var t = require("../../types"); +var each = require("lodash/collection/each"); var PRECEDENCE = {}; -_.each([ +each([ ["||"], ["&&"], ["|"], @@ -18,7 +18,7 @@ _.each([ ["*", "/", "%"], ["**"] ], function (tier, i) { - _.each(tier, function (op) { + each(tier, function (op) { PRECEDENCE[op] = i; }); }); diff --git a/lib/6to5/generation/node/whitespace.js b/lib/6to5/generation/node/whitespace.js index 8deca5a4b2..b2c6aaecc0 100644 --- a/lib/6to5/generation/node/whitespace.js +++ b/lib/6to5/generation/node/whitespace.js @@ -1,7 +1,9 @@ "use strict"; -var _ = require("lodash"); -var t = require("../../types"); +var t = require("../../types"); +var each = require("lodash/collection/each"); +var map = require("lodash/collection/map"); +var isNumber = require("lodash/lang/isNumber"); exports.before = { nodes: { @@ -40,7 +42,7 @@ exports.after = { list: { VariableDeclaration: function (node) { - return _.map(node.declarations, "init"); + return map(node.declarations, "init"); }, ArrayExpression: function (node) { @@ -53,7 +55,7 @@ exports.after = { } }; -_.each({ +each({ Function: 1, Class: 1, For: 1, @@ -64,12 +66,12 @@ _.each({ CallExpression: { after: 1 }, Literal: { after: 1 } }, function (amounts, type) { - if (_.isNumber(amounts)) { + if (isNumber(amounts)) { amounts = { after: amounts, before: amounts }; } - _.each([type].concat(t.FLIPPED_ALIAS_KEYS[type] || []), function (type) { - _.each(amounts, function (amount, key) { + each([type].concat(t.FLIPPED_ALIAS_KEYS[type] || []), function (type) { + each(amounts, function (amount, key) { exports[key].nodes[type] = function () { return amount; }; diff --git a/lib/6to5/generation/whitespace.js b/lib/6to5/generation/whitespace.js index 04089795e0..e8f299c798 100644 --- a/lib/6to5/generation/whitespace.js +++ b/lib/6to5/generation/whitespace.js @@ -2,7 +2,7 @@ module.exports = Whitespace; -var _ = require("lodash"); +var sortBy = require("lodash/collection/sortBy"); /** * Returns `i`th number from `base`, continuing from 0 when `max` is reached. @@ -23,7 +23,7 @@ function getLookupIndex(i, base, max) { } function Whitespace(tokens, comments) { - this.tokens = _.sortBy(tokens.concat(comments), "start"); + this.tokens = sortBy(tokens.concat(comments), "start"); this.used = {}; // Profiling this code shows that while generator passes over it, indexes diff --git a/lib/6to5/index.js b/lib/6to5/index.js index e7876de5de..fb1c9c7ebd 100644 --- a/lib/6to5/index.js +++ b/lib/6to5/index.js @@ -1,9 +1,9 @@ "use strict"; -var transform = require("./transformation/transform"); -var util = require("./util"); -var fs = require("fs"); -var _ = require("lodash"); +var transform = require("./transformation/transform"); +var util = require("./util"); +var fs = require("fs"); +var isFunction = require("lodash/lang/isFunction"); exports.version = require("../../package").version; @@ -27,7 +27,7 @@ exports._util = util; exports.transform = transform; exports.transformFile = function (filename, opts, callback) { - if (_.isFunction(opts)) { + if (isFunction(opts)) { callback = opts; opts = {}; } diff --git a/lib/6to5/patch.js b/lib/6to5/patch.js index 99441c83c1..adda701345 100644 --- a/lib/6to5/patch.js +++ b/lib/6to5/patch.js @@ -1,14 +1,14 @@ "use strict"; -var t = require("./types"); -var _ = require("lodash"); +var t = require("./types"); +var extend = require("lodash/object/extend"); require("./types/node"); // estraverse var estraverse = require("estraverse"); -_.extend(estraverse.VisitorKeys, t.VISITOR_KEYS); +extend(estraverse.VisitorKeys, t.VISITOR_KEYS); // regenerator-6to5/ast-types diff --git a/lib/6to5/register.js b/lib/6to5/register.js index b36bd09cd8..e25470a112 100644 --- a/lib/6to5/register.js +++ b/lib/6to5/register.js @@ -7,7 +7,8 @@ var registerCache = require("./register-cache"); var util = require("./util"); var to5 = require("./index"); var fs = require("fs"); -var _ = require("lodash"); +var extend = require("lodash/object/extend"); +var each = require("lodash/collection/each"); sourceMapSupport.install({ retrieveSourceMap: function (source) { @@ -56,7 +57,7 @@ var loader = function (m, filename) { } } - result = result || to5.transformFileSync(filename, _.extend({ + result = result || to5.transformFileSync(filename, extend({ whitelist: whitelist, sourceMap: true, ast: false @@ -73,13 +74,13 @@ var loader = function (m, filename) { }; var hookExtensions = function (_exts) { - _.each(exts, function (old, ext) { + each(exts, function (old, ext) { require.extensions[ext] = old; }); exts = {}; - _.each(_exts, function (ext) { + each(_exts, function (ext) { exts[ext] = require.extensions[ext]; require.extensions[ext] = loader; }); @@ -103,5 +104,5 @@ module.exports = function (opts) { delete opts.cache; delete opts.only; - _.extend(transformOpts, opts); + extend(transformOpts, opts); }; diff --git a/lib/6to5/transformation/modules/_default.js b/lib/6to5/transformation/modules/_default.js index f2133a245a..f616ec3036 100644 --- a/lib/6to5/transformation/modules/_default.js +++ b/lib/6to5/transformation/modules/_default.js @@ -6,7 +6,7 @@ var traverse = require("../../traverse"); var object = require("../../helpers/object"); var util = require("../../util"); var t = require("../../types"); -var _ = require("lodash"); +var extend = require("lodash/object/extend"); function DefaultFormatter(file) { this.file = file; @@ -45,7 +45,7 @@ var exportsVisitor = { formatter.hasLocalImports = true; if (declar && t.isStatement(declar)) { - _.extend(formatter.localExports, t.getIds(declar, true)); + extend(formatter.localExports, t.getIds(declar, true)); } if (!node.default) { @@ -67,7 +67,7 @@ var importsVisitor = { enter: function (node, parent, scope, context, formatter) { if (t.isImportDeclaration(node)) { formatter.hasLocalImports = true; - _.extend(formatter.localImports, t.getIds(node, true)); + extend(formatter.localImports, t.getIds(node, true)); formatter.bumpImportOccurences(node); } } diff --git a/lib/6to5/transformation/modules/amd.js b/lib/6to5/transformation/modules/amd.js index a4d102f210..f4d7713954 100644 --- a/lib/6to5/transformation/modules/amd.js +++ b/lib/6to5/transformation/modules/amd.js @@ -6,7 +6,8 @@ var DefaultFormatter = require("./_default"); var CommonFormatter = require("./common"); var util = require("../../util"); var t = require("../../types"); -var _ = require("lodash"); +var contains = require("lodash/collection/contains"); +var values = require("lodash/object/values"); function AMDFormatter() { CommonFormatter.apply(this, arguments); @@ -39,7 +40,7 @@ AMDFormatter.prototype.transform = function (ast) { // build up define container - var params = _.values(this.ids); + var params = values(this.ids); if (this.passModuleArg) params.unshift(t.identifier("module")); params.unshift(t.identifier("exports")); @@ -79,7 +80,7 @@ AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) { var key = t.getSpecifierName(specifier); var ref = this.getExternalReference(node); - if (_.contains(this.file.dynamicImported, node)) { + if (contains(this.file.dynamicImported, node)) { // Prevent unnecessary renaming of dynamic imports. this.ids[node.source.value] = key; return; diff --git a/lib/6to5/transformation/modules/common.js b/lib/6to5/transformation/modules/common.js index 122bf71f80..8238f304bc 100644 --- a/lib/6to5/transformation/modules/common.js +++ b/lib/6to5/transformation/modules/common.js @@ -5,7 +5,7 @@ module.exports = CommonJSFormatter; var DefaultFormatter = require("./_default"); var util = require("../../util"); var t = require("../../types"); -var _ = require("lodash"); +var contains = require("lodash/collection/contains"); function CommonJSFormatter(file) { DefaultFormatter.apply(this, arguments); @@ -24,7 +24,7 @@ CommonJSFormatter.prototype.importSpecifier = function (specifier, node, nodes) // import foo from "foo"; if (t.isSpecifierDefault(specifier)) { - if (!_.contains(this.file.dynamicImported, node)) { + if (!contains(this.file.dynamicImported, node)) { ref = t.callExpression(this.file.addHelper("interop-require"), [ref]); } nodes.push(t.variableDeclaration("var", [t.variableDeclarator(variableName, ref)])); diff --git a/lib/6to5/transformation/modules/system.js b/lib/6to5/transformation/modules/system.js index dccb045cfa..feb17fe479 100644 --- a/lib/6to5/transformation/modules/system.js +++ b/lib/6to5/transformation/modules/system.js @@ -8,7 +8,9 @@ var useStrict = require("../helpers/use-strict"); var traverse = require("../../traverse"); var util = require("../../util"); var t = require("../../types"); -var _ = require("lodash"); +var last = require("lodash/array/last"); +var each = require("lodash/collection/each"); +var map = require("lodash/collection/map"); function SystemFormatter(file) { this.exportIdentifier = file.generateUidIdentifier("export"); @@ -61,14 +63,14 @@ SystemFormatter.prototype.buildExportCall = function (id, init, isStatement) { SystemFormatter.prototype.importSpecifier = function (specifier, node, nodes) { AMDFormatter.prototype.importSpecifier.apply(this, arguments); - this._addImportSource(_.last(nodes), node); + this._addImportSource(last(nodes), node); }; var runnerSettersVisitor = { enter: function (node, parent, scope, context, state) { if (node._importSource === state.source) { if (t.isVariableDeclaration(node)) { - _.each(node.declarations, function (declar) { + each(node.declarations, function (declar) { state.hoistDeclarators.push(t.variableDeclarator(declar.id)); state.nodes.push(t.expressionStatement( t.assignmentExpression("=", declar.id, declar.init) @@ -86,7 +88,7 @@ var runnerSettersVisitor = { SystemFormatter.prototype.buildRunnerSetters = function (block, hoistDeclarators) { var scope = this.file.scope; - return t.arrayExpression(_.map(this.ids, function (uid, source) { + return t.arrayExpression(map(this.ids, function (uid, source) { var state = { source: source, nodes: [], diff --git a/lib/6to5/transformation/modules/umd.js b/lib/6to5/transformation/modules/umd.js index f5c068bb64..da86b4dfb5 100644 --- a/lib/6to5/transformation/modules/umd.js +++ b/lib/6to5/transformation/modules/umd.js @@ -5,7 +5,7 @@ module.exports = UMDFormatter; var AMDFormatter = require("./amd"); var util = require("../../util"); var t = require("../../types"); -var _ = require("lodash"); +var values = require("lodash/object/values"); function UMDFormatter() { AMDFormatter.apply(this, arguments); @@ -26,7 +26,7 @@ UMDFormatter.prototype.transform = function (ast) { // factory - var ids = _.values(this.ids); + var ids = values(this.ids); var args = [t.identifier("exports")]; if (this.passModuleArg) args.push(t.identifier("module")); args = args.concat(ids); diff --git a/lib/6to5/transformation/transform.js b/lib/6to5/transformation/transform.js index 68f85d4185..e861e43721 100644 --- a/lib/6to5/transformation/transform.js +++ b/lib/6to5/transformation/transform.js @@ -6,7 +6,7 @@ var Transformer = require("./transformer"); var object = require("../helpers/object"); var File = require("../file"); var util = require("../util"); -var _ = require("lodash"); +var each = require("lodash/collection/each"); function transform(code, opts) { var file = new File(opts); @@ -64,7 +64,7 @@ transform.moduleFormatters = require("./modules"); var rawTransformers = require("./transformers"); -_.each(rawTransformers, function (transformer, key) { +each(rawTransformers, function (transformer, key) { var namespace = key.split(".")[0]; transform.namespaces[namespace] = transform.namespaces[namespace] || []; transform.namespaces[namespace].push(key); diff --git a/lib/6to5/transformation/transformer-pass.js b/lib/6to5/transformation/transformer-pass.js index dc7ed07622..48d7866ef9 100644 --- a/lib/6to5/transformation/transformer-pass.js +++ b/lib/6to5/transformation/transformer-pass.js @@ -2,7 +2,7 @@ module.exports = TransformerPass; var traverse = require("../traverse"); var util = require("../util"); -var _ = require("lodash"); +var contains = require("lodash/collection/contains"); /** * This class is responsible for traversing over the provided `File`s @@ -32,12 +32,12 @@ TransformerPass.prototype.canRun = function () { if (key[0] === "_") return true; var blacklist = opts.blacklist; - if (blacklist.length && _.contains(blacklist, key)) return false; + if (blacklist.length && contains(blacklist, key)) return false; var whitelist = opts.whitelist; - if (whitelist.length && !_.contains(whitelist, key)) return false; + if (whitelist.length && !contains(whitelist, key)) return false; - if (transformer.optional && !_.contains(opts.optional, key)) return false; + if (transformer.optional && !contains(opts.optional, key)) return false; if (transformer.experimental && !opts.experimental) return false; diff --git a/lib/6to5/transformation/transformer.js b/lib/6to5/transformation/transformer.js index a8c189a8ea..591c9a35da 100644 --- a/lib/6to5/transformation/transformer.js +++ b/lib/6to5/transformation/transformer.js @@ -4,7 +4,9 @@ module.exports = Transformer; var TransformerPass = require("./transformer-pass"); var t = require("../types"); -var _ = require("lodash"); +var isFunction = require("lodash/lang/isFunction"); +var isObject = require("lodash/lang/isObject"); +var each = require("lodash/collection/each"); /** * This is the class responsible for normalising a transformers handlers @@ -25,29 +27,29 @@ function Transformer(key, transformer, opts) { Transformer.prototype.normalise = function (transformer) { var self = this; - if (_.isFunction(transformer)) { + if (isFunction(transformer)) { transformer = { ast: transformer }; } - _.each(transformer, function (fns, type) { + each(transformer, function (fns, type) { // hidden property if (type[0] === "_") { self[type] = fns; return; } - if (_.isFunction(fns)) fns = { enter: fns }; + if (isFunction(fns)) fns = { enter: fns }; - if (!_.isObject(fns)) return; + if (!isObject(fns)) return; - if (!fns.enter) fns.enter = _.noop; - if (!fns.exit) fns.exit = _.noop; + if (!fns.enter) fns.enter = function () { }; + if (!fns.exit) fns.exit = function () { }; transformer[type] = fns; var aliases = t.FLIPPED_ALIAS_KEYS[type]; if (aliases) { - _.each(aliases, function (alias) { + each(aliases, function (alias) { transformer[alias] = fns; }); } diff --git a/lib/6to5/transformation/transformers/es6/block-scoping.js b/lib/6to5/transformation/transformers/es6/block-scoping.js index ff75035621..9f32a185cd 100644 --- a/lib/6to5/transformation/transformers/es6/block-scoping.js +++ b/lib/6to5/transformation/transformers/es6/block-scoping.js @@ -4,7 +4,8 @@ var traverse = require("../../../traverse"); var object = require("../../../helpers/object"); var util = require("../../../util"); var t = require("../../../types"); -var _ = require("lodash"); +var values = require("lodash/object/values"); +var extend = require("lodash/object/extend"); var isLet = function (node, parent) { if (!t.isVariableDeclaration(node)) return false; @@ -200,7 +201,7 @@ LetScoping.prototype.needsClosure = function () { this.hoistVarDeclarations(); // turn outsideLetReferences into an array - var params = _.values(this.outsideLetReferences); + var params = values(this.outsideLetReferences); // build the closure that we're going to wrap the block with var fn = t.functionExpression(null, params, t.blockStatement(block.body)); @@ -268,7 +269,7 @@ LetScoping.prototype.getLetReferences = function () { // for (var i = 0; i < declarators.length; i++) { declar = declarators[i]; - _.extend(this.outsideLetReferences, t.getIds(declar, true)); + extend(this.outsideLetReferences, t.getIds(declar, true)); } // @@ -285,7 +286,7 @@ LetScoping.prototype.getLetReferences = function () { for (i = 0; i < declarators.length; i++) { declar = declarators[i]; var keys = t.getIds(declar, true); - _.extend(this.letReferences, keys); + extend(this.letReferences, keys); this.hasLetReferences = true; } diff --git a/lib/6to5/transformation/transformers/es6/properties.shorthand.js b/lib/6to5/transformation/transformers/es6/properties.shorthand.js index 4c4fbeafb0..9c4230fdeb 100644 --- a/lib/6to5/transformation/transformers/es6/properties.shorthand.js +++ b/lib/6to5/transformation/transformers/es6/properties.shorthand.js @@ -2,7 +2,7 @@ var nameMethod = require("../../helpers/name-method"); var t = require("../../../types"); -var _ = require("lodash"); +var clone = require("lodash/lang/clone"); exports.Property = function (node, parent, scope, context, file) { if (node.method) { @@ -12,6 +12,6 @@ exports.Property = function (node, parent, scope, context, file) { if (node.shorthand) { node.shorthand = false; - node.key = t.removeComments(_.clone(node.key)); + node.key = t.removeComments(clone(node.key)); } }; diff --git a/lib/6to5/transformation/transformers/es6/spread.js b/lib/6to5/transformation/transformers/es6/spread.js index f0389e8d8f..c37e1905b3 100644 --- a/lib/6to5/transformation/transformers/es6/spread.js +++ b/lib/6to5/transformation/transformers/es6/spread.js @@ -1,7 +1,7 @@ "use strict"; var t = require("../../../types"); -var _ = require("lodash"); +var contains = require("lodash/collection/contains"); var getSpreadLiteral = function (spread, file) { return file.toArray(spread.argument); @@ -101,7 +101,7 @@ exports.NewExpression = function (node, parent, scope, context, file) { var args = node.arguments; if (!hasSpread(args)) return; - var nativeType = t.isIdentifier(node.callee) && _.contains(t.NATIVE_TYPE_NAMES, node.callee.name); + var nativeType = t.isIdentifier(node.callee) && contains(t.NATIVE_TYPE_NAMES, node.callee.name); var nodes = build(args, file); diff --git a/lib/6to5/transformation/transformers/es6/unicode-regex.js b/lib/6to5/transformation/transformers/es6/unicode-regex.js index 1c1cf36089..bccb76303d 100644 --- a/lib/6to5/transformation/transformers/es6/unicode-regex.js +++ b/lib/6to5/transformation/transformers/es6/unicode-regex.js @@ -1,7 +1,7 @@ "use strict"; var rewritePattern = require("regexpu/rewrite-pattern"); -var _ = require("lodash"); +var pull = require("lodash/array/pull"); exports.Literal = function (node) { var regex = node.regex; @@ -9,7 +9,7 @@ exports.Literal = function (node) { var flags = regex.flags.split(""); if (regex.flags.indexOf("u") < 0) return; - _.pull(flags, "u"); + pull(flags, "u"); regex.pattern = rewritePattern(regex.pattern, regex.flags); regex.flags = flags.join(""); diff --git a/lib/6to5/transformation/transformers/internal/block-hoist.js b/lib/6to5/transformation/transformers/internal/block-hoist.js index 711cded73b..d8936adca8 100644 --- a/lib/6to5/transformation/transformers/internal/block-hoist.js +++ b/lib/6to5/transformation/transformers/internal/block-hoist.js @@ -1,7 +1,9 @@ "use strict"; var useStrict = require("../../helpers/use-strict"); -var _ = require("lodash"); +var groupBy = require("lodash/collection/groupBy"); +var flatten = require("lodash/array/flatten"); +var values = require("lodash/object/values"); // Priority: // @@ -21,14 +23,14 @@ exports.Program = { if (!hasChange) return; useStrict.wrap(node, function () { - var nodePriorities = _.groupBy(node.body, function (bodyNode) { + var nodePriorities = groupBy(node.body, function (bodyNode) { var priority = bodyNode._blockHoist; if (priority == null) priority = 1; if (priority === true) priority = 2; return priority; }); - node.body = _.flatten(_.values(nodePriorities).reverse()); + node.body = flatten(values(nodePriorities).reverse()); }); } }; diff --git a/lib/6to5/transformation/transformers/other/self-contained.js b/lib/6to5/transformation/transformers/other/self-contained.js index 6748950ac7..9212d14c05 100644 --- a/lib/6to5/transformation/transformers/other/self-contained.js +++ b/lib/6to5/transformation/transformers/other/self-contained.js @@ -4,10 +4,11 @@ var traverse = require("../../../traverse"); var util = require("../../../util"); var core = require("core-js/library"); var t = require("../../../types"); -var _ = require("lodash"); +var has = require("lodash/object/has"); +var contains = require("lodash/collection/contains"); var coreHas = function (node) { - return node.name !== "_" && _.has(core, node.name); + return node.name !== "_" && has(core, node.name); }; var ALIASABLE_CONSTRUCTORS = [ @@ -30,11 +31,11 @@ var astVisitor = { if (!t.isReferenced(obj, node)) return; - if (!node.computed && coreHas(obj) && _.has(core[obj.name], prop.name)) { + if (!node.computed && coreHas(obj) && has(core[obj.name], prop.name)) { context.skip(); return t.prependToMemberExpression(node, file.get("coreIdentifier")); } - } else if (t.isReferencedIdentifier(node, parent) && !t.isMemberExpression(parent) && _.contains(ALIASABLE_CONSTRUCTORS, node.name) && !scope.get(node.name, true)) { + } else if (t.isReferencedIdentifier(node, parent) && !t.isMemberExpression(parent) && contains(ALIASABLE_CONSTRUCTORS, node.name) && !scope.get(node.name, true)) { // Symbol() -> _core.Symbol(); new Promise -> new _core.Promise return t.memberExpression(file.get("coreIdentifier"), node); } else if (t.isCallExpression(node)) { diff --git a/lib/6to5/transformation/transformers/spec/proto-to-assign.js b/lib/6to5/transformation/transformers/spec/proto-to-assign.js index 3e0b35f877..e63e03696c 100644 --- a/lib/6to5/transformation/transformers/spec/proto-to-assign.js +++ b/lib/6to5/transformation/transformers/spec/proto-to-assign.js @@ -1,7 +1,7 @@ "use strict"; -var t = require("../../../types"); -var _ = require("lodash"); +var t = require("../../../types"); +var pull = require("lodash/array/pull"); var isProtoKey = function (node) { return t.isLiteral(t.toComputedKey(node, node.key), { value: "__proto__" }); @@ -50,7 +50,7 @@ exports.ObjectExpression = function (node, parent, scope, context, file) { if (isProtoKey(prop)) { proto = prop.value; - _.pull(node.properties, prop); + pull(node.properties, prop); } } diff --git a/lib/6to5/traverse/index.js b/lib/6to5/traverse/index.js index d8a3e63229..2dbdc8089c 100644 --- a/lib/6to5/traverse/index.js +++ b/lib/6to5/traverse/index.js @@ -4,9 +4,11 @@ module.exports = traverse; /* jshint maxparams:7 */ -var Scope = require("./scope"); -var t = require("../types"); -var _ = require("lodash"); +var Scope = require("./scope"); +var t = require("../types"); +var contains = require("lodash/collection/contains"); +var flatten = require("lodash/array/flatten"); +var compact = require("lodash/array/compact"); function TraversalContext() { this.shouldFlatten = false; @@ -52,7 +54,7 @@ function replaceNode(obj, key, node, result) { // we're replacing a statement or block node with an array of statements so we better // ensure that it's a block - if (isArray && _.contains(t.STATEMENT_OR_BLOCK_KEYS, key) && !t.isBlockStatement(obj)) { + if (isArray && contains(t.STATEMENT_OR_BLOCK_KEYS, key) && !t.isBlockStatement(obj)) { t.ensureBlock(obj, key); } @@ -153,11 +155,11 @@ TraversalContext.prototype.visit = function (node, key, opts, scope, state) { } if (this.shouldFlatten) { - node[key] = _.flatten(node[key]); + node[key] = flatten(node[key]); if (key === "body") { // we can safely compact this - node[key] = _.compact(node[key]); + node[key] = compact(node[key]); } } }; @@ -184,8 +186,8 @@ function traverse(parent, opts, scope, state) { } if (!opts) opts = {}; - if (!opts.enter) opts.enter = _.noop; - if (!opts.exit) opts.exit = _.noop; + if (!opts.enter) opts.enter = function () { }; + if (!opts.exit) opts.exit = function () { }; // array of nodes if (Array.isArray(parent)) { @@ -244,7 +246,7 @@ function hasBlacklistedType(node, parent, scope, context, state) { traverse.hasType = function (tree, scope, type, blacklistTypes) { // the node we're searching in is blacklisted - if (_.contains(blacklistTypes, tree.type)) return false; + if (contains(blacklistTypes, tree.type)) return false; // the type we're looking for is the same as the passed node if (tree.type === type) return true; diff --git a/lib/6to5/traverse/scope.js b/lib/6to5/traverse/scope.js index 723cfb3f80..75e5f6f2fd 100644 --- a/lib/6to5/traverse/scope.js +++ b/lib/6to5/traverse/scope.js @@ -5,7 +5,10 @@ module.exports = Scope; var traverse = require("./index"); var object = require("../helpers/object"); var t = require("../types"); -var _ = require("lodash"); +var each = require("lodash/collection/each"); +var has = require("lodash/object/has"); +var contains = require("lodash/collection/contains"); +var defaults = require("lodash/object/defaults"); var FOR_KEYS = ["left", "init"]; @@ -140,7 +143,7 @@ Scope.prototype.generateTempBasedOnNode = function (node) { var functionVariableVisitor = { enter: function (node, parent, scope, context, state) { if (t.isFor(node)) { - _.each(FOR_KEYS, function (key) { + each(FOR_KEYS, function (key) { var declar = node[key]; if (t.isVar(declar)) state.add(declar); }); @@ -207,7 +210,7 @@ Scope.prototype.getInfo = function () { // ForStatement - left, init if (t.isFor(block)) { - _.each(FOR_KEYS, function (key) { + each(FOR_KEYS, function (key) { var node = block[key]; if (t.isBlockScoped(node)) add(node, false, true); }); @@ -261,7 +264,7 @@ Scope.prototype.getInfo = function () { // Function - params, rest if (t.isFunction(block)) { - _.each(block.params, function (param) { + each(block.params, function (param) { add(param); }); } @@ -331,7 +334,7 @@ Scope.prototype.getAllOfKind = function (kind) { var scope = this; do { - _.defaults(ids, scope.declarationKinds[kind]); + defaults(ids, scope.declarationKinds[kind]); scope = scope.parent; } while (scope); @@ -359,7 +362,7 @@ Scope.prototype.get = function (id, decl) { Scope.prototype.getOwn = function (id, decl) { var refs = this.references; if (decl) refs = this.declarations; - return _.has(refs, id) && refs[id]; + return has(refs, id) && refs[id]; }; /** @@ -383,7 +386,7 @@ Scope.prototype.parentGet = function (id, decl) { Scope.prototype.has = function (id, decl) { return (id && (this.hasOwn(id, decl) || this.parentHas(id, decl))) || - _.contains(Scope.defaultDeclarations, id); + contains(Scope.defaultDeclarations, id); }; /** diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index 51752c3961..c70e2e509c 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -4,7 +4,12 @@ var toFastProperties = require("../helpers/to-fast-properties"); var esutils = require("esutils"); var object = require("../helpers/object"); var Node = require("./node"); -var _ = require("lodash"); +var each = require("lodash/collection/each"); +var uniq = require("lodash/array/uniq"); +var compact = require("lodash/array/compact"); +var defaults = require("lodash/object/defaults"); +var keys = require("lodash/object/keys"); +var isString = require("lodash/lang/isString"); var t = exports; @@ -43,18 +48,18 @@ t.ALIAS_KEYS = require("./alias-keys"); t.FLIPPED_ALIAS_KEYS = {}; -_.each(t.VISITOR_KEYS, function (keys, type) { +each(t.VISITOR_KEYS, function (keys, type) { registerType(type, true); }); -_.each(t.ALIAS_KEYS, function (aliases, type) { - _.each(aliases, function (alias) { +each(t.ALIAS_KEYS, function (aliases, type) { + each(aliases, function (alias) { var types = t.FLIPPED_ALIAS_KEYS[alias] = t.FLIPPED_ALIAS_KEYS[alias] || []; types.push(type); }); }); -_.each(t.FLIPPED_ALIAS_KEYS, function (types, type) { +each(t.FLIPPED_ALIAS_KEYS, function (types, type) { t[type.toUpperCase() + "_TYPES"] = types; registerType(type, false); }); @@ -97,15 +102,15 @@ t.is = function (type, node, opts, skipAliasCheck) { // -t.BUILDER_KEYS = _.defaults(require("./builder-keys"), t.VISITOR_KEYS); +t.BUILDER_KEYS = defaults(require("./builder-keys"), t.VISITOR_KEYS); -_.each(t.BUILDER_KEYS, function (keys, type) { +each(t.BUILDER_KEYS, function (keys, type) { t[type[0].toLowerCase() + type.slice(1)] = function () { var args = arguments; var node = new Node; node.start = null; node.type = type; - _.each(keys, function (key, i) { + each(keys, function (key, i) { node[key] = args[i]; }); return node; @@ -156,13 +161,13 @@ t.isFalsyExpression = function (node) { t.toSequenceExpression = function (nodes, scope) { var exprs = []; - _.each(nodes, function (node) { + each(nodes, function (node) { if (t.isExpression(node)) { exprs.push(node); } if (t.isExpressionStatement(node)) { exprs.push(node.expression); } else if (t.isVariableDeclaration(node)) { - _.each(node.declarations, function (declar) { + each(node.declarations, function (declar) { scope.push({ kind: node.kind, key: declar.id.name, @@ -344,7 +349,7 @@ t.isReferencedIdentifier = function (node, parent) { */ t.isValidIdentifier = function (name) { - return _.isString(name) && esutils.keyword.isIdentifierName(name) && !esutils.keyword.isReservedWordES6(name, true); + return isString(name) && esutils.keyword.isIdentifierName(name) && !esutils.keyword.isReservedWordES6(name, true); }; /* @@ -540,7 +545,7 @@ t.getIds = function (node, map, ignoreTypes) { } } - if (!map) ids = _.keys(ids); + if (!map) ids = keys(ids); return ids; }; @@ -614,7 +619,7 @@ t.COMMENT_KEYS = ["leadingComments", "trailingComments"]; */ t.removeComments = function (child) { - _.each(t.COMMENT_KEYS, function (key) { + each(t.COMMENT_KEYS, function (key) { delete child[key]; }); return child; @@ -629,8 +634,8 @@ t.removeComments = function (child) { */ t.inheritsComments = function (child, parent) { - _.each(t.COMMENT_KEYS, function (key) { - child[key] = _.uniq(_.compact([].concat(child[key], parent[key]))); + each(t.COMMENT_KEYS, function (key) { + child[key] = uniq(compact([].concat(child[key], parent[key]))); }); return child; }; diff --git a/lib/6to5/util.js b/lib/6to5/util.js index fc5a30ded4..fcb560ebe6 100644 --- a/lib/6to5/util.js +++ b/lib/6to5/util.js @@ -11,7 +11,15 @@ var path = require("path"); var util = require("util"); var fs = require("fs"); var t = require("./types"); -var _ = require("lodash"); +var each = require("lodash/collection/each"); +var isNumber = require("lodash/lang/isNumber"); +var isString = require("lodash/lang/isString"); +var isRegExp = require("lodash/lang/isRegExp"); +var isEmpty = require("lodash/lang/isEmpty"); +var clone = require("lodash/lang/clone"); +var cloneDeep = require("lodash/lang/cloneDeep"); +var has = require("lodash/object/has"); +var contains = require("lodash/collection/contains"); exports.inherits = util.inherits; @@ -20,13 +28,13 @@ exports.debug = debug("6to5"); exports.canCompile = function (filename, altExts) { var exts = altExts || exports.canCompile.EXTENSIONS; var ext = path.extname(filename); - return _.contains(exts, ext); + return contains(exts, ext); }; exports.canCompile.EXTENSIONS = [".js", ".jsx", ".es6", ".es"]; exports.isInteger = function (i) { - return _.isNumber(i) && i % 1 === 0; + return isNumber(i) && i % 1 === 0; }; exports.resolve = function (loc) { @@ -48,14 +56,14 @@ exports.list = function (val) { exports.regexify = function (val) { if (!val) return new RegExp(/.^/); if (Array.isArray(val)) val = val.join("|"); - if (_.isString(val)) return new RegExp(val); - if (_.isRegExp(val)) return val; + if (isString(val)) return new RegExp(val); + if (isRegExp(val)) return val; throw new TypeError("illegal type for regexify"); }; exports.arrayify = function (val) { if (!val) return []; - if (_.isString(val)) return exports.list(val); + if (isString(val)) return exports.list(val); if (Array.isArray(val)) return val; throw new TypeError("illegal type for arrayify"); }; @@ -82,11 +90,11 @@ exports.pushMutatorMap = function (mutatorMap, key, kind, computed, method) { } else if (t.isLiteral(key)) { alias = String(key.value); } else { - alias = JSON.stringify(traverse.removeProperties(_.cloneDeep(key))); + alias = JSON.stringify(traverse.removeProperties(cloneDeep(key))); } var map; - if (_.has(mutatorMap, alias)) { + if (has(mutatorMap, alias)) { map = mutatorMap[alias]; } else { map = {}; @@ -104,7 +112,7 @@ exports.pushMutatorMap = function (mutatorMap, key, kind, computed, method) { exports.buildDefineProperties = function (mutatorMap) { var objExpr = t.objectExpression([]); - _.each(mutatorMap, function (map) { + each(mutatorMap, function (map) { var mapNode = t.objectExpression([]); var propNode = t.property("init", map._key, mapNode, map._computed); @@ -116,10 +124,10 @@ exports.buildDefineProperties = function (mutatorMap) { map.enumerable = t.literal(true); map.configurable = t.literal(true); - _.each(map, function (node, key) { + each(map, function (node, key) { if (key[0] === "_") return; - node = _.clone(node); + node = clone(node); var inheritNode = node; if (t.isMethodDefinition(node)) node = node.value; @@ -137,7 +145,7 @@ exports.buildDefineProperties = function (mutatorMap) { var templateVisitor = { enter: function (node, parent, scope, context, nodes) { - if (t.isIdentifier(node) && _.has(nodes, node.name)) { + if (t.isIdentifier(node) && has(nodes, node.name)) { return nodes[node.name]; } } @@ -152,9 +160,9 @@ exports.template = function (name, nodes, keepExpression) { nodes = null; } - template = _.cloneDeep(template); + template = cloneDeep(template); - if (!_.isEmpty(nodes)) { + if (!isEmpty(nodes)) { traverse(template, templateVisitor, null, nodes); } @@ -246,7 +254,7 @@ var loadTemplates = function () { "https://github.com/6to5/6to5/issues"); } - _.each(fs.readdirSync(templatesLoc), function (name) { + each(fs.readdirSync(templatesLoc), function (name) { if (name[0] === ".") return; var key = path.basename(name, path.extname(name));