Neatly Positioned Magazines

    clean-yaml-object

    0.1.0 • Public • Published

    clean-yaml-object Build Status Coverage Status

    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

    Install

    $ npm install --save clean-yaml-object
    

    Usage

    const cleanYamlObject = require('clean-yaml-object');
     
    cleanYamlObject(new Error('foo'));
    //=> {name: 'Error', message: 'foo', stack: ...}

    API

    cleanYamlObject(input, [filterFn])

    Returns a deep copy of input that is suitable for serialization.

    input

    Type: *

    Any object.

    filterFn

    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: true only if source is the top level object passed to copyYamlObject
    • source: The source from which source[propertyName] will be copied.
    • target: The target object.

    License

    MIT © Isaac Z. Schlueter James Talmage

    Install

    npm i clean-yaml-object

    DownloadsWeekly Downloads

    335,889

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • jamestalmage
    • isaacs
    • bcoe