kwhitley / treeize

Converts row data (in JSON/associative array format) to tree structure based on column naming conventions.
MIT License
189 stars 24 forks source link

Objects with "length" property are not treated correctly #36

Closed davebaol closed 7 years ago

davebaol commented 8 years ago

This simple code

  new Treeize().grow([{"length":86}]);

throws the exception below

Unhandled rejection TypeError: attr.fullPath.split is not a function
    at Treeize.<anonymous> (<MyApp>\node_modules\treeize\lib\treeize.js:96:37)
    at <MyApp>\node_modules\treeize\node_modules\lodash\dist\lodash.js:4446:21
    at Function.forEach (<MyApp>\node_modules\treeize\node_modules\lodash\dist\lodash.js:2590:15)
    at Treeize.signature (<MyApp>\node_modules\treeize\lib\treeize.js:90:5)
    at Treeize.setSignatureAuto (<MyApp>\node_modules\treeize\lib\treeize.js:165:15)
    at Treeize.grow (<MyApp>\node_modules\treeize\lib\treeize.js:197:22)
    at <MyApp>\app.js:127:8
    at tryCatcher (<MyApp>\node_modules\bluebird\js\main\util.js:26:23)
    at Promise._settlePromiseFromHandler (<MyApp>\node_modules\bluebird\js\main\promise.js:507:31)
    at Promise._settlePromiseAt (<MyApp>\node_modules\bluebird\js\main\promise.js:581:18)
    at Promise._settlePromises (<MyApp>\node_modules\bluebird\js\main\promise.js:697:14)
    at Async._drainQueue (<MyApp>\node_modules\bluebird\js\main\async.js:123:16)
    at Async._drainQueues (<MyApp>\node_modules\bluebird\js\main\async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (<MyApp>\node_modules\bluebird\js\main\async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

I think that the issue is due to _.isArray({"length":86}) being true.

kwhitley commented 7 years ago

this should work properly now, thanks @davebaol