# @nextgis/tree

> Filtering objects by its properties using expressions

Latest version **4.1.1** (published 2026-11-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nextgis/tree
pnpm add @nextgis/tree
yarn add @nextgis/tree
bun add @nextgis/tree
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.1.1 |
| Published | 2026-11-13 |
| First published | 2020-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 144.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | NextGIS |
| Maintainers | rendrom, maximdubinin, karavanjo |
| Keywords | NextGIS, MAP |

## Links

- npm: https://www.npmjs.com/package/@nextgis/tree
- Repository: https://github.com/nextgis/nextgis_frontend
- Homepage: https://github.com/nextgis/nextgis_frontend/tree/master/packages/tree#readme
- Issues: https://github.com/nextgis/nextgis_frontend/issues
- npm.io page: https://npm.io/package/@nextgis/tree

## Dependencies (2)

- [@nextgis/utils](https://npm.io/package/@nextgis/utils.md) 4.1.1
- [@nextgis/properties-filter](https://npm.io/package/@nextgis/properties-filter.md) 4.1.1

## Recent versions

- 4.1.1 (latest) — 2026-11-13
- 4.0.2 — 2026-11-05
- 4.0.1 — 2026-11-02
- 4.0.0 — 2026-08-30
- 4.0.0-rc.2 — 2026-08-30
- 4.0.0-rc.1 — 2026-08-29
- 4.0.0-rc.0 — 2026-08-27
- 4.0.0-alpha.8 — 2026-08-25
- 4.0.0-alpha.6 — 2026-08-24
- 4.0.0-alpha.5 — 2026-08-21
- 4.0.0-alpha.2 — 2026-05-28
- 3.0.0 — 2025-07-26
- 3.0.0-alpha.22 — 2025-05-14
- 3.0.0-alpha.17 — 2024-12-24
- 3.0.0-alpha.13 — 2024-10-24
- … 61 more at https://npm.io/package/@nextgis/tree/versions

## README

# Tree

![version](https://img.shields.io/npm/v/@nextgis/tree)

Utilities to simplify interaction with tree data structures

## Installation

```bash
# latest stable
npm install @nextgis/tree
```

General form for each tree function

treeFunc(item | item[], actionFunc, relationFunc | childrenParamName)

## Usage

```javascript
import { treeFilter, treeFind, treeSome, treeEvery } from '@nextgis/tree';

const tree = [
  {
    name: 'A',
    children: [{ name: 'A-a' }, { name: 'A-b', children: [{ name: 'A-b-1' }] }],
  },
  {
    name: 'B',
    children: [{ name: 'B-a' }, { name: 'B-b' }],
  },
];

// 'children' - is default relation name, this param may be ignored in this case
treeFilter(tree, (item): item.name !== 'A', 'children').map((item) => item.name); // ['B', 'B-a', 'B-b']

treeFind(tree, (item)=> item.name === 'A-b-1', (item) => item.children); // {name: 'A-b-2'}
treeFind(tree, (item)=> item.name === 'A-b-2'); // undefined

treeSome(tree, someFunction, relationFunction | childrenParamName): boolean;

treeEvery(tree, everyFunction, relationFunction | childrenParamName): boolean;
```

## Commercial support

Need to fix a bug or add a feature to `@nextgis/tree`? We provide custom development and support for this software. [Contact us](http://nextgis.com/contact/) to discuss options!

[![http://nextgis.com](https://nextgis.com/img/nextgis.png)](http://nextgis.com)

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