Socket
Socket
Sign inDemoInstall

flat

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flat - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

2

index.js

@@ -83,3 +83,3 @@ var flat = module.exports = {

// unflatten again for 'messy objects'
recipient[key1] = unflatten(target[key])
recipient[key1] = unflatten(target[key], opts)
})

@@ -86,0 +86,0 @@

{
"name": "flat",
"version": "1.2.0",
"version": "1.2.1",
"main": "index.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -240,2 +240,9 @@ var assert = require('assert')

test('Should create object instead of array when true', function() {
var unflattened = unflatten({
'hello.you.0': 'ipsum',
'hello.you.1': 'lorem',
'hello.other.world': 'foo'
}, {
object: true
});
assert.deepEqual({

@@ -249,20 +256,30 @@ hello: {

}
}, unflatten(
{
'hello.you.0': 'ipsum',
'hello.you.1': 'lorem',
'hello.other.world': 'foo'
}, unflattened);
assert(!Array.isArray(unflattened.hello.you));
})
test('Should create object instead of array when nested', function() {
var unflattened = unflatten({
'hello': {
'you.0': 'ipsum',
'you.1': 'lorem',
'other.world': 'foo'
}
}, {
object: true
}))
})
test('Should not create object when false', function() {
});
assert.deepEqual({
hello: {
you: ['ipsum', 'lorem'],
you: {
0: 'ipsum',
1: 'lorem',
},
other: { world: 'foo' }
}
}, unflatten(
{
}, unflattened);
assert(!Array.isArray(unflattened.hello.you));
})
test('Should not create object when false', function() {
var unflattened = unflatten({
'hello.you.0': 'ipsum',

@@ -273,3 +290,10 @@ 'hello.you.1': 'lorem',

object: false
}))
});
assert.deepEqual({
hello: {
you: ['ipsum', 'lorem'],
other: { world: 'foo' }
}
}, unflattened);
assert(Array.isArray(unflattened.hello.you));
})

@@ -276,0 +300,0 @@ })

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