Socket
Socket
Sign inDemoInstall

electron-log

Package Overview
Dependencies
Maintainers
1
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-log - npm Package Compare versions

Comparing version 5.1.0-beta.1 to 5.1.0-beta.2

2

package.json
{
"name": "electron-log",
"version": "5.1.0-beta.1",
"version": "5.1.0-beta.2",
"description": "Just a simple logging module for your Electron application",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -21,15 +21,20 @@ 'use strict';

it('should serialize object', () => {
expect(serialize(null, { a: 1 })).toEqual({ a: 1 });
expect(serialize('', { a: 1 })).toEqual({ a: 1 });
});
it('should serialize errors', () => {
expect(serialize(null, new Error('test'))).toMatch('Error: test\n');
expect(serialize('', new Error('test'))).toMatch('Error: test\n');
});
it('should serialize functions', () => {
expect(serialize(null, () => 1)).toEqual('[function] () => 1');
expect(serialize('', () => 1)).toEqual('[function] () => 1');
});
it('should serialize Date', () => {
expect(serialize('', new Date('2000-01-01T00:00:00.000Z')))
.toEqual('2000-01-01T00:00:00.000Z');
});
it('should serialize set', () => {
expect(serialize(null, new Set([1]))).toEqual([1]);
expect(serialize('', new Set([1]))).toEqual([1]);
});

@@ -39,3 +44,3 @@

if (Object.fromEntries) {
expect(serialize(null, new Map([['a', 1]]))).toEqual({ a: 1 });
expect(serialize('', new Map([['a', 1]]))).toEqual({ a: 1 });
}

@@ -42,0 +47,0 @@ });

@@ -124,2 +124,6 @@ 'use strict';

if (value instanceof Date) {
return value.toISOString();
}
if (serializeMapAndSet && value instanceof Map && Object.fromEntries) {

@@ -126,0 +130,0 @@ return Object.fromEntries(value);

@@ -12,10 +12,18 @@ 'use strict';

serializeFn(data, { depth = 5, seen = new WeakSet() } = {}) {
if (seen.has(data)) {
return '[Circular]';
}
if (depth < 1) {
if (isPrimitive(data)) {
return data;
}
if (Array.isArray(data)) {
return '[Array]';
}
return `[${typeof data}]`;
}
if (seen.has(data)) {
return data;
}
if (['function', 'symbol'].includes(typeof data)) {

@@ -25,4 +33,3 @@ return data.toString();

// Primitive types (including null and undefined)
if (Object(data) !== data) {
if (isPrimitive(data)) {
return data;

@@ -44,2 +51,6 @@ }

if (data instanceof Date) {
return data.toISOString();
}
if (data instanceof Error) {

@@ -105,1 +116,10 @@ return data.stack;

}
/**
* Is type primitive, including null and undefined
* @param {any} value
* @returns {boolean}
*/
function isPrimitive(value) {
return Object(value) !== value;
}
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