# clean-yaml-object

> Clean up an object prior to serialization

Latest version **1.0.0** (published 2025-11-02) · 0 weekly downloads

## Install

```sh
npm install clean-yaml-object
pnpm add clean-yaml-object
yarn add clean-yaml-object
bun add clean-yaml-object
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2025-11-02 |
| First published | 2016-01-16 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 1 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | jamestalmage, isaacs, bcoe |

## Links

- npm: https://www.npmjs.com/package/clean-yaml-object
- Repository: https://github.com/tapjs/clean-yaml-object
- Homepage: https://github.com/tapjs/clean-yaml-object#readme
- Issues: https://github.com/tapjs/clean-yaml-object/issues
- npm.io page: https://npm.io/package/clean-yaml-object

## Dependencies (1)

- [@isaacs/buffer-to-string](https://npm.io/package/@isaacs/buffer-to-string.md) ^1.0.1

## Recent versions

- 1.0.0 (latest) — 2025-11-02
- 0.1.0 — 2016-01-16
- 0.0.1 — 2016-01-16

## README

# 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`](https://github.com/tapjs/node-tap)

## Usage

```ts
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.

---
_Source: https://npm.io/package/clean-yaml-object · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
