6to5-core
Advanced tools
Comparing version 3.0.15 to 3.0.16
@@ -7,3 +7,4 @@ #!/usr/bin/env node | ||
var fs = require("fs"); | ||
var _ = require("lodash"); | ||
var each = require("lodash/collection/each"); | ||
var keys = require("lodash/object/keys"); | ||
@@ -34,3 +35,3 @@ commander.option("-t, --source-maps-inline", "Append sourceMappingURL comment to bottom of code"); | ||
_.each(_.keys(obj).sort(), function (key) { | ||
each(keys(obj).sort(), function (key) { | ||
if (key[0] === "_") return; | ||
@@ -63,3 +64,3 @@ | ||
_.each(filenames, function (filename) { | ||
each(filenames, function (filename) { | ||
if (!fs.existsSync(filename)) { | ||
@@ -66,0 +67,0 @@ errors.push(filename + " doesn't exist"); |
@@ -7,9 +7,12 @@ "use strict"; | ||
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"); | ||
@@ -91,3 +94,3 @@ function File(opts) { | ||
_.defaults(opts, { | ||
defaults(opts, { | ||
keepModuleIdExtensions: false, | ||
@@ -119,19 +122,19 @@ experimental: false, | ||
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, | ||
@@ -154,3 +157,3 @@ sourceMapName: opts.filenameRelative | ||
File.prototype.isLoose = function (key) { | ||
return _.contains(this.opts.loose, key); | ||
return contains(this.opts.loose, key); | ||
}; | ||
@@ -166,3 +169,3 @@ | ||
_.each(transform.transformers, function (transformer, key) { | ||
each(transform.transformers, function (transformer, key) { | ||
var pass = transformers[key] = transformer.buildPass(file); | ||
@@ -203,3 +206,3 @@ | ||
File.prototype.getModuleFormatter = function (type) { | ||
var ModuleFormatter = _.isFunction(type) ? type : transform.moduleFormatters[type]; | ||
var ModuleFormatter = isFunction(type) ? type : transform.moduleFormatters[type]; | ||
@@ -273,3 +276,3 @@ if (!ModuleFormatter) { | ||
File.prototype.addHelper = function (name) { | ||
if (!_.contains(File.helpers, name)) { | ||
if (!contains(File.helpers, name)) { | ||
throw new ReferenceError("unknown declaration " + name); | ||
@@ -323,2 +326,3 @@ } | ||
opts.allowImportExportEverywhere = this.isLoose("es6.modules"); | ||
//opts.strictMode = this.transformers.useStrict.canRun(); | ||
@@ -342,3 +346,3 @@ return util.parse(opts, code, function (tree) { | ||
var astRun = function (key) { | ||
_.each(self.transformerStack, function (pass) { | ||
each(self.transformerStack, function (pass) { | ||
pass.astRun(key); | ||
@@ -350,3 +354,3 @@ }); | ||
_.each(this.transformerStack, function (pass) { | ||
each(this.transformerStack, function (pass) { | ||
pass.transform(); | ||
@@ -353,0 +357,0 @@ }); |
@@ -5,4 +5,6 @@ "use strict"; | ||
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"); | ||
@@ -79,3 +81,3 @@ function Buffer(position, format) { | ||
if (_.isNumber(i)) { | ||
if (isNumber(i)) { | ||
if (this.endsWith("{\n")) i--; | ||
@@ -90,3 +92,3 @@ if (this.endsWith(util.repeat(i, "\n"))) return; | ||
if (_.isBoolean(i)) { | ||
if (isBoolean(i)) { | ||
removeLast = i; | ||
@@ -161,3 +163,3 @@ } | ||
if (Array.isArray(cha)) { | ||
return _.contains(cha, last); | ||
return contains(cha, last); | ||
} else { | ||
@@ -164,0 +166,0 @@ return cha === last; |
@@ -18,3 +18,5 @@ "use strict"; | ||
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"); | ||
@@ -35,3 +37,3 @@ function CodeGenerator(ast, opts, code) { | ||
_.each(Buffer.prototype, function (fn, key) { | ||
each(Buffer.prototype, function (fn, key) { | ||
CodeGenerator.prototype[key] = function () { | ||
@@ -47,3 +49,3 @@ return fn.apply(this.buffer, arguments); | ||
return _.merge({ | ||
return merge({ | ||
parentheses: true, | ||
@@ -75,4 +77,4 @@ comments: opts.comments == null || opts.comments, | ||
_.each(CodeGenerator.generators, function (generator) { | ||
_.extend(CodeGenerator.prototype, generator); | ||
each(CodeGenerator.generators, function (generator) { | ||
extend(CodeGenerator.prototype, generator); | ||
}); | ||
@@ -86,3 +88,3 @@ | ||
var comments = []; | ||
_.each(ast.comments, function (comment) { | ||
each(ast.comments, function (comment) { | ||
if (!comment._displayed) comments.push(comment); | ||
@@ -216,3 +218,3 @@ }); | ||
_.each(nodes, function (node, i) { | ||
each(nodes, function (node, i) { | ||
print(node, { | ||
@@ -282,3 +284,3 @@ statement: opts.statement, | ||
_.each(nodes, function (node) { | ||
each(nodes, function (node) { | ||
comments = comments.concat(self._getComments(key, node)); | ||
@@ -301,7 +303,7 @@ }); | ||
_.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) { | ||
@@ -308,0 +310,0 @@ // comment has already been output |
"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"); | ||
@@ -136,3 +136,3 @@ exports.UnaryExpression = 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; | ||
@@ -139,0 +139,0 @@ } |
"use strict"; | ||
var t = require("../../types"); | ||
var _ = require("lodash"); | ||
var t = require("../../types"); | ||
var each = require("lodash/collection/each"); | ||
@@ -50,3 +50,3 @@ exports.JSXAttribute = function (node, print) { | ||
this.indent(); | ||
_.each(node.children, function (child) { | ||
each(node.children, function (child) { | ||
if (t.isLiteral(child)) { | ||
@@ -53,0 +53,0 @@ self.push(child.value); |
"use strict"; | ||
var t = require("../../types"); | ||
var _ = require("lodash"); | ||
var t = require("../../types"); | ||
var each = require("lodash/collection/each"); | ||
@@ -69,3 +69,3 @@ exports.ImportSpecifier = function (node, print) { | ||
_.each(node.specifiers, function (spec, i) { | ||
each(node.specifiers, function (spec, i) { | ||
if (+i > 0) { | ||
@@ -72,0 +72,0 @@ self.push(", "); |
"use strict"; | ||
var _ = require("lodash"); | ||
var each = require("lodash/collection/each"); | ||
_.each(["BindMemberExpression", "BindFunctionExpression"], function (type) { | ||
each(["BindMemberExpression", "BindFunctionExpression"], function (type) { | ||
exports[type] = function () { | ||
@@ -7,0 +7,0 @@ throw new ReferenceError("Trying to render non-standard playground node " + JSON.stringify(type)); |
"use strict"; | ||
var _ = require("lodash"); | ||
var each = require("lodash/collection/each"); | ||
@@ -21,3 +21,3 @@ exports.TaggedTemplateExpression = function (node, print) { | ||
_.each(quasis, function (quasi, i) { | ||
each(quasis, function (quasi, i) { | ||
print(quasi); | ||
@@ -24,0 +24,0 @@ |
"use strict"; | ||
var _ = require("lodash"); | ||
var each = require("lodash/collection/each"); | ||
@@ -65,3 +65,3 @@ exports.Identifier = function (node) { | ||
_.each(elems, function (elem, i) { | ||
each(elems, function (elem, i) { | ||
if (!elem) { | ||
@@ -68,0 +68,0 @@ // If the array expression ends with a hole, that hole |
@@ -8,3 +8,4 @@ "use strict"; | ||
var t = require("../../types"); | ||
var _ = require("lodash"); | ||
var each = require("lodash/collection/each"); | ||
var some = require("lodash/collection/some"); | ||
@@ -48,3 +49,3 @@ var find = function (obj, node, parent) { | ||
_.each(find(whitespace[type].list, node, parent), function (expr) { | ||
each(find(whitespace[type].list, node, parent), function (expr) { | ||
lines = Node.needsWhitespace(expr, node, type); | ||
@@ -70,3 +71,3 @@ if (lines) return false; | ||
var hasCall = _.some(node, function (val) { | ||
var hasCall = some(node, function (val) { | ||
return t.isCallExpression(val); | ||
@@ -100,3 +101,3 @@ }); | ||
_.each(Node, function (fn, key) { | ||
each(Node, function (fn, key) { | ||
Node.prototype[key] = function () { | ||
@@ -103,0 +104,0 @@ // Avoid leaking arguments to prevent deoptimization |
"use strict"; | ||
var t = require("../../types"); | ||
var _ = require("lodash"); | ||
var t = require("../../types"); | ||
var each = require("lodash/collection/each"); | ||
var PRECEDENCE = {}; | ||
_.each([ | ||
each([ | ||
["||"], | ||
@@ -21,3 +21,3 @@ ["&&"], | ||
], function (tier, i) { | ||
_.each(tier, function (op) { | ||
each(tier, function (op) { | ||
PRECEDENCE[op] = i; | ||
@@ -24,0 +24,0 @@ }); |
"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"); | ||
@@ -34,2 +36,6 @@ exports.before = { | ||
nodes: { | ||
LogicalExpression: function (node) { | ||
return t.isFunction(node.left) || t.isFunction(node.right); | ||
}, | ||
AssignmentExpression: function (node) { | ||
@@ -44,3 +50,3 @@ if (t.isFunction(node.right)) { | ||
VariableDeclaration: function (node) { | ||
return _.map(node.declarations, "init"); | ||
return map(node.declarations, "init"); | ||
}, | ||
@@ -58,3 +64,3 @@ | ||
_.each({ | ||
each({ | ||
Function: 1, | ||
@@ -70,8 +76,8 @@ Class: 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 () { | ||
@@ -78,0 +84,0 @@ return amount; |
@@ -5,3 +5,3 @@ "use strict"; | ||
var _ = require("lodash"); | ||
var sortBy = require("lodash/collection/sortBy"); | ||
@@ -27,3 +27,3 @@ /** | ||
function Whitespace(tokens, comments) { | ||
this.tokens = _.sortBy(tokens.concat(comments), "start"); | ||
this.tokens = sortBy(tokens.concat(comments), "start"); | ||
this.used = {}; | ||
@@ -30,0 +30,0 @@ |
@@ -50,3 +50,3 @@ // syntax highlighting based on https://github.com/dominictarr/ansi-highlight by the fantastic Dominic Tarr | ||
lines = lines.split("\n"); | ||
lines = lines.split(/\r\n|[\n\r\u2028\u2029]/); | ||
@@ -53,0 +53,0 @@ var start = Math.max(lineNumber - 3, 0); |
"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"); | ||
@@ -30,3 +30,3 @@ exports.version = require("../../package").version; | ||
exports.transformFile = function (filename, opts, callback) { | ||
if (_.isFunction(opts)) { | ||
if (isFunction(opts)) { | ||
callback = opts; | ||
@@ -33,0 +33,0 @@ opts = {}; |
"use strict"; | ||
var t = require("./types"); | ||
var _ = require("lodash"); | ||
var t = require("./types"); | ||
var extend = require("lodash/object/extend"); | ||
@@ -11,3 +11,3 @@ require("./types/node"); | ||
var estraverse = require("estraverse"); | ||
_.extend(estraverse.VisitorKeys, t.VISITOR_KEYS); | ||
extend(estraverse.VisitorKeys, t.VISITOR_KEYS); | ||
@@ -14,0 +14,0 @@ // regenerator-6to5/ast-types |
@@ -10,3 +10,4 @@ "use strict"; | ||
var fs = require("fs"); | ||
var _ = require("lodash"); | ||
var extend = require("lodash/object/extend"); | ||
var each = require("lodash/collection/each"); | ||
@@ -60,3 +61,3 @@ sourceMapSupport.install({ | ||
result = result || to5.transformFileSync(filename, _.extend({ | ||
result = result || to5.transformFileSync(filename, extend({ | ||
whitelist: whitelist, | ||
@@ -78,3 +79,3 @@ sourceMap: true, | ||
var hookExtensions = function (_exts) { | ||
_.each(exts, function (old, ext) { | ||
each(exts, function (old, ext) { | ||
require.extensions[ext] = old; | ||
@@ -85,3 +86,3 @@ }); | ||
_.each(_exts, function (ext) { | ||
each(_exts, function (ext) { | ||
exts[ext] = require.extensions[ext]; | ||
@@ -110,3 +111,3 @@ require.extensions[ext] = loader; | ||
_.extend(transformOpts, opts); | ||
extend(transformOpts, opts); | ||
}; |
@@ -9,3 +9,3 @@ "use strict"; | ||
var t = require("../../types"); | ||
var _ = require("lodash"); | ||
var extend = require("lodash/object/extend"); | ||
@@ -49,3 +49,3 @@ function DefaultFormatter(file) { | ||
if (declar && t.isStatement(declar)) { | ||
_.extend(formatter.localExports, t.getIds(declar, true)); | ||
extend(formatter.localExports, t.getIds(declar, true)); | ||
} | ||
@@ -72,3 +72,3 @@ | ||
formatter.hasLocalImports = true; | ||
_.extend(formatter.localImports, t.getIds(node, true)); | ||
extend(formatter.localImports, t.getIds(node, true)); | ||
formatter.bumpImportOccurences(node); | ||
@@ -75,0 +75,0 @@ } |
@@ -9,3 +9,4 @@ "use strict"; | ||
var t = require("../../types"); | ||
var _ = require("lodash"); | ||
var contains = require("lodash/collection/contains"); | ||
var values = require("lodash/object/values"); | ||
@@ -43,3 +44,3 @@ function AMDFormatter() { | ||
var params = _.values(this.ids); | ||
var params = values(this.ids); | ||
if (this.passModuleArg) params.unshift(t.identifier("module")); | ||
@@ -84,6 +85,5 @@ params.unshift(t.identifier("exports")); | ||
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; | ||
this.ids[node.source.value] = ref; | ||
} else if (t.isImportBatchSpecifier(specifier)) { | ||
@@ -90,0 +90,0 @@ // import * as bar from "foo"; |
@@ -8,3 +8,3 @@ "use strict"; | ||
var t = require("../../types"); | ||
var _ = require("lodash"); | ||
var contains = require("lodash/collection/contains"); | ||
@@ -28,3 +28,3 @@ function CommonJSFormatter(file) { | ||
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]); | ||
@@ -31,0 +31,0 @@ } |
@@ -11,3 +11,5 @@ "use strict"; | ||
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"); | ||
@@ -65,3 +67,3 @@ function SystemFormatter(file) { | ||
AMDFormatter.prototype.importSpecifier.apply(this, arguments); | ||
this._addImportSource(_.last(nodes), node); | ||
this._addImportSource(last(nodes), node); | ||
}; | ||
@@ -73,3 +75,3 @@ | ||
if (t.isVariableDeclaration(node)) { | ||
_.each(node.declarations, function (declar) { | ||
each(node.declarations, function (declar) { | ||
state.hoistDeclarators.push(t.variableDeclarator(declar.id)); | ||
@@ -92,3 +94,3 @@ state.nodes.push(t.expressionStatement( | ||
return t.arrayExpression(_.map(this.ids, function (uid, source) { | ||
return t.arrayExpression(map(this.ids, function (uid, source) { | ||
var state = { | ||
@@ -95,0 +97,0 @@ source: source, |
@@ -8,3 +8,3 @@ "use strict"; | ||
var t = require("../../types"); | ||
var _ = require("lodash"); | ||
var values = require("lodash/object/values"); | ||
@@ -30,3 +30,3 @@ function UMDFormatter() { | ||
var ids = _.values(this.ids); | ||
var ids = values(this.ids); | ||
var args = [t.identifier("exports")]; | ||
@@ -33,0 +33,0 @@ if (this.passModuleArg) args.push(t.identifier("module")); |
@@ -9,3 +9,3 @@ "use strict"; | ||
var util = require("../util"); | ||
var _ = require("lodash"); | ||
var each = require("lodash/collection/each"); | ||
@@ -68,3 +68,3 @@ function transform(code, opts) { | ||
_.each(rawTransformers, function (transformer, key) { | ||
each(rawTransformers, function (transformer, key) { | ||
var namespace = key.split(".")[0]; | ||
@@ -71,0 +71,0 @@ transform.namespaces[namespace] = transform.namespaces[namespace] || []; |
@@ -5,3 +5,3 @@ module.exports = TransformerPass; | ||
var util = require("../util"); | ||
var _ = require("lodash"); | ||
var contains = require("lodash/collection/contains"); | ||
@@ -36,8 +36,8 @@ /** | ||
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; | ||
@@ -44,0 +44,0 @@ if (transformer.experimental && !opts.experimental) return false; |
@@ -7,3 +7,5 @@ "use strict"; | ||
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"); | ||
@@ -29,7 +31,7 @@ /** | ||
if (_.isFunction(transformer)) { | ||
if (isFunction(transformer)) { | ||
transformer = { ast: transformer }; | ||
} | ||
_.each(transformer, function (fns, type) { | ||
each(transformer, function (fns, type) { | ||
// hidden property | ||
@@ -41,8 +43,8 @@ if (type[0] === "_") { | ||
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 () { }; | ||
@@ -53,3 +55,3 @@ transformer[type] = fns; | ||
if (aliases) { | ||
_.each(aliases, function (alias) { | ||
each(aliases, function (alias) { | ||
transformer[alias] = fns; | ||
@@ -56,0 +58,0 @@ }); |
@@ -7,3 +7,4 @@ "use strict"; | ||
var t = require("../../../types"); | ||
var _ = require("lodash"); | ||
var values = require("lodash/object/values"); | ||
var extend = require("lodash/object/extend"); | ||
@@ -204,3 +205,3 @@ var isLet = function (node, parent) { | ||
// turn outsideLetReferences into an array | ||
var params = _.values(this.outsideLetReferences); | ||
var params = values(this.outsideLetReferences); | ||
@@ -273,3 +274,3 @@ // build the closure that we're going to wrap the block with | ||
declar = declarators[i]; | ||
_.extend(this.outsideLetReferences, t.getIds(declar, true)); | ||
extend(this.outsideLetReferences, t.getIds(declar, true)); | ||
} | ||
@@ -291,3 +292,3 @@ | ||
var keys = t.getIds(declar, true); | ||
_.extend(this.letReferences, keys); | ||
extend(this.letReferences, keys); | ||
this.hasLetReferences = true; | ||
@@ -294,0 +295,0 @@ } |
@@ -5,3 +5,3 @@ "use strict"; | ||
var t = require("../../../types"); | ||
var _ = require("lodash"); | ||
var clone = require("lodash/lang/clone"); | ||
@@ -16,4 +16,4 @@ exports.Property = function (node, parent, scope, context, file) { | ||
node.shorthand = false; | ||
node.key = t.removeComments(_.clone(node.key)); | ||
node.key = t.removeComments(clone(node.key)); | ||
} | ||
}; |
"use strict"; | ||
var t = require("../../../types"); | ||
var _ = require("lodash"); | ||
var contains = require("lodash/collection/contains"); | ||
@@ -104,3 +104,3 @@ var getSpreadLiteral = function (spread, file) { | ||
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); | ||
@@ -107,0 +107,0 @@ var nodes = build(args, file); |
"use strict"; | ||
var rewritePattern = require("regexpu/rewrite-pattern"); | ||
var _ = require("lodash"); | ||
var pull = require("lodash/array/pull"); | ||
@@ -12,3 +12,3 @@ exports.Literal = function (node) { | ||
if (regex.flags.indexOf("u") < 0) return; | ||
_.pull(flags, "u"); | ||
pull(flags, "u"); | ||
@@ -15,0 +15,0 @@ regex.pattern = rewritePattern(regex.pattern, regex.flags); |
"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"); | ||
@@ -24,3 +26,3 @@ // Priority: | ||
useStrict.wrap(node, function () { | ||
var nodePriorities = _.groupBy(node.body, function (bodyNode) { | ||
var nodePriorities = groupBy(node.body, function (bodyNode) { | ||
var priority = bodyNode._blockHoist; | ||
@@ -32,5 +34,5 @@ if (priority == null) priority = 1; | ||
node.body = _.flatten(_.values(nodePriorities).reverse()); | ||
node.body = flatten(values(nodePriorities).reverse()); | ||
}); | ||
} | ||
}; |
@@ -7,6 +7,7 @@ "use strict"; | ||
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); | ||
}; | ||
@@ -34,7 +35,7 @@ | ||
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 | ||
@@ -41,0 +42,0 @@ return t.memberExpression(file.get("coreIdentifier"), node); |
"use strict"; | ||
var t = require("../../../types"); | ||
var _ = require("lodash"); | ||
var t = require("../../../types"); | ||
var pull = require("lodash/array/pull"); | ||
@@ -53,3 +53,3 @@ var isProtoKey = function (node) { | ||
proto = prop.value; | ||
_.pull(node.properties, prop); | ||
pull(node.properties, prop); | ||
} | ||
@@ -56,0 +56,0 @@ } |
@@ -7,5 +7,7 @@ "use strict"; | ||
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"); | ||
@@ -56,3 +58,3 @@ function TraversalContext() { | ||
// 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); | ||
@@ -158,7 +160,7 @@ } | ||
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]); | ||
} | ||
@@ -190,4 +192,4 @@ } | ||
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 () { }; | ||
@@ -251,3 +253,3 @@ // array of nodes | ||
// the node we're searching in is blacklisted | ||
if (_.contains(blacklistTypes, tree.type)) return false; | ||
if (contains(blacklistTypes, tree.type)) return false; | ||
@@ -254,0 +256,0 @@ // the type we're looking for is the same as the passed node |
@@ -8,3 +8,6 @@ "use strict"; | ||
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"); | ||
@@ -144,3 +147,3 @@ var FOR_KEYS = ["left", "init"]; | ||
if (t.isFor(node)) { | ||
_.each(FOR_KEYS, function (key) { | ||
each(FOR_KEYS, function (key) { | ||
var declar = node[key]; | ||
@@ -212,3 +215,3 @@ if (t.isVar(declar)) state.add(declar); | ||
if (t.isFor(block)) { | ||
_.each(FOR_KEYS, function (key) { | ||
each(FOR_KEYS, function (key) { | ||
var node = block[key]; | ||
@@ -267,3 +270,3 @@ if (t.isBlockScoped(node)) add(node, false, true); | ||
if (t.isFunction(block)) { | ||
_.each(block.params, function (param) { | ||
each(block.params, function (param) { | ||
add(param); | ||
@@ -338,3 +341,3 @@ }); | ||
do { | ||
_.defaults(ids, scope.declarationKinds[kind]); | ||
defaults(ids, scope.declarationKinds[kind]); | ||
scope = scope.parent; | ||
@@ -367,3 +370,3 @@ } while (scope); | ||
if (decl) refs = this.declarations; | ||
return _.has(refs, id) && refs[id]; | ||
return has(refs, id) && refs[id]; | ||
}; | ||
@@ -392,3 +395,3 @@ | ||
return (id && (this.hasOwn(id, decl) || this.parentHas(id, decl))) || | ||
_.contains(Scope.defaultDeclarations, id); | ||
contains(Scope.defaultDeclarations, id); | ||
}; | ||
@@ -395,0 +398,0 @@ |
@@ -7,3 +7,8 @@ "use strict"; | ||
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"); | ||
@@ -47,8 +52,8 @@ var t = exports; | ||
_.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] || []; | ||
@@ -59,3 +64,3 @@ types.push(type); | ||
_.each(t.FLIPPED_ALIAS_KEYS, function (types, type) { | ||
each(t.FLIPPED_ALIAS_KEYS, function (types, type) { | ||
t[type.toUpperCase() + "_TYPES"] = types; | ||
@@ -103,5 +108,5 @@ registerType(type, false); | ||
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 () { | ||
@@ -112,3 +117,3 @@ var args = arguments; | ||
node.type = type; | ||
_.each(keys, function (key, i) { | ||
each(keys, function (key, i) { | ||
node[key] = args[i]; | ||
@@ -164,3 +169,3 @@ }); | ||
_.each(nodes, function (node) { | ||
each(nodes, function (node) { | ||
if (t.isExpression(node)) { | ||
@@ -171,3 +176,3 @@ exprs.push(node); | ||
} else if (t.isVariableDeclaration(node)) { | ||
_.each(node.declarations, function (declar) { | ||
each(node.declarations, function (declar) { | ||
scope.push({ | ||
@@ -354,3 +359,3 @@ kind: node.kind, | ||
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); | ||
}; | ||
@@ -551,3 +556,3 @@ | ||
if (!map) ids = _.keys(ids); | ||
if (!map) ids = keys(ids); | ||
return ids; | ||
@@ -626,3 +631,3 @@ }; | ||
t.removeComments = function (child) { | ||
_.each(t.COMMENT_KEYS, function (key) { | ||
each(t.COMMENT_KEYS, function (key) { | ||
delete child[key]; | ||
@@ -642,4 +647,4 @@ }); | ||
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]))); | ||
}); | ||
@@ -646,0 +651,0 @@ return child; |
@@ -14,3 +14,11 @@ "use strict"; | ||
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"); | ||
@@ -24,3 +32,3 @@ exports.inherits = util.inherits; | ||
var ext = path.extname(filename); | ||
return _.contains(exts, ext); | ||
return contains(exts, ext); | ||
}; | ||
@@ -31,3 +39,3 @@ | ||
exports.isInteger = function (i) { | ||
return _.isNumber(i) && i % 1 === 0; | ||
return isNumber(i) && i % 1 === 0; | ||
}; | ||
@@ -54,4 +62,4 @@ | ||
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"); | ||
@@ -62,3 +70,3 @@ }; | ||
if (!val) return []; | ||
if (_.isString(val)) return exports.list(val); | ||
if (isString(val)) return exports.list(val); | ||
if (Array.isArray(val)) return val; | ||
@@ -90,7 +98,7 @@ throw new TypeError("illegal type for arrayify"); | ||
} 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]; | ||
@@ -113,3 +121,3 @@ } else { | ||
_.each(mutatorMap, function (map) { | ||
each(mutatorMap, function (map) { | ||
var mapNode = t.objectExpression([]); | ||
@@ -126,6 +134,6 @@ | ||
_.each(map, function (node, key) { | ||
each(map, function (node, key) { | ||
if (key[0] === "_") return; | ||
node = _.clone(node); | ||
node = clone(node); | ||
var inheritNode = node; | ||
@@ -148,3 +156,3 @@ if (t.isMethodDefinition(node)) node = node.value; | ||
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]; | ||
@@ -164,5 +172,5 @@ } | ||
template = _.cloneDeep(template); | ||
template = cloneDeep(template); | ||
if (!_.isEmpty(nodes)) { | ||
if (!isEmpty(nodes)) { | ||
traverse(template, templateVisitor, null, nodes); | ||
@@ -209,3 +217,3 @@ } | ||
playground: opts.playground, | ||
strictMode: true, | ||
strictMode: opts.strictMode, | ||
onComment: comments, | ||
@@ -260,3 +268,3 @@ locations: true, | ||
_.each(fs.readdirSync(templatesLoc), function (name) { | ||
each(fs.readdirSync(templatesLoc), function (name) { | ||
if (name[0] === ".") return; | ||
@@ -263,0 +271,0 @@ |
{ | ||
"name": "6to5-core", | ||
"description": "Turn ES6 code into readable vanilla ES5 with source maps", | ||
"version": "3.0.15", | ||
"version": "3.0.16", | ||
"author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
@@ -41,3 +41,3 @@ "homepage": "https://6to5.org/", | ||
"private": "0.1.6", | ||
"regenerator-6to5": "0.8.9-6", | ||
"regenerator-6to5": "0.8.9-7", | ||
"regexpu": "1.1.0", | ||
@@ -47,4 +47,5 @@ "roadrunner": "1.0.4", | ||
"source-map-support": "0.2.9", | ||
"supports-color": "1.2.0" | ||
"supports-color": "1.2.0", | ||
"useragent": "^2.1.5" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
134
8
1333665
22
11367
+ Addeduseragent@^2.1.5
+ Addedlru-cache@4.1.5(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedregenerator-6to5@0.8.9-7(transitive)
+ Addedtmp@0.0.33(transitive)
+ Addeduseragent@2.3.0(transitive)
+ Addedyallist@2.1.2(transitive)
- Removedregenerator-6to5@0.8.9-6(transitive)
Updatedregenerator-6to5@0.8.9-7