# merle

> walk objects, including inherited members

Latest version **0.1.5** (published 2013-11-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install merle
pnpm add merle
yarn add merle
bun add merle
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2013-11-30 |
| First published | 2013-11-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | mike chevett |
| Maintainers | chevett |
| Keywords | object, graph, traverse |

## Links

- npm: https://www.npmjs.com/package/merle
- Repository: git@github.com:chevett/merle
- Issues: https://github.com/chevett/merle/issues
- npm.io page: https://npm.io/package/merle

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2013-11-30
- 0.1.4 — 2013-11-24
- 0.1.3 — 2013-11-23
- 0.1.2 — 2013-11-23
- 0.1.1 — 2013-11-21
- 0.1.0 — 2013-11-21
- 0.0.2 — 2013-11-20
- 0.0.1 — 2013-11-19

## README

merle [![Build Status](https://travis-ci.org/chevett/merle.png?branch=master)](https://travis-ci.org/chevett/merle?branch=master) [![Dependency Status](https://gemnasium.com/chevett/merle.png)](https://gemnasium.com/chevett/merle) 
=====
[![NPM](https://nodei.co/npm-dl/merle.png?months=1)](https://nodei.co/npm/merle/)

poor man's [traverse](https://github.com/substack/js-traverse), except merle includes inherited members.

![get it](http://media.moddb.com/cache/images/groups/1/6/5169/thumb_620x2000/Merle_Dixon_-_The_Walking_Dead_-_Guts34.jpg)


examples
-------
```js
var merle = require('merle');

merle(someObject, function(){

	console.log(this.name); 
	console.log(this.value);
	console.log(this.depth);
	console.log(this.path); // the array of property names that got us to this node.
	console.log(this.isLeaf);
	console.log(this.isRoot);
	console.log(this.isOwn);
	
	this.value = 'this replaces the current node';
	
	return false; // return an explicit false is equivalent to calling this.stop(); 

  // this.stop() will stop walking the current path, this.stop(true) will stop completely
});
```
### transform negative numbers in-place
```js
var merle = require('merle');
var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ];

merle(obj, function () {
    if (this.value < 0) this.value += 128;
});

console.dir(obj);
```

Output:
```js
[ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ]
```
### delete negative numbers in-place
```js
var merle = require('merle');
var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ];

merle(obj, function () {
    if (this.value < 0) delete this.value;
});

console.dir(obj);
```
	
Output:
```js	
[ 5, 6, [ 7, 8, 1 ], { f: 10 } ]
```	
### collect leaf nodes
```js
var m = require('merle');
var obj = {
    a : [1,2,3],
    b : 4,
    c : [5,6],
    d : { e : [7,8], f : 9 },
};

var leaves = [];
m(obj, function () {
    if (this.isLeaf) leaves.push(this.value);
});

console.dir(leaves);
```


Output:
```js	
[ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
```

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