https://github.com/hexlet-components/js-immutable-fs-trees
https://github.com/hexlet-components/js-immutable-fs-trees
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hexlet-components/js-immutable-fs-trees
- Owner: hexlet-components
- Created: 2017-10-28T17:26:20.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-09-05T07:31:27.000Z (almost 2 years ago)
- Last Synced: 2025-08-08T17:24:37.658Z (11 months ago)
- Language: JavaScript
- Homepage: https://hexlet.io
- Size: 945 KB
- Stars: 18
- Watchers: 8
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# js-immutable-fs-trees
[](https://github.com/hexlet-components/js-immutable-fs-trees/actions)
## Install
```sh
npm install @hexlet/immutable-fs-trees
```
## Usage example
```javascript
import {
mkfile, mkdir, isDirectory, isFile, map,
} from '@hexlet/immutable-fs-trees';
isFile(mkfile('config')); // true
isDirectory(mkdir('etc')); // true
const tree = mkdir('etc', [mkfile('config'), mkfile('hosts')]);
const callbackFn = (node) => {
const { name } = node;
const newName = name.toUpperCase();
return { ...node, name: newName };
};
map(callbackFn, tree);
// {
// name: 'ETC',
// children: [
// { name: 'CONFIG', meta: {}, type: 'file' },
// { name: 'HOSTS', meta: {}, type: 'file' }
// ],
// meta: {},
// type: 'directory',
// }
```
For more information, see the [Full Documentation](https://github.com/hexlet-components/js-immutable-fs-trees/tree/master/docs)
---
[](https://hexlet.io?utm_source=github&utm_medium=link&utm_campaign=js-immutable-fs-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-immutable-fs-trees).
See most active contributors on [hexlet-friends](https://friends.hexlet.io/).