UNPKG

logpipes

Version:

Console.log transformation pipes

76 lines (75 loc) 2.84 kB
/** Options for 'simplifyJson()' function. */ export interface JsonSimplifierOptions { /** * Maximum depth level in JSON before overriding the leaf value with a @depthLimitValue. * Default: 10. */ maxDepthLimit: number; /** * All arrays with a number of elements greater the limit are serialized as a @arrayLengthLimitValue. * Default: 100. */ maxArrayLength: number; /** * All objects with a number of properties greater the limit are serialized as a @objectPropertyCountLimitValue. * Default: 100. */ maxObjectPropertyCount: number; /** * Excludes the property from the result. * Default: no properties are excluded. */ isIgnoredProperty: (propertyName: string) => boolean; /** * Replaces property value with another value. * Can be used for value masking. * Default: no properties are replaced. */ replacePropertyValue: (propertyName: string, propertyValue: unknown) => unknown; /** * A value used to stop recursion when @maxDepthLimit is reached. * Default: '[Depth limit ~]'. */ depthLimitValue: string; /** * A value used to replace arrays with a number of elements > @maxArrayLength * Default: '[Array, length: $length ~]'. */ arrayLengthLimitValue: string; /** * A value used to replace objects with a number of properties > @maxObjectPropertyCount. * Default: '[Object, properties: $count ~]'. */ objectPropertyCountLimitValue: string; /** * A value used to replace a circular reference. * Default: '[Circular ~]'. */ circularReferenceValue: string; /** * A value used to replace functions. * Default: '[Function ~]'. **/ functionValue: string; /** * A value used to replace symbol values. * Default: '[Symbol ~]'. **/ symbolValue: string; } /** Returns default properties used by 'simplifyJson' function. */ export declare function getDefaultJsonSimplifierOptions(): JsonSimplifierOptions; /** A type with no 'symbol' & 'function': primitives + object. */ type SimplifiedType = object | null | string | undefined | number | boolean | bigint; /** * Converts given value to a 'simplified' JSON object. * A 'simplified' object is an object that can be restored into the original form using JSON.parse(JSON.stringify(obj)). */ export declare function simplifyJson(value: unknown, inputOptions?: Partial<JsonSimplifierOptions>, recursionLevel?: number, visitedObjects?: Set<object>): SimplifiedType; interface SimplifyValueOptions { functionValue: string; symbolValue: string; } /** Simplifies a single property value with no recursion. */ export declare function simplifyValue(value: unknown, options?: Partial<SimplifyValueOptions>): SimplifiedType; export {};