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

flat

Package Overview
Dependencies
Maintainers
2
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.6.1 to 2.0.0

7

index.js

@@ -85,3 +85,8 @@ var isBuffer = require('is-buffer')

if ((overwrite && !isobject) || (!overwrite && recipient[key1] === undefined)) {
// do not write over falsey, non-undefined values if overwrite is false
if (!overwrite && !isobject && typeof recipient[key1] !== 'undefined') {
return
}
if ((overwrite && !isobject) || (!overwrite && recipient[key1] == null)) {
recipient[key1] = (

@@ -88,0 +93,0 @@ typeof key2 === 'number' &&

2

package.json
{
"name": "flat",
"version": "1.6.1",
"version": "2.0.0",
"main": "index.js",

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

@@ -266,2 +266,23 @@ var assert = require('assert')

suite('Overwrite + non-object values in key positions', function() {
test('non-object keys + overwrite should be overwritten', function() {
assert.deepEqual(flat.unflatten({ a: null, 'a.b': 'c' }, {overwrite: true}), { a: { b: 'c' } })
assert.deepEqual(flat.unflatten({ a: 0, 'a.b': 'c' }, {overwrite: true}), { a: { b: 'c' } })
assert.deepEqual(flat.unflatten({ a: 1, 'a.b': 'c' }, {overwrite: true}), { a: { b: 'c' } })
assert.deepEqual(flat.unflatten({ a: '', 'a.b': 'c' }, {overwrite: true}), { a: { b: 'c' } })
})
test('overwrite value should not affect undefined keys', function() {
assert.deepEqual(flat.unflatten({ a: undefined, 'a.b': 'c' }, {overwrite: true}), { a: { b: 'c' } })
assert.deepEqual(flat.unflatten({ a: undefined, 'a.b': 'c' }, {overwrite: false}), { a: { b: 'c' } })
})
test('if no overwrite, should ignore nested values under non-object key', function() {
assert.deepEqual(flat.unflatten({ a: null, 'a.b': 'c' }), { a: null })
assert.deepEqual(flat.unflatten({ a: 0, 'a.b': 'c' }), { a: 0 })
assert.deepEqual(flat.unflatten({ a: 1, 'a.b': 'c' }), { a: 1 })
assert.deepEqual(flat.unflatten({ a: '', 'a.b': 'c' }), { a: '' })
})
})
suite('.safe', function() {

@@ -268,0 +289,0 @@ test('Should protect arrays when true', function() {

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