dtrim
v1.13.1
Published
A tool for trimming deep/lenghty javascript structures. Some potential usages are: debugging, logging or data sanitization.
Maintainers
Readme
dtrim 
dtrim is a tool for trimming deep/lengthy javascript structures. Some potential usages are: debugging, logging or data sanitization. Fully configurable.
Caters for:
- Big arrays
- Objects with lots of keys
- Nested, deep structures
- Objects with circular references
- Long strings
- Buffers
- Functions
Installation
npm i dtrimUsage
import * as dtrim from 'dtrim'
const trim = dtrim.trimmer({ depth: 4 });
const nasty = { ... a big, deep and nasty object here ... };
const nice = trim(nasty);Options
dtrim.trimmer([options])
options:<Object>depth:<number>Trim depth - all structures deeper than this will be omitted from output. This is useful for truncating large complicated objects. To make it return full structure, passInfinityor some arbitrary large number. Default:4.size:<number>Trim size - all objects and arrays that are longer/bigger than specified size will be trimmed. Note on trimming objects: because order of properties is not guaranteed by javascript spec, objects with number of properties bigger than size will be represented as string"Object(N)". To make it return full structure, passInfinityor some arbitrary large number. Default:64.string:<number>Trim strings that are longer than specified number. To make it return full structure, passInfinityor some arbitrary large number. Default:512.buffer:<boolean>Substitutes instances of aBufferobject with their string representation:"Buffer(N)". Default:true.getters:<boolean>Whentrue, substitutes getter properties with"[Getter]"placeholder. Whenfalse, evaluates getters and includes their actual values. Default:true.functions:<boolean>Whentrue, substitutes function values with"[Function]"placeholder. Whenfalse, functions are omitted from the result entirely. Default:true.retain:<Set<string>>A set of root paths to ignore while at depth 0. For example trimming{a: FooClass}withnew Set(['a'])will result in{a: FooClass}instead of{a: {}}. Default:new Set()
Returns:
<Function>- trimmer function that accepts input argument of any type.
License
MIT
