https://github.com/hexlet-components/js-trees
https://github.com/hexlet-components/js-trees
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hexlet-components/js-trees
- Owner: hexlet-components
- Created: 2016-07-01T10:32:01.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2025-07-11T20:14:29.000Z (12 months ago)
- Last Synced: 2025-08-08T17:24:40.396Z (11 months ago)
- Language: JavaScript
- Size: 2.01 MB
- Stars: 2
- Watchers: 9
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# js-trees
[](https://github.com/hexlet-components/js-trees/actions)
## Install
```sh
npm install @hexlet/trees
```
## Usage example
```javascript
import Tree from '@hexlet/trees';
const tree = new Tree('/', 'root directory');
tree.getMeta(); // 'root directory'
const etcNode = tree.addChild('etc');
etcNode.getKey(); // 'etc'
tree.hasChild('etc'); // true
etcNode.getParent() === tree; // true
etcNode.hasChildren(); // false
tree.hasChildren(); // true
const libNode = etcNode.addChild('lib');
libNode === tree.getChild('lib'); // true
libNode === tree.getDeepChild(['etc', 'lib']); // true
etcNode.removeChild('lib'); // true
etcNode.hasChild('lib'); // false
```
For more information, see the [Full Documentation](https://github.com/hexlet-components/js-trees/tree/master/docs)
[](https://hexlet.io?utm_source=github&utm_medium=link&utm_campaign=js-trees)
This repository is created and maintained by the team and the community of Hexlet, an educational project. [Read more about Hexlet](https://hexlet.io?utm_source=github&utm_medium=link&utm_campaign=js-trees).
See most active contributors on [hexlet-friends](https://friends.hexlet.io/).