Skip to content

Commit

Permalink
Remove unused lodash deps. Replace isEmpty with Object.keys to check …
Browse files Browse the repository at this point in the history
…if the network elements objects are empty.

refs #48
  • Loading branch information
d2fong committed Jul 15, 2020
1 parent c037505 commit 7fc5942
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 98 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"lodash.get": "^4.4.2",
"lodash.groupby": "^4.6.0",
"lodash.intersection": "^4.4.0",
"lodash.isempty": "^4.4.0",
"lodash.union": "^4.6.0",
"lodash.uniq": "^4.5.0",
"mysql2": "^2.1.0",
Expand Down Expand Up @@ -129,7 +128,6 @@
"lodash.difference": "general difference function for objects, lists, etc",
"lodash.groupby": "general groupby function",
"lodash.intersection": "general intersection function for objects, lists, etc",
"lodash.isempty": "general check for is empty, could be removed as we only use it a few times and can replace it with .length === 0",
"lodash.union": "general union function for objects, lists, etc",
"lodash.uniq": "compute uniques in an list",
"object-hash": "compute hashes for keys",
Expand Down
30 changes: 14 additions & 16 deletions src/client/js/util/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
let deepCopy = obj => JSON.parse(JSON.stringify(obj));
let deepCopy = (obj) => JSON.parse(JSON.stringify(obj));

let sum = arr => arr.reduce((a, b) => a + b, 0);
let sum = (arr) => arr.reduce((a, b) => a + b, 0);

let capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
let capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);

let max = arr => Math.max(...arr);
let max = (arr) => Math.max(...arr);

let min = arr => Math.min(...arr);
let min = (arr) => Math.min(...arr);

let flatten = arr => arr.reduce((a, b) => a.concat(b), []);
let flatten = (arr) => arr.reduce((a, b) => a.concat(b), []);

let unique = require('lodash.uniq');

Expand All @@ -18,16 +18,14 @@ let union = require('lodash.union');

let difference = require('lodash.difference');

let isEmpty = require('lodash.isempty');

let debounce = require('lodash.debounce');

let groupBy = require('lodash.groupby');

let prettyPrintArray = arr => {
let prettyPrintArray = (arr) => {
let label;

if (arr === []) { return ''; }
if (arr === []) {
return '';
}

if (arr.length === 1) {
label = arr[0];
Expand All @@ -38,14 +36,15 @@ let prettyPrintArray = arr => {
}

if (arr.length > 2) {
label = `${arr.slice(0, arr.length - 2).join(', ')} and ${arr[arr.length - 1]}`;
label = `${arr.slice(0, arr.length - 2).join(', ')} and ${
arr[arr.length - 1]
}`;
}

return label;
};

module.exports = {
isEmpty,
deepCopy,
debounce,
sum,
Expand All @@ -57,6 +56,5 @@ module.exports = {
union,
flatten,
difference,
groupBy,
prettyPrintArray
prettyPrintArray,
};
Loading

0 comments on commit 7fc5942

Please sign in to comment.