# libnested

> basic functions (map, each, get, set, keys) for nested objects.

Latest version **1.5.2** (published 2022-03-07) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.2 |
| Published | 2022-03-07 |
| First published | 2016-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | 'Dominic Tarr' |
| Maintainers | dominictarr, ahdinosaur |

## Links

- npm: https://www.npmjs.com/package/libnested
- Repository: https://github.com/dominictarr/libnested
- Issues: https://github.com/dominictarr/libnested/issues
- npm.io page: https://npm.io/package/libnested

## Recent versions

- 1.5.2 (latest) — 2022-03-07
- 1.5.1 — 2021-11-24
- 1.5.0 — 2020-01-07
- 1.4.1 — 2018-11-26
- 1.4.0 — 2018-11-11
- 1.3.2 — 2018-04-11
- 1.3.1 — 2018-04-10
- 1.2.3 — 2018-04-10
- 1.2.1 — 2017-02-11
- 1.1.0 — 2016-11-22
- 1.0.0 — 2016-11-22
- 0.0.0 — 2016-11-22

## README

# libnested

basic functions (map, each, get, set, keys) for nested objects.

## api

### each (object, iter(value, path), includeArrays?) => boolean

iterate over an object (depth first) and call `iter` with each value.
`path` is an array with one or more items, which is the path to value.
`value` will be any item which is not a `{}` object. Arrays are treated as values.

if `iter` returns false then each will stop traversing the object and return false also.

if `includeArrays` is true (defaults to false) then arrays
encounted will be treated like objects. If `includeArrays`
is not true, arrays will be treated like `values`.

### map (object, iter(value, path) => nextValue, output, includeArrays?) => output

map over a nested object (depth first). A new object is returned (unless `output` is given), containing values returned by `iter`.

if `includeArrays` is true, the contents of arrays will be mapped,
otherwise only the arrays themselves will be.

### paths (object) => [path...]

return an array of paths into an object.

### get(object, path, default) => value

get the `value` at `path` within object.
if `path` does not exist in the `object`, return `default`.

`path` may be an array of strings or numbers, or a single string or number.

### set(object, path, value)

set `value` at location `path` within `object`.
If path is deeper than object goes, intermediate `{}`'s are added.

`path` may be an array of strings or numbers, or a single string or number.

`object` will be mutated.

### clone (object)

return a new object with the same structure and primitive values as `object`

cyclic objects are not supported - will produce a `RangeError` (stackoverflow)

## License

MIT

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