Comparing version 0.1.0 to 0.2.0
@@ -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() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10933
275