electron-log
Advanced tools
Comparing version 4.4.3 to 4.4.4
{ | ||
"name": "electron-log", | ||
"version": "4.4.3", | ||
"version": "4.4.4", | ||
"description": "Just a very simple logging module for your Electron application", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -34,2 +34,10 @@ 'use strict'; | ||
}); | ||
it('should serialize set', function () { | ||
expect(object.serialize(null, new Set([1]))).toEqual([1]); | ||
}); | ||
it('should serialize map', function () { | ||
expect(object.serialize(null, new Map([['a', 1]]))).toEqual({ a: 1 }); | ||
}); | ||
}); | ||
@@ -54,3 +62,8 @@ | ||
}); | ||
it('should convert a set to a string representation', function () { | ||
var set = new Set([1]); | ||
expect(object.toStringFactory()([set])).toEqual('[ 1 ]'); | ||
}); | ||
}); | ||
}); |
@@ -12,3 +12,8 @@ 'use strict'; | ||
function createSerializer() { | ||
/** | ||
* @param {object} options? | ||
* @param {boolean} options.serializeMapAndSet? | ||
* @return {function} | ||
*/ | ||
function createSerializer(options) { | ||
var seen = createWeakSet(); | ||
@@ -25,3 +30,3 @@ | ||
return serialize(key, value); | ||
return serialize(key, value, options); | ||
}; | ||
@@ -97,3 +102,11 @@ } | ||
function serialize(key, value) { | ||
/** | ||
* @param {string} key | ||
* @param {any} value | ||
* @param {object} options? | ||
* @return {any} | ||
*/ | ||
function serialize(key, value, options) { | ||
var serializeMapAndSet = !options || options.serializeMapAndSet !== false; | ||
if (value instanceof Error) { | ||
@@ -115,2 +128,10 @@ return value.stack; | ||
if (serializeMapAndSet && value instanceof Map && Object.fromEntries) { | ||
return Object.fromEntries(value); | ||
} | ||
if (serializeMapAndSet && value instanceof Set && Array.from) { | ||
return Array.from(value); | ||
} | ||
return value; | ||
@@ -117,0 +138,0 @@ } |
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
102501
3090