Skip to content

Commit 5a5e5b8

Browse files
author
Philipp Alferov
committed
Update dependencies, use Array.isArray instead of outdated lodash.isarray package
1 parent 834a427 commit 5a5e5b8

File tree

5 files changed

+1233
-1849
lines changed

5 files changed

+1233
-1849
lines changed

.eslintrc

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,10 @@
1-
root: true
2-
3-
env:
4-
node: true
5-
mocha: true
6-
7-
extends:
8-
"eslint:recommended"
9-
10-
rules:
11-
array-bracket-spacing: [2, "never"]
12-
block-scoped-var: 2
13-
brace-style: [2, "1tbs"]
14-
camelcase: 1
15-
curly: 2
16-
eol-last: 2
17-
eqeqeq: [2, "smart"]
18-
indent: [2, 2, { "SwitchCase": 1 }]
19-
max-depth: [1, 3]
20-
max-len: [1, 80]
21-
max-statements: [1, 15]
22-
new-cap: 1
23-
no-extend-native: 2
24-
no-mixed-spaces-and-tabs: 2
25-
no-trailing-spaces: 2
26-
no-unused-vars: 1
27-
no-use-before-define: [2, "nofunc"]
28-
object-curly-spacing: [2, "never"]
29-
quotes: [2, "single", "avoid-escape"]
30-
semi: [2, "always"]
31-
space-after-keywords: [2, "always"]
32-
space-unary-ops: 2
1+
{
2+
"extends": "eslint:recommended",
3+
"rules": {
4+
"comma-dangle": "off"
5+
},
6+
"env": {
7+
"browser": true,
8+
"node": true
9+
}
10+
}

index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict';
2-
var isArray = require('lodash.isarray');
32
var assign = require('lodash.assign');
43
var property = require('nested-property');
54
var keyBy = require('lodash.keyby');
@@ -12,7 +11,7 @@ var createTree = function(array, rootNodes, customID) {
1211
var childNode = array[node[customID]];
1312

1413
if (!node && !rootNodes.hasOwnProperty(rootNode)) {
15-
continue ;
14+
continue;
1615
}
1716

1817
if (childNode) {
@@ -63,13 +62,16 @@ var groupByParents = function(array, options) {
6362
*/
6463

6564
module.exports = function arrayToTree(data, options) {
66-
options = assign({
67-
parentProperty: 'parent_id',
68-
customID: 'id',
69-
rootID: '0'
70-
}, options);
65+
options = assign(
66+
{
67+
parentProperty: 'parent_id',
68+
customID: 'id',
69+
rootID: '0'
70+
},
71+
options
72+
);
7173

72-
if (!isArray(data)) {
74+
if (!Array.isArray(data)) {
7375
throw new TypeError('Expected an object but got an invalid argument');
7476
}
7577

0 commit comments

Comments
 (0)