@firstandthird/serialize-object
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -53,2 +53,11 @@ const serializeInner = require('serialize-error'); | ||
} | ||
if (Array.isArray(originalObj)) { | ||
const serializedArray = originalObj.map(item => { | ||
const result = serialize(item, options, 1); | ||
return result; | ||
}); | ||
return serializedArray; | ||
} | ||
// serialize-object does not modify the original object: | ||
@@ -55,0 +64,0 @@ const clonedObj = Object.assign({}, originalObj); |
{ | ||
"name": "@firstandthird/serialize-object", | ||
"description": "a serialize object", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"homepage": "https://github.com/firstandthird/serialize-object", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -260,1 +260,13 @@ const tap = require('tap'); | ||
}); | ||
tap.test('return array without changing type', t => { | ||
const message = serialize({ organic: ['hapi', 'sed'] }, {}); | ||
t.same(message, { organic: ['hapi', 'sed'] }); | ||
t.end(); | ||
}); | ||
tap.test('return array of objects serialized', t => { | ||
const message = serialize({ organic: [{ one: 'one', two: 'deu', trois: { eng: 'english', fr: 'french' } }] }, { blacklist: 'two' }); | ||
t.same(message, { organic: [{ one: 'one', two: 'xxxxxx', trois: { eng: 'english', fr: 'french' } }] }); | ||
t.end(); | ||
}); |
8401
322