Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Jun 2, 2016
2 parents 5a786e5 + 8c5eb59 commit acf33c1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flattree",
"version": "0.8.2",
"version": "0.9.0",
"description": "Convert hierarchical tree structure to flat structure.",
"main": "lib/index.js",
"scripts": {
Expand All @@ -25,20 +25,22 @@
"tree"
],
"devDependencies": {
"babel-cli": "^6.6.5",
"babel-core": "^6.7.4",
"babel-eslint": "^6.0.2",
"babel-plugin-transform-es3-member-expression-literals": "^6.5.0",
"babel-plugin-transform-es3-property-literals": "^6.5.0",
"babel-cli": "^6.8.0",
"babel-core": "^6.8.0",
"babel-eslint": "^6.0.4",
"babel-plugin-transform-es3-member-expression-literals": "^6.8.0",
"babel-plugin-transform-es3-property-literals": "^6.8.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-stage-0": "^6.5.0",
"coveralls": "^2.11.8",
"eslint": "^2.6.0",
"eslint-config-airbnb": "^6.2.0",
"eslint-plugin-react": "^4.2.3",
"lodash": "^4.7.0",
"tap": "^5.7.0"
"coveralls": "^2.11.9",
"eslint": "^2.9.0",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.8.0",
"eslint-plugin-jsx-a11y": "^1.2.0",
"eslint-plugin-react": "^5.1.1",
"lodash": "^4.12.0",
"tap": "^5.7.1"
},
"nyc": {
"exclude": [
Expand Down
1 change: 1 addition & 0 deletions src/extend.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint no-restricted-syntax: 0 */
const extend = (target, ...sources) => {
if (target === undefined || target === null) {
throw new TypeError('Cannot convert undefined or null to object');
Expand Down
5 changes: 2 additions & 3 deletions src/flatten.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint no-console: 0 */
import extend from './extend';
import Node from './node';

Expand Down Expand Up @@ -26,7 +27,6 @@ const flatten = (nodes = [], options = {}) => {
parentNode = new Node(parentNode);
}
const rootNode = parentNode || new Node({ // defaults
label: '',
parent: null,
children: nodes,
state: {
Expand Down Expand Up @@ -57,9 +57,8 @@ const flatten = (nodes = [], options = {}) => {
if (options.throwOnError) {
throw new Error('The node might have been corrupted: id=' + JSON.stringify(p.id) + ', state=' + JSON.stringify(p.state));
} else {
console && console.log('Error: The node might have been corrupted: id=%s, label=%s, parent=%s, children=%s, state=%s',
console && console.log('Error: The node might have been corrupted: id=%s, parent=%s, children=%s, state=%s',
JSON.stringify(p.id),
JSON.stringify(p.label),
p.parent,
p.children,
JSON.stringify(p.state),
Expand Down
1 change: 0 additions & 1 deletion src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import extend from './extend';

class Node {
id = null;
label = '';
parent = null;
children = [];
state = {};
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ test('[flatten] Corrupted parent node', (t) => {
parent.parent.state.total = 0;
const originalConsoleLogger = console.log;
console.log = (msg) => {
t.same(msg, 'Error: The node might have been corrupted: id=%s, label=%s, parent=%s, children=%s, state=%s');
t.same(msg, 'Error: The node might have been corrupted: id=%s, parent=%s, children=%s, state=%s');
};
flatten(node, { openAllNodes: true, throwOnError: false });
console.log = originalConsoleLogger;
Expand Down

0 comments on commit acf33c1

Please sign in to comment.