# @esfx/iter-hierarchy

> A Symbol-based API for defining an Iterable with an inherent hierarchy.

Latest version **1.0.2** (published 2022-11-01) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @esfx/iter-hierarchy
pnpm add @esfx/iter-hierarchy
yarn add @esfx/iter-hierarchy
bun add @esfx/iter-hierarchy
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-11-01 |
| First published | 2020-12-18 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 158.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 234 |
| Author | Ron Buckton |
| Maintainers | rbuckton |

## Links

- npm: https://www.npmjs.com/package/@esfx/iter-hierarchy
- Repository: https://github.com/esfx/esfx
- Homepage: https://github.com/esfx/esfx#readme
- Issues: https://github.com/esfx/esfx/issues
- npm.io page: https://npm.io/package/@esfx/iter-hierarchy

## Dependencies (4)

- [tslib](https://npm.io/package/tslib.md) ^2.4.0
- [@esfx/interval](https://npm.io/package/@esfx/interval.md) ^1.0.2
- [@esfx/equatable](https://npm.io/package/@esfx/equatable.md) ^1.0.2
- [@esfx/iter-ordered](https://npm.io/package/@esfx/iter-ordered.md) ^1.0.2

## Recent versions

- 1.0.2 (latest) — 2022-11-01
- 1.1.0-alpha.202307260322 (next) — 2023-07-26
- 1.0.0-dev.8 (dev) — 2022-10-20
- 1.1.0-alpha.202306080253 — 2023-06-08
- 1.1.0-alpha.202306061406 — 2023-06-06
- 1.1.0-alpha.202306061316 — 2023-06-06
- 1.1.0-alpha.202306051228 — 2023-06-05
- 1.1.0-alpha.202305082104 — 2023-05-08
- 1.1.0-alpha.202302091715 — 2023-02-09
- 1.1.0-alpha.202302071935 — 2023-02-07
- 1.1.0-alpha.202211291446 — 2022-11-29
- 1.1.0-alpha.202211221509 — 2022-11-22
- 1.1.0-alpha.202210252139 — 2022-10-25
- 1.0.0 — 2022-10-20
- 1.0.0-dev.7 — 2022-10-20
- … 25 more at https://npm.io/package/@esfx/iter-hierarchy/versions

## README

# `@esfx/iter-hierarchy`

A Symbol-based API for defining an Iterable with an inherent hierarchy.

# Overview

* [Installation](#installation)
* [Usage](#usage)
* [API](#api)

# Installation

```sh
npm i @esfx/iter-hierarchy
```

# Usage

```ts
import { HierarchyIterable, Hierarchical, HierarchyProvider } from "@esfx/iter-hierarchy";

interface Node {
    parent?: Node;
    children?: Node[];
    ...
}

const hierarchyProvider: HierarchyProvider<Node> = {
    parent(node: Node) { return node.parent; },
    children(node: Node) { return node.children; },
};

class MyHierarchyIterable implements HierarchyIterable<Node> {
    private #nodes: Iterable<Node>;
    constructor(nodes: Iterable<Node>) {
        this.#nodes = nodes;
    }

    [Symbol.iterator]() {
        return this.#nodes[Symbol.iterator]();
    }

    [Hierarchical.hierarchy]() {
        return hierarhcyProvider;
    }
}
```

# API

You can read more about the API [here](https://esfx.js.org/esfx/api/iter-hierarchy.html).

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