Huge News!Announcing our $40M Series B led by Abstract Ventures.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.8 to 0.0.9

2

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

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

@@ -46,3 +46,2 @@ 'use strict';

handlePropertiesOnNonObjects = 'throw',
extraHandling,
} = options;

@@ -77,10 +76,2 @@

if (extraHandling) {
({ token, value } = extraHandling({
route,
token,
value
}));
}
//let containerValue = container.getValue();

@@ -95,9 +86,5 @@ var containerValue = container.getValue();

route,
root: out,
parent: parent.getValue(),
erroneousPath: path.slice(0, i),
erroneousKey: container.token,
erroneousValue: containerValue,
currentKey: token,
currentValue: value,
path: currentPath,
token,
value
})

@@ -104,0 +91,0 @@ }

@@ -166,12 +166,5 @@ 'use strict';

}, { handlePropertiesOnNonObjects: (bag) => {
var {
route,
parent,
erroneousKey,
erroneousValue,
currentKey,
currentValue,
} = bag;
parent[erroneousKey] = { [currentKey]: currentValue };
var { route, token, value } = bag;
var [ container, parent ] = route;
parent.getValue()[container.token] = { [token]: value };
}});

@@ -191,24 +184,18 @@

}, { handlePropertiesOnNonObjects: (bag) => {
var {
root,
parent,
erroneousPath,
erroneousKey,
erroneousValue,
currentKey,
currentValue
} = bag;
if (typeof parent !== 'object') {
var current = root;
for (var [ ix, token ] of erroneousPath.entries()) {
if (typeof current[token] !== 'object') {
current[token] = {};
var { route, path, token, value } = bag;
var [ root ] = route.slice(-1);
var [ container, parent ] = route;
if (typeof parent.getValue() !== 'object') {
var current = root.getValue();
for (var it of path.slice(0, -1)) {
if (typeof current[it] !== 'object') {
current[it] = {};
}
current = current[token];
current = current[it];
}
current[currentKey] = currentValue;
current[token] = value;
}
else {
parent[erroneousKey] = { [currentKey]: currentValue };
parent.getValue()[container.token] = { [token]: value };
}

@@ -227,23 +214,11 @@ }});

var out = unflatten({
'foo.[0]': 'a',
'foo.[1]': 'b',
'foo.[2]': 'c',
}, {
traverseArrays: true,
extraHandling: (bag) => {
var { route, token, value } = bag;
var [ container, parent ] = route
if (
!Array.isArray(container.getValue())
&& /\[\d+\]/.test(token)
) {
parent.getValue()[container.token] = []
}
return { token: token.replace(/[\[\]]/g, ''), value };
}
'foo': [],
'foo.0': 'a',
'foo.1': 'b',
'foo.2.x': 'c',
});
expect(out).to.eql({
foo: [ 'a', 'b', 'c' ]
foo: [ 'a', 'b', { x: 'c' }]
});
})
})
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