Comparing version 0.2.89 to 0.2.90
@@ -10,4 +10,4 @@ export const BOLD: symbol; | ||
export const UNCOLOR: symbol; | ||
export function computeNoColorLoggingArgs(args: Array<string | Symbol | Object | number>): Array<string | object | number>; | ||
export function computeNoColorLoggingArgs(args: Array<undefined | string | Symbol | Object | number | (() => any)>): Array<string | object | number>; | ||
export function createModuleLogger(_print: (...args: any[]) => void, moduleName: string): (...args: any[]) => void; | ||
//# sourceMappingURL=logging.common.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export function print(...args: Array<string | Symbol | Object | number>): void; | ||
export function print(...args: Array<string | Symbol | Object | number | undefined>): void; | ||
export function warn(...args: Array<string | Symbol | Object | number>): void; | ||
@@ -3,0 +3,0 @@ export function printError(err: Error): void; |
export function testLogging(): void; | ||
export function testModuleLogger(): void; | ||
//# sourceMappingURL=logging.test.d.ts.map |
@@ -10,4 +10,4 @@ export const BOLD: symbol; | ||
export const UNCOLOR: symbol; | ||
export function computeNoColorLoggingArgs(args: Array<string | Symbol | Object | number>): Array<string | object | number>; | ||
export function computeNoColorLoggingArgs(args: Array<undefined | string | Symbol | Object | number | (() => any)>): Array<string | object | number>; | ||
export function createModuleLogger(_print: (...args: any[]) => void, moduleName: string): (...args: any[]) => void; | ||
//# sourceMappingURL=logging.common.d.ts.map |
@@ -5,2 +5,3 @@ import * as symbol from './symbol.js' | ||
import * as func from './function.js' | ||
import * as json from './json.js' | ||
@@ -19,6 +20,9 @@ export const BOLD = symbol.create() | ||
/** | ||
* @param {Array<string|Symbol|Object|number>} args | ||
* @param {Array<undefined|string|Symbol|Object|number|function():any>} args | ||
* @return {Array<string|object|number>} | ||
*/ | ||
export const computeNoColorLoggingArgs = args => { | ||
if (args.length === 1 && args[0]?.constructor === Function) { | ||
args = /** @type {Array<string|Symbol|Object|number>} */ (/** @type {[function]} */ (args)[0]()) | ||
} | ||
const strBuilder = [] | ||
@@ -30,3 +34,5 @@ const logArgs = [] | ||
const arg = args[i] | ||
if (arg.constructor === String || arg.constructor === Number) { | ||
if (arg === undefined) { | ||
strBuilder.push('undefined') | ||
} else if (arg.constructor === String || arg.constructor === Number) { | ||
strBuilder.push(arg) | ||
@@ -62,2 +68,5 @@ } else if (arg.constructor === Object) { | ||
: (...args) => { | ||
if (args.length === 1 && args[0]?.constructor === Function) { | ||
args = args[0]() | ||
} | ||
const timeNow = time.getUnixTime() | ||
@@ -70,7 +79,16 @@ const timeDiff = timeNow - lastLoggingTime | ||
UNCOLOR, | ||
...args.map((arg) => | ||
(typeof arg === 'string' || typeof arg === 'symbol') | ||
? arg | ||
: JSON.stringify(arg) | ||
), | ||
...args.map((arg) => { | ||
if (arg != null && arg.constructor === Uint8Array) { | ||
arg = Array.from(arg) | ||
} | ||
const t = typeof arg | ||
switch (t) { | ||
case 'string': | ||
case 'symbol': | ||
return arg | ||
default: { | ||
return json.stringify(arg) | ||
} | ||
} | ||
}), | ||
color, | ||
@@ -77,0 +95,0 @@ ' +' + timeDiff + 'ms' |
@@ -35,3 +35,3 @@ /** | ||
/** | ||
* @param {Array<string|Symbol|Object|number>} args | ||
* @param {Array<string|Symbol|Object|number|function():any>} args | ||
* @return {Array<string|object|number>} | ||
@@ -41,2 +41,5 @@ */ | ||
const computeBrowserLoggingArgs = (args) => { | ||
if (args.length === 1 && args[0]?.constructor === Function) { | ||
args = /** @type {Array<string|Symbol|Object|number>} */ (/** @type {[function]} */ (args)[0]()) | ||
} | ||
const strBuilder = [] | ||
@@ -58,2 +61,5 @@ const styles = [] | ||
} else { | ||
if (arg === undefined) { | ||
break | ||
} | ||
if (arg.constructor === String || arg.constructor === Number) { | ||
@@ -201,3 +207,3 @@ const style = dom.mapToStyleString(currentStyle) | ||
for (; i < args.length; i++) { | ||
const arg = args[i] | ||
let arg = args[i] | ||
// @ts-ignore | ||
@@ -208,2 +214,5 @@ const style = _browserStyleMap[arg] | ||
} else { | ||
if (arg === undefined) { | ||
arg = 'undefined ' | ||
} | ||
if (arg.constructor === String || arg.constructor === Number) { | ||
@@ -210,0 +219,0 @@ // @ts-ignore |
@@ -1,2 +0,2 @@ | ||
export function print(...args: Array<string | Symbol | Object | number>): void; | ||
export function print(...args: Array<string | Symbol | Object | number | undefined>): void; | ||
export function warn(...args: Array<string | Symbol | Object | number>): void; | ||
@@ -3,0 +3,0 @@ export function printError(err: Error): void; |
@@ -26,6 +26,9 @@ /** | ||
/** | ||
* @param {Array<string|Symbol|Object|number>} args | ||
* @return {Array<string|object|number>} | ||
* @param {Array<string|undefined|Symbol|Object|number|function():Array<any>>} args | ||
* @return {Array<string|object|number|undefined>} | ||
*/ | ||
const computeNodeLoggingArgs = (args) => { | ||
if (args.length === 1 && args[0]?.constructor === Function) { | ||
args = /** @type {Array<string|Symbol|Object|number>} */ (/** @type {[function]} */ (args)[0]()) | ||
} | ||
const strBuilder = [] | ||
@@ -42,3 +45,5 @@ const logArgs = [] | ||
} else { | ||
if (arg.constructor === String || arg.constructor === Number) { | ||
if (arg === undefined) { | ||
break | ||
} else if (arg.constructor === String || arg.constructor === Number) { | ||
strBuilder.push(arg) | ||
@@ -73,3 +78,3 @@ } else { | ||
/** | ||
* @param {Array<string|Symbol|Object|number>} args | ||
* @param {Array<string|Symbol|Object|number|undefined>} args | ||
*/ | ||
@@ -76,0 +81,0 @@ export const print = (...args) => { |
export function testLogging(): void; | ||
export function testModuleLogger(): void; | ||
//# sourceMappingURL=logging.test.d.ts.map |
{ | ||
"name": "lib0", | ||
"version": "0.2.89", | ||
"version": "0.2.90", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
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
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
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
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
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
1796845
23470
689