# @whi/object-walk

> A method for traversing an object and optionally replacing values

Latest version **0.4.2** (published 2025-05-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install @whi/object-walk
pnpm add @whi/object-walk
yarn add @whi/object-walk
bun add @whi/object-walk
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.2 |
| Published | 2025-05-20 |
| First published | 2021-06-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Matthew Brisebois |
| Maintainers | brisebom |

## Links

- npm: https://www.npmjs.com/package/@whi/object-walk
- Repository: https://github.com/mjbrisebois/js-object-walk
- Homepage: https://github.com/mjbrisebois/js-object-walk#readme
- Issues: https://github.com/mjbrisebois/js-object-walk/issues
- npm.io page: https://npm.io/package/@whi/object-walk

## Recent versions

- 0.4.2 (latest) — 2025-05-20
- 0.4.1 — 2025-05-20
- 0.4.0 — 2025-05-20
- 0.3.0 — 2022-09-23
- 0.2.0 — 2022-09-22
- 0.1.4 — 2021-06-11
- 0.1.3 — 2021-06-10
- 0.1.2 — 2021-06-09
- 0.1.1 — 2021-06-09
- 0.1.0 — 2021-06-09

## README

[![](https://img.shields.io/npm/v/@whi/object-walk/latest?style=flat-square)](http://npmjs.com/package/@whi/object-walk)

# `Object.walk( obj, replacer )`
This module is intended to help with recursively traversing an object and optionally replacing
values.

[![](https://img.shields.io/github/issues-raw/mjbrisebois/js-object-walk?style=flat-square)](https://github.com/mjbrisebois/js-object-walk/issues)
[![](https://img.shields.io/github/issues-closed-raw/mjbrisebois/js-object-walk?style=flat-square)](https://github.com/mjbrisebois/js-object-walk/issues?q=is%3Aissue+is%3Aclosed)
[![](https://img.shields.io/github/issues-pr-raw/mjbrisebois/js-object-walk?style=flat-square)](https://github.com/mjbrisebois/js-object-walk/pulls)


## Overview


### Doesn't [`traverse`](https://www.npmjs.com/package/traverse) do this?

Traverse is a great library, but it hasn't been updated since 2013.  The internal assumptions
(specifically around the immutable/copy feature) do not support newer types such as Node's `Buffer`
class.  You may see this error message when using `traverse` with `Buffer`

```
TypeError: Method get TypedArray.prototype.length called on incompatible receiver [object Object]
```

Another reason you might use `Object.walk` instead of `traverse` is to avoid dependence on `this`
context.  I don't see anything wrong with the object oriented approach, but this library is intended
to feel like a native method.  Other native implementations with callbacks (such as
`JSON.stringify`) don't add contextual API's to `this`.


## Install

```bash
npm i @whi/object-walk
```

## Usage

```typescript
import { walk } from '@whi/object-walk';

walk( some_obj, function ( key, value ) {
    return value;
});
```

Alternatively, attach `walk` to the native `Object` as a method.

```typescript
import { bindNative } from '@whi/object-walk';
bindNative();

Object.walk( some_obj, function ( key, value ) {
    return value;
});
```

### API Reference

See [docs/API.md](docs/API.md)

### Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md)

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