@highoutput/logger
Advanced tools
Comparing version 0.5.7 to 0.5.8
@@ -0,0 +0,0 @@ declare type Argument = number | string | Error | object | unknown; |
@@ -41,3 +41,3 @@ "use strict"; | ||
} | ||
return (0, serialize_1.serialize)((0, serialize_1.deserialize)(item)); | ||
return (0, serialize_1.serialize)(item); | ||
}) | ||
@@ -44,0 +44,0 @@ .map((item) => { |
@@ -1,3 +0,2 @@ | ||
export declare function deserialize(object: any): any; | ||
export declare const serialize: (data: any) => any; | ||
export declare const serialize: (object: any) => any; | ||
//# sourceMappingURL=serialize.d.ts.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serialize = exports.deserialize = void 0; | ||
const R = __importStar(require("ramda")); | ||
function deserialize(object) { | ||
const type = typeof object; | ||
if (type === 'object' && | ||
!(object instanceof Date || | ||
object instanceof Set || | ||
object instanceof Map || | ||
object instanceof Buffer)) { | ||
if (object === null) { | ||
return null; | ||
exports.serialize = void 0; | ||
const serialize = (object) => { | ||
try { | ||
const type = typeof object; | ||
if (type === 'string') { | ||
return object.replace(/\n/g, '\\n'); | ||
} | ||
if (object instanceof Array) { | ||
return object.map(deserialize); | ||
if (type === 'number') { | ||
return object.toString(); | ||
} | ||
if (object.__classObject) { | ||
if (object.type === 'Date') { | ||
return new Date(object.data); | ||
if (type === 'object') { | ||
if (object === null || object === void 0 ? void 0 : object.__classObject) { | ||
if (object.type === 'Date') { | ||
return (0, exports.serialize)(new Date(object.data)); | ||
} | ||
if (object.type === 'Set') { | ||
return (0, exports.serialize)(object.data); | ||
} | ||
if (object.type === 'Map') { | ||
return (0, exports.serialize)(object.data); | ||
} | ||
if (object.type === 'Buffer') { | ||
return (0, exports.serialize)(Buffer.from(object.data, 'base64')); | ||
} | ||
} | ||
if (object.type === 'Set') { | ||
return new Set(object.data.map(deserialize)); | ||
if ((object === null || object === void 0 ? void 0 : object._bsontype) === 'Binary') { | ||
return (0, exports.serialize)(object.buffer); | ||
} | ||
if (object.type === 'Map') { | ||
return new Map(object.data.map(deserialize)); | ||
if (object instanceof Array) { | ||
return object.reduce((arr, val) => { | ||
return arr.concat([(0, exports.serialize)(val)]); | ||
}, []); | ||
} | ||
if (object.type === 'Buffer') { | ||
return Buffer.from(object.data, 'base64'); | ||
if (object instanceof Date) { | ||
return object.toISOString(); | ||
} | ||
if (object instanceof Set) { | ||
return (0, exports.serialize)(Array.from(object)); | ||
} | ||
if (object instanceof Map) { | ||
return (0, exports.serialize)(Array.from(object)); | ||
} | ||
if (object instanceof Buffer) { | ||
return object.toString('base64'); | ||
} | ||
if (object === null) { | ||
return null; | ||
} | ||
return Object.getOwnPropertyNames(object).reduce((arr, key) => { | ||
return Object.assign(Object.assign({}, arr), { [key]: (0, exports.serialize)(object[key]) }); | ||
}, {}); | ||
} | ||
return R.map(deserialize)(object); | ||
return object; | ||
} | ||
return object; | ||
} | ||
exports.deserialize = deserialize; | ||
const serialize = (data) => { | ||
const type = typeof data; | ||
if (type === 'string') { | ||
return data.replace(/\n/g, '\\n'); | ||
catch (error) { | ||
return null; | ||
} | ||
if (type === 'number') { | ||
return data.toString(); | ||
} | ||
if (type === 'object') { | ||
if (data instanceof Array) { | ||
return data.map(exports.serialize); | ||
} | ||
if (data instanceof Date) { | ||
return data.toISOString(); | ||
} | ||
if (data instanceof Set) { | ||
return (0, exports.serialize)(Array.from(data)); | ||
} | ||
if (data instanceof Map) { | ||
return (0, exports.serialize)(Array.from(data)); | ||
} | ||
if (data instanceof Buffer) { | ||
return data.toString('base64'); | ||
} | ||
if (data === null) { | ||
return null; | ||
} | ||
return R.map(exports.serialize)(data); | ||
} | ||
return data; | ||
}; | ||
exports.serialize = serialize; | ||
//# sourceMappingURL=serialize.js.map |
{ | ||
"name": "@highoutput/logger", | ||
"version": "0.5.7", | ||
"version": "0.5.8", | ||
"main": "build/index.js", | ||
"dependencies": { | ||
"debug": "^3.1.0", | ||
"lru-cache": "^6.0.0", | ||
"ramda": "^0.28.0" | ||
"lru-cache": "^6.0.0" | ||
}, | ||
@@ -24,3 +23,2 @@ "scripts": { | ||
"@types/node": "^17.0.16", | ||
"@types/ramda": "^0.27.64", | ||
"chai": "^4.3.6", | ||
@@ -35,3 +33,3 @@ "mocha": "^7.0.0", | ||
}, | ||
"gitHead": "1b5d5435b0252b5f4f3e978a897d9ee59cc3b679" | ||
"gitHead": "7932d20959500665c51b0cda885b96ea969a0968" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
2
10
13337
145
- Removedramda@^0.28.0
- Removedramda@0.28.0(transitive)