Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

object-treeify

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-treeify - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

12

lib/index.js

@@ -9,3 +9,4 @@ const assert = require('assert');

keyNoNeighbour: '└─ ',
keyNeighbour: '├─ '
keyNeighbour: '├─ ',
sortFn: (a, b) => a.localeCompare(b)
}, opts);

@@ -17,7 +18,6 @@ assert(typeof ctx.joined === 'boolean');

assert(typeof ctx.keyNeighbour === 'string');
assert(typeof ctx.sortFn === 'function');
return ctx;
};
const sortFn = (a, b) => b.localeCompare(a);
module.exports = (tree, opts = {}) => {

@@ -27,3 +27,3 @@ const ctx = buildCtx(opts);

const neighbours = [];
const keys = Object.keys(tree).sort(sortFn).map(k => [k]);
const keys = Object.keys(tree).sort((a, b) => ctx.sortFn(b, a)).map(k => [k]);
const lookup = [tree];

@@ -38,3 +38,3 @@

if (node instanceof Object && !Array.isArray(node)) {
keys.push(...Object.keys(node).sort(sortFn).map(k => key.concat(k)));
keys.push(...Object.keys(node).sort((a, b) => ctx.sortFn(b, a)).map(k => key.concat(k)));
lookup[key.length] = node;

@@ -46,2 +46,2 @@ }

};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJhc3NlcnQiLCJyZXF1aXJlIiwiYnVpbGRDdHgiLCJvcHRzIiwiY3R4IiwiT2JqZWN0IiwiYXNzaWduIiwiam9pbmVkIiwic3BhY2VyTm9OZWlnaGJvdXIiLCJzcGFjZXJOZWlnaGJvdXIiLCJrZXlOb05laWdoYm91ciIsImtleU5laWdoYm91ciIsInNvcnRGbiIsImEiLCJiIiwibG9jYWxlQ29tcGFyZSIsIm1vZHVsZSIsImV4cG9ydHMi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rZXkgPSBrZXlzLnBvcCgpO1xuICAgIGNvbnN0IG5vZGUgPSBsb29rdXBba2V5Lmxlbmd0aCAtIDFdW2tleVtrZXkubGVuZ3RoIC0gMV1dO1xuXG4gICAgbmVpZ2hib3Vyc1trZXkubGVuZ3RoIC0gMV0gPSBrZXlzLmxlbmd0aCAhPT0gMCAmJiBrZXlzW2tleXMubGVuZ3RoIC0gMV0ubGVuZ3RoID09PSBrZXkubGVuZ3RoO1xuICAgIHJlc3VsdC5wdXNoKFtcbiAgICAgIG5laWdoYm91cnMuc2xpY2UoMCwga2V5Lmxlbmd0aCAtIDEpLm1hcChuID0+IChuID8gY3R4LnNwYWNlck5laWdoYm91ciA6IGN0eC5zcGFjZXJOb05laWdoYm91cikpLmpvaW4oJycpLFxuICAgICAgbmVpZ2hib3Vyc1trZXkubGVuZ3RoIC0gMV0gPyBjdHgua2V5TmVpZ2hib3VyIDogY3R4LmtleU5vTmVpZ2hib3VyLFxuICAgICAga2V5W2tleS5sZW5ndGggLSAxXSxcbiAgICAgIFsnYm9vbGVhbicsICdzdHJpbmcnLCAnbnVtYmVyJ10uaW5jbHVkZXModHlwZW9mIG5vZGUpID8gYDogJHtub2RlfWAgOiAnJ1xuICAgIF0uam9pbignJykpO1xuXG4gICAgaWYgKG5vZGUgaW5zdGFuY2VvZiBPYmplY3QgJiYgIUFycmF5LmlzQXJyYXkobm9kZSkpIHtcbiAgICAgIGtleXMucHVzaCguLi5PYmplY3Qua2V5cyhub2RlKS5zb3J0KChhLCBiKSA9PiBjdHguc29ydEZuKGIsIGEpKS5tYXAoayA9PiBrZXkuY29uY2F0KGspKSk7XG4gICAgICBsb29rdXBba2V5Lmxlbmd0aF0gPSBub2RlO1xuICAgIH1cbiAgfVxuXG4gIHJldHVybiBjdHguam9pbmVkID09PSB0cnVlID8gcmVzdWx0LmpvaW4oJ1xcbicpIDogcmVzdWx0O1xufTtcbiJdfQ==
{
"name": "object-treeify",
"version": "1.0.3",
"version": "1.1.0",
"description": "Stringify Object as tree structure",

@@ -42,12 +42,12 @@ "main": "lib/index.js",

"@babel/cli": "7.2.3",
"@babel/core": "7.3.4",
"@babel/plugin-proposal-object-rest-spread": "7.3.4",
"@babel/plugin-transform-flow-comments": "7.2.0",
"@babel/core": "7.4.0",
"@babel/plugin-proposal-object-rest-spread": "7.4.0",
"@babel/plugin-transform-flow-comments": "7.4.0",
"@babel/preset-flow": "7.0.0",
"@babel/register": "7.0.0",
"@babel/register": "7.4.0",
"babel-eslint": "10.0.1",
"chai": "4.2.0",
"coveralls": "3.0.3",
"eslint": "5.15.2",
"js-gardener": "1.38.4",
"eslint": "5.15.3",
"js-gardener": "1.38.6",
"nyc": "13.3.0",

@@ -54,0 +54,0 @@ "semantic-release": "15.13.3"

@@ -31,3 +31,3 @@ # object-treeify

the algorithm is much shorter and faster, works without recursion and is very memory efficient. Furthermore
the output is sorted alphabetically as one would expect.
the output can be sorted using a custom comparator function.

@@ -112,4 +112,11 @@ ## Install

#### sortFn
Type: `function`<br>
Default: `(a, b) => a.localeCompare(b)`
Function that defines the key sort order.
## Examples
More examples can be found in the tests.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc