@@ -5,7 +5,6 @@ import { memoBuilder, MemoFunc } from './memo';
5
5
import { convertToPlainObject } from './object' ;
6
6
import { getFunctionName } from './stacktrace' ;
7
7
8
- type UnknownMaybeWithToJson = unknown & { toJSON ?: ( ) => string } ;
9
8
type Prototype = { constructor : ( ...args : unknown [ ] ) => unknown } ;
10
9
11
10
/**
@@ -27,18 +26,18 @@ type Prototype = { constructor: (...args: unknown[]) => unknown };
27
26
* object in the normallized output..
28
27
* @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normalization.
29
28
*/
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 {
31
30
try {
32
31
// 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 ) ;
34
33
} catch ( err ) {
35
34
return { ERROR : `**non-serializable** (${ err } )` } ;
36
35
}
37
36
}
38
37
39
38
/** JSDoc */
40
39
export function normalizeToSize < T > (
41
- object : { [ key : string ] : any } ,
40
+ object : { [ key : string ] : unknown } ,
42
41
// Default Node.js REPL depth
43
42
depth : number = 3 ,
44
43
// 100kB, as 200kB is max payload size, so half sounds reasonable
@@ -68,7 +67,7 @@ export function visit(
68
67
depth : number = + Infinity ,
69
68
maxProperties : number = + Infinity ,
70
69
memo : MemoFunc = memoBuilder ( ) ,
71
- ) : Primitive | unknown [ ] | { [ key : string ] : unknown } {
70
+ ) : Primitive | { [ key : string ] : unknown } {
72
71
const [ memoize , unmemoize ] = memo ;
73
72
74
73
// if the value has a `toJSON` method, bail and let it do the work
@@ -230,6 +229,6 @@ function utf8Length(value: string): number {
230
229
}
231
230
232
231
/** Calculates bytes size of input object */
233
- function jsonSize ( value : any ) : number {
232
+ function jsonSize ( value : unknown ) : number {
234
233
return utf8Length ( JSON . stringify ( value ) ) ;
235
234
}
0 commit comments