Skip to content

Commit

Permalink
Replace underscore dependency in Loc class using native methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rjcorwin committed Apr 8, 2020
1 parent 6bde178 commit 53e9c5f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"redux": "^4.0.0",
"signature_pad": "^3.0.0-beta.3",
"translation-web-component": "^0.1.1",
"underscore": "^1.9.0",
"zxing-js-es6": "^0.15.3"
},
"devDependencies": {
Expand Down
11 changes: 4 additions & 7 deletions util/loc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

import 'underscore/underscore.js'

export class Loc {
/*
* @returns FlatLocationList {locations: [ LocationNodeWithParentRef, ... ], locationsLevels: [ ... ]}
Expand Down Expand Up @@ -179,7 +176,7 @@ export class Loc {
static _query (depth, targetDepth, data, levelMap, criteria) {
var allChildren, i, j, len, levelData, v;
if (depth === targetDepth) {
return _.map(data, function(obj) {
return Object.keys(data).map(key => data[key]).map(function(obj) {
return {
id: obj.id,
label: obj.label
Expand All @@ -193,12 +190,12 @@ export class Loc {
}
if ((levelMap[depth] == null) && (depth < targetDepth)) {
levelData = {};
allChildren = _.map(data, function(loc) {
allChildren = Object.keys(data).map(key => data[key]).map(function(loc) {
return loc.children;
});
for (i = j = 0, len = allChildren.length; j < len; i = ++j) {
v = allChildren[i];
_.extend(levelData, v);
Object.assign(levelData, v);
}
return Loc._query(depth + 1, targetDepth, levelData, levelMap, criteria);
}
Expand All @@ -215,7 +212,7 @@ export class Loc {
return levelMap.indexOf(level);
}
}
return levelMap.indexOf(_.last(levels));
return levelMap.indexOf(levels[levels.length-1]);
}

}

0 comments on commit 53e9c5f

Please sign in to comment.