Skip to content

Commit 8fc8e98

Browse files
author
Philipp Alferov
committed
Rollback to ES3 syntax
1 parent f247472 commit 8fc8e98

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

index.js

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

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

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

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

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

34-
return array.reduce((prev, item) => {
35-
let parentID = property.get(item, options.parentProperty);
34+
return array.reduce(function(prev, item) {
35+
var 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-
const grouped = groupByParents(data.slice(), options);
85+
var grouped = groupByParents(data.slice(), options);
8686
return createTree(
8787
grouped,
8888
grouped[options.rootID],

0 commit comments

Comments
 (0)