clean-yaml-object
Clean up an object prior to serialization
Last updated 5 months ago by isaacs .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install clean-yaml-object 
SYNC missed versions from official npm registry.

clean-yaml-object

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

Usage

import { cleanYamlObject } from 'clean-yaml-object'
// or: 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.

Current Tags

  • 1.0.0                                ...           latest (5 months ago)

3 Versions

  • 1.0.0                                ...           5 months ago
  • 0.1.0                                ...           10 years ago
  • 0.0.1                                ...           10 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (4)
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |