Skip to content

Commit 7f754a1

Browse files
author
Philipp Alferov
committed
Drop node.js 0.x support
1 parent 4504bf5 commit 7f754a1

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
"browser": true,
88
"node": true,
99
"mocha": true
10+
},
11+
"parserOptions": {
12+
"ecmaVersion": 6
1013
}
1114
}

index.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'use strict';
2-
var property = require('nested-property');
3-
var keyBy = require('lodash.keyby');
2+
const property = require('nested-property');
3+
const keyBy = require('lodash.keyby');
44

5-
var createTree = function(array, rootNodes, customID, childrenProperty) {
6-
var tree = [];
5+
const createTree = (array, rootNodes, customID, childrenProperty) => {
6+
const tree = [];
77

8-
for (var rootNode in rootNodes) {
9-
var node = rootNodes[rootNode];
10-
var childNode = array[node[customID]];
8+
for (const rootNode in rootNodes) {
9+
const node = rootNodes[rootNode];
10+
const childNode = array[node[customID]];
1111

1212
if (!node && !rootNodes.hasOwnProperty(rootNode)) {
1313
continue;
@@ -28,11 +28,11 @@ var createTree = function(array, rootNodes, customID, childrenProperty) {
2828
return tree;
2929
};
3030

31-
var groupByParents = function(array, options) {
32-
var arrayByID = keyBy(array, options.customID);
31+
const groupByParents = (array, options) => {
32+
const arrayByID = keyBy(array, options.customID);
3333

34-
return array.reduce(function(prev, item) {
35-
var parentID = property.get(item, options.parentProperty);
34+
return array.reduce((prev, item) => {
35+
let parentID = property.get(item, options.parentProperty);
3636
if (!parentID || !arrayByID.hasOwnProperty(parentID)) {
3737
parentID = options.rootID;
3838
}
@@ -82,7 +82,7 @@ module.exports = function arrayToTree(data, options) {
8282
throw new TypeError('Expected an object but got an invalid argument');
8383
}
8484

85-
var grouped = groupByParents(data.slice(), options);
85+
const grouped = groupByParents(data.slice(), options);
8686
return createTree(
8787
grouped,
8888
grouped[options.rootID],

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"email": "[email protected]"
3030
},
3131
"engines": {
32-
"node": ">=0.10.0"
32+
"node": ">=4"
3333
},
3434
"license": "MIT",
3535
"dependencies": {

0 commit comments

Comments
 (0)