Skip to content

Commit

Permalink
refactor: replace underscore w/ lodash module pkgs
Browse files Browse the repository at this point in the history
- _.extend -> lodash.assign
- _.isDate -> lodash.isdate
- _.isObject -> lodash.isobject
- _.zip -> lodash.zip
  • Loading branch information
erisu committed Jan 12, 2023
1 parent b782a72 commit cfefcd3
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 22 deletions.
57 changes: 45 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@
"fast-glob": "^3.2.2",
"fs-extra": "^9.0.0",
"glob": "^7.1.6",
"lodash.assign": "^4.2.0",
"lodash.isdate": "^4.0.1",
"lodash.isobject": "^3.0.2",
"lodash.zip": "^4.2.0",
"plist": "^3.0.1",
"q": "^1.5.1",
"read-chunk": "^3.2.0",
"strip-bom": "^4.0.0",
"underscore": "^1.9.2"
"strip-bom": "^4.0.0"
},
"devDependencies": {
"@cordova/eslint-config": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/superspawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

const crossSpawn = require('cross-spawn');
const fs = require('fs-extra');
const _ = require('underscore');
const extend = require('lodash.assign');
const Q = require('q');
const events = require('./events');
const iswin32 = process.platform === 'win32';
Expand Down Expand Up @@ -73,7 +73,7 @@ exports.spawn = (cmd, args, opts) => {
}

if (opts.env) {
spawnOpts.env = _.extend(_.extend({}, process.env), opts.env);
spawnOpts.env = extend(extend({}, process.env), opts.env);
}

if (opts.chmod && !iswin32) {
Expand Down
8 changes: 5 additions & 3 deletions src/util/plist-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
*/

// contains PLIST utility functions
const _ = require('underscore');
const isObject = require('lodash.isobject');
const isDate = require('lodash.isdate');
const extend = require('lodash.assign');
const plist = require('plist');

// adds node to doc at selector
Expand All @@ -33,8 +35,8 @@ function graftPLIST (doc, xml, selector) {
} else {
// plist uses objects for <dict>. If we have two dicts we merge them instead of
// overriding the old one. See CB-6472
const isDict = o => _.isObject(o) && !_.isDate(o); // arrays checked above
if (isDict(node) && isDict(obj)) _.extend(obj, node);
const isDict = o => isObject(o) && !isDate(o); // arrays checked above
if (isDict(node) && isDict(obj)) extend(obj, node);

doc[selector] = obj;
}
Expand Down
7 changes: 4 additions & 3 deletions src/util/xml-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

const fs = require('fs-extra');
const path = require('path');
const _ = require('underscore');
const extend = require('lodash.assign');
const zip = require('lodash.zip');
const et = require('elementtree');
const stripBom = require('strip-bom');

Expand All @@ -49,7 +50,7 @@ module.exports = {
one.len() === two.len() &&
String(one.text).trim() === String(two.text).trim() &&
attribMatch(one, two) &&
_.zip(one.getchildren(), two.getchildren())
zip(one.getchildren(), two.getchildren())
.every(([c1, c2]) => module.exports.equalNodes(c1, c2));
},

Expand Down Expand Up @@ -158,7 +159,7 @@ module.exports = {
if (!target) return false;

if (xml.oldAttrib) {
target.attrib = _.extend({}, xml.oldAttrib);
target.attrib = extend({}, xml.oldAttrib);
}

return true;
Expand Down

0 comments on commit cfefcd3

Please sign in to comment.