# nfsu

> Node file system utilities

Latest version **0.0.1** (published 2014-05-14) · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2014-05-14 |
| First published | 2014-05-14 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dmitry |
| Maintainers | dmi3y |
| Keywords | filesystem, utilities |

## Links

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

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.0.1 (latest) — 2014-05-14
- 0.0.0 — 2014-05-14

## README

# nfsu [![Build Status](http://img.shields.io/travis/dmi3y/nfsu.svg?style=flat&branch=nfsu)](http://travis-ci.org/dmi3y/nfsu)


> Wrapper for low level NodeJS filesystem utilities.

Mixed `fs` and `path` toolkit, plus commonly used syncronious shortcuts on top.

## Usage

```js

    var nfsu = require('nfsu');
```

## Cheatsheet

```js

    nfsu.readFileStr(file/*str*/);
```

Reads `file` and returns string representation of it or `false` if file does not exists.

```js

    nfsu.readFileJson(file/*str*/);
```

Reads JSON `file` and returns parsed JSON object or `false` if file does not exists.

```js

    nfsu.readDir(target/*str*/);
```

Reads `target` directory and returns array of contained folders/files or `false` if directory does not exists.

```js

   nfsu.ifFile(target/*str*/);
```

Checks if `target` is file and returns `true` if so and `false` if it is not or file does not exists.

```js

   nfsu.ifDir(target);
```

Checks if `target` is directory and returns `true` if so and `false` if it is not or directory does not exists.

```js

   nfsu.lookDownFilesByExts(targets/*arr*/, exts/*arr*/, opt/*obj*/);
```

Recursively iterates down through all the 'targets' folder items and gathers all the files wich are listed into `exts` (.css, .js, .jpg etc).
Additionally `opt` configuration may be provided.

```js

   opt = { excl:['exclude/folder', 'exclude/file.js'], base: '/basefolder' };
```

By default opt.base is current working directory.

Returns object with key(s) as file extentions and value(s) array of accordingly resolved file pathes found to that extention, or empty array if there is nothing found.

Headsup: if `opt.base` speceficly provided, relative `targets` and `opt.excl` folders/files have to take it into account.
Eg:

```
    ..(cwd)/a/b/c/d/x.n
                 /d/y.n
                 /d/z.n
                 /e/...
```


nfsu.lookDownFilesByExts([d/], ['.n'], {excl:['d/y.n'], base: 'a/b/c/'})
This is right -> {'.n':['<fullpath>/a/b/c/d/x.n','<fullpath>/a/b/c/d/z.n']}

~~nfsu.lookDownFilesByExts([a/b/c/d/], ['.n'], {excl:['a/b/c/d/y.n'], base: 'a/b/c/'})~~
This is  wrong -> {'.n':[]}

Tip: To filter files with no extention provide empty sting into 'exts' array.
[""] - will look down files with no extention.

```js 

    nfsu.lookUpFileByName(filename/*str*/, base/*str*/, stopby/*str*/);
````

Recursively iterates up from the current working directory or `base` untill `filename` found, or userhome|`stopby`|top directory.
Returns resolved file path, or `null` if nothing is found.

In addition all the `fs` and `path` methods available through according properties:
`nfsu.fs` and `nfsu.path`, and its shortcuts `nfsu.f` and `nfsu.p`

## License
Copyright (c) 2014 Dmitry Lapshukov. Licensed under the MIT license.

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