@@ -5,7 +5,6 @@ import { memoBuilder, MemoFunc } from './memo';
55import { convertToPlainObject } from './object' ;
66import { getFunctionName } from './stacktrace' ;
77
8- type UnknownMaybeWithToJson = unknown & { toJSON ?: ( ) => string } ;
98type Prototype = { constructor : ( ...args : unknown [ ] ) => unknown } ;
109
1110/**
@@ -27,18 +26,18 @@ type Prototype = { constructor: (...args: unknown[]) => unknown };
2726 * object in the normallized output..
2827 * @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normalization.
2928 */
30- export function normalize ( input : unknown , depth : number = + Infinity , maxProperties : number = + Infinity ) : any {
29+ export function normalize ( input : unknown , depth : number = + Infinity , maxProperties : number = + Infinity ) : unknown {
3130 try {
3231 // since we're at the outermost level, there is no key
33- return visit ( '' , input as UnknownMaybeWithToJson , depth , maxProperties ) ;
32+ return visit ( '' , input , depth , maxProperties ) ;
3433 } catch ( err ) {
3534 return { ERROR : `**non-serializable** (${ err } )` } ;
3635 }
3736}
3837
3938/** JSDoc */
4039export function normalizeToSize < T > (
41- object : { [ key : string ] : any } ,
40+ object : { [ key : string ] : unknown } ,
4241 // Default Node.js REPL depth
4342 depth : number = 3 ,
4443 // 100kB, as 200kB is max payload size, so half sounds reasonable
@@ -68,7 +67,7 @@ export function visit(
6867 depth : number = + Infinity ,
6968 maxProperties : number = + Infinity ,
7069 memo : MemoFunc = memoBuilder ( ) ,
71- ) : Primitive | unknown [ ] | { [ key : string ] : unknown } {
70+ ) : Primitive | { [ key : string ] : unknown } {
7271 const [ memoize , unmemoize ] = memo ;
7372
7473 // if the value has a `toJSON` method, bail and let it do the work
@@ -230,6 +229,6 @@ function utf8Length(value: string): number {
230229}
231230
232231/** Calculates bytes size of input object */
233- function jsonSize ( value : any ) : number {
232+ function jsonSize ( value : unknown ) : number {
234233 return utf8Length ( JSON . stringify ( value ) ) ;
235234}
0 commit comments