Clean up an object prior to serialization.
Replaces circular references, pretty prints Buffers, and numerous other enhancements. Primarily designed to prepare Errors for serialization to JSON/YAML.
Extracted from node-tap
import { cleanYamlObject } from 'clean-yaml-object'
// or: const { cleanYamlObject } = require('clean-yaml-object')
cleanYamlObject(new Error('foo'))
//=> {name: 'Error', message: 'foo', stack: ...}Returns a deep copy of input that is suitable for
serialization.
Type: *
Any object.
Type: callback(propertyName, isRoot, source, target)
Optional filter callback. Returning true will cause the
property to be copied. Otherwise it will be skipped
propertyName: The property being copied.isRoot:trueonly ifsourceis the top level object passed tocopyYamlObjectsource: The source from whichsource[propertyName]will be copied.target: The target object.