New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cdxoo/flat

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cdxoo/flat - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"name": "@cdxoo/flat",
"version": "0.0.2",
"version": "0.0.3",
"description": "does not flatten cats",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -5,3 +5,7 @@ 'use strict';

var flatten = (that, options = {}) => {
var { delimiter = '.' } = options;
var {
delimiter = '.',
maxDepth = 0,
} = options;
var out = {};

@@ -11,5 +15,12 @@

var { isLeaf, path, value } = context;
if (isLeaf) {
out[path.join(delimiter)] = value;
if (maxDepth) {
if (path.length === maxDepth) {
out[path.join(delimiter)] = value;
}
}
else {
if (isLeaf) {
out[path.join(delimiter)] = value;
}
}
}, options)

@@ -16,0 +27,0 @@

@@ -49,1 +49,26 @@ 'use strict';

})
describe('flatten() maxDepth', () => {
var pairs = [
[
3,
{ foo: { bar: { baz: { quux: 42 }}}},
{ 'foo.bar.baz': { quux: 42 }}
]
];
it('flatten', () => {
for (var it of pairs) {
var [ maxDepth, raw, flat ] = it;
expect(flatten(raw, { maxDepth })).to.deep.eql(flat);
}
});
it('unflatten', () => {
for (var it of pairs) {
var [ maxDepth, raw, flat ] = it;
expect(unflatten(flat)).to.deep.eql(raw);
}
})
})
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