Skip to content

Commit

Permalink
Reduce lodash usage.
Browse files Browse the repository at this point in the history
Use `lodash.assign` directly; this is needed for node.js < 4, otherwise we can completely get rid of lodash.
  • Loading branch information
XhmikosR committed Jul 19, 2016
1 parent c3dae35 commit 7b27d05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -17,7 +17,7 @@
},
"dependencies": {
"chalk": "^1.0.0",
"lodash": "^4.0.1",
"lodash.assign": "^4.0.9",
"maxmin": "^1.1.0",
"uglify-js": "~2.6.2",
"uri-path": "^1.0.0"
Expand Down
20 changes: 10 additions & 10 deletions tasks/lib/uglify.js
Expand Up @@ -11,7 +11,7 @@
// External libs.
var path = require('path');
var UglifyJS = require('uglify-js');
var _ = require('lodash');
var assign = require('lodash.assign');
var uriPath = require('uri-path');
var getOutputOptions;

Expand Down Expand Up @@ -66,8 +66,8 @@ exports.init = function(grunt) {

// Wrap code in closure with configurable arguments/parameters list.
if (options.enclose) {
var argParamList = _.map(options.enclose, function(val, key) {
return key + ':' + val;
var argParamList = Object.keys(options.enclose).map(function(key) {
return key + ':' + options.enclose[key];
});

topLevel = topLevel.wrap_enclose(argParamList);
Expand Down Expand Up @@ -247,29 +247,29 @@ exports.init = function(grunt) {
}
}

if (!_.isUndefined(options.indentLevel)) {
if (typeof options.indentLevel !== 'undefined') {
outputOptions.indent_level = options.indentLevel;
}

if (!_.isUndefined(options.maxLineLen)) {
if (typeof options.maxLineLen !== 'undefined') {
outputOptions.max_line_len = options.maxLineLen;
}

if (!_.isUndefined(options.ASCIIOnly)) {
if (typeof options.ASCIIOnly !== 'undefined') {
outputOptions.ascii_only = options.ASCIIOnly;
}

if (!_.isUndefined(options.quoteStyle)) {
if (typeof options.quoteStyle !== 'undefined') {
outputOptions.quote_style = options.quoteStyle;
}

if (!_.isUndefined(options.preserveComments)) {
if (typeof options.preserveComments !== 'undefined') {
outputOptions.comments = options.preserveComments;
}

if (options.beautify) {
if (_.isObject(options.beautify)) {
_.assign(outputOptions, options.beautify);
if (typeof options.beautify === 'object') {
assign(outputOptions, options.beautify);
} else {
outputOptions.beautify = true;
}
Expand Down

0 comments on commit 7b27d05

Please sign in to comment.