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

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 0.1.0 to 0.2.0

3

index.js

@@ -15,3 +15,4 @@ var flat = module.exports = {}

var isarray = opts.safe && Array.isArray(object[key])
, isobject = typeof object[key] === 'object'
, type = Object.prototype.toString.call(object[key])
, isobject = (type === "[object Object]" || type === "[object Array]")

@@ -18,0 +19,0 @@ if (!isarray && isobject) {

{
"name": "flat",
"version": "0.1.0",
"version": "0.2.0",
"main": "index.js",

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

@@ -6,2 +6,48 @@ var assert = require('assert')

suite('Flatten Primitives', function(){
test('String', function(){
assert.deepEqual(flatten({hello:{world: "good morning"}}),{'hello.world':'good morning'})
})
test('Number', function(){
assert.deepEqual(flatten({hello:{world: 1234.99}}),{'hello.world': 1234.99})
})
test('Boolean', function(){
assert.deepEqual(flatten({hello:{world: true}}),{'hello.world': true})
assert.deepEqual(flatten({hello:{world: false}}),{'hello.world': false})
})
test('Date', function(){
var d = new Date()
assert.deepEqual(flatten({hello:{world: d}}),{'hello.world': d})
})
test('Null', function(){
assert.deepEqual(flatten({hello:{world: null}}),{'hello.world': null})
})
test('Undefined', function(){
assert.deepEqual(flatten({hello:{world: undefined}}),{'hello.world': undefined})
})
})
suite('Unflatten Primitives', function(){
test('String', function(){
assert.deepEqual(unflatten({'hello.world':'good morning'}),{hello:{world: "good morning"}})
})
test('Number', function(){
assert.deepEqual(unflatten({'hello.world': 1234.99}),{hello:{world: 1234.99}})
})
test('Boolean', function(){
assert.deepEqual(unflatten({'hello.world': true}),{hello:{world: true}})
assert.deepEqual(unflatten({'hello.world': false}),{hello:{world: false}})
})
test('Date', function(){
var d = new Date()
assert.deepEqual(unflatten({'hello.world': d}),{hello:{world: d}})
})
test('Null', function(){
assert.deepEqual(unflatten({'hello.world': null}),{hello:{world: null}})
})
test('Undefined', function(){
assert.deepEqual(unflatten({'hello.world': undefined}),{hello:{world: undefined}})
})
})
suite('Flatten', function() {

@@ -8,0 +54,0 @@ test('Nested once', 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