# qir

> another fs

Latest version **0.4.1** (published 2024-04-17) · ISC license · 0 weekly downloads

## Install

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

## 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.4.1 |
| Published | 2024-04-17 |
| First published | 2019-02-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 52.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | YounGoat |
| Maintainers | youngoat |
| Keywords | fs, mkdirp, rmfr |

## Links

- npm: https://www.npmjs.com/package/qir
- Repository: https://github.com/YounGoat/nodejs.qir
- Issues: https://github.com/YounGoat/nodejs.qir/issues
- npm.io page: https://npm.io/package/qir

## Dependencies (2)

- [noda](https://npm.io/package/noda.md) ^0.6.0
- [sore](https://npm.io/package/sore.md) ^0.1.0

## 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.4.1 (latest) — 2024-04-17
- 0.4.0 — 2022-06-05
- 0.3.0 — 2022-05-11
- 0.2.0 — 2021-04-28
- 0.1.0 — 2021-02-22
- 0.0.7 — 2020-12-15
- 0.0.6 — 2019-05-20
- 0.0.5 — 2019-05-19
- 0.0.4 — 2019-05-19
- 0.0.3 — 2019-05-19
- 0.0.2 — 2019-03-31
- 0.0.1 — 2019-02-19

## README

#	qir
__another fs__

>	If links in this document not avaiable, please access [README on GitHub](./README.md) directly.

##  Description

`qir` is variant of *dir* which is abbreviation of *directory*. Actually, this package is based on built-in module `fs` and offers easy utilities helping access with file system.

##	ToC

*	[Get Started](#get-started)
*	[API](#api)
* 	[Examples](#examples)
*	[Why qir](#why-qir)

##	Links

*	[CHANGE LOG](./CHANGELOG.md)
*	[Homepage](https://github.com/YounGoat/nodejs.qir)

##	Get Started

```javascript
const qir = require('qir');

// Sync mode.
qir.syncing.mkd('/foo/bar/quz');

// Async mode.
qir.asyncing.rmfr('/foo').then(() => {
    // ...
});
```

##	API

There are two collections of methods in this package. 

```javascript
const qir       = require('qir');
const qirSync   = require('qir/syncing');
const qirAsync  = require('qir/asyncing');
const SyncDir   = require('qir/SyncDir');
const AsyncDir  = require('qir/AsyncDir');

qir.syncing  === qirSync    // true
qir.asyncing === qirAsync   // true
qir.SyncDir  === SyncDir    // true
qir.AsyncDir === AsyncDir   // true
```

*   class __qir.AsyncDir__( string *basepath* )
*   class __qir.SyncDir__( string *basepath* )
*   Object __qir.syncing__
*   Object __qir.asyncing__

The method collections `syncing` and `asyncing` are parallel, so are the classes `AsyncDir` and `SyncDir`.

Each of the method collections and class instances has following methods:  

*   void | Promise(void)   
    __appendFile__( string *filename*, string | Buffer *data* )

*   void | Promise(void)  
    __clear__()  
    Only available for instances of `AsyncDir` and `SyncDir`.  
    Remove everything in the directory and the directory itself.

*   void | Promise(void)  
    __copy__( string *src*, string *dest*)

*   void | Promise(void)   
    __copyFile__( string *src*, string *dest*, number *flags* )

*   stream.Readable | Promise(stream.Readable)  
    __createReadStream__( string *filename*[, Object *options*] )

*   stream.Writable | Promise(stream.Writable)  
    __createWriteStream__( string *filename*[, Object *options*] )

*   boolean  
    __exists__( string *pathname* )  
    Only available for instances of `AsyncDir` and `SyncDir`.

*   string[]  
    __find__( object *options* )  
    Only available for `asyncing` and instances of `AsyncDir`.  
    See [sore/find](https://github.com/YounGoat/sore/blob/master/docs/find.md) for details of *options*.

*   void | Promise(void)  
    __link__( string *existingPath*, string *newPath* )

*   void | Promise(void)  
    __mkd__( string *dirname* )

*   void | Promise(void)  
    __mkd_temp__( string *dirname* [, string *prefix*] )

*   void | Promise(void)  
    __mkd_parent__( string *pathname* )

*   integer | Promise(integer)  
    __open__( string *filename* [, string | number *flags* [, integer *mode* ] ] )

*   string | Buffer | Promis(string) | Promise(Buffer)  
    __readFile__( string *pathname* )  
    Only available for instances of `AsyncDir` and `SyncDir`.

*   JSON | Promise(JSON)  
    __readJSON__( string *filename* )

*   string[] | Promis(string[])  
    __readdir__( string *dirname* )  

*   void | Promise(void)  
    __rename__( string *oldPath*, string *newPath* )

*   string  
    __resolve__( string *pathname* )  
    Only available for instances of `AsyncDir` and `SyncDir`.

*   void | Promise(void)  
    __rmfr__( string *pathname* )

*   fs.Stats | Promise(fs.Stats)  
    __stat__( string *pathname* )  
    ATTENTION： This method is some different from built-in `fs.stats` which will throws an Error if the target is not accessible. It will return `null` in such case.

*   void | Promise(void)  
    __symlink__( string *target*, string *pathname* [, string *type* ] )

*   void | Promise(void)  
    __touch__( string *filename* )

*   void | Promise(void)  
    __writeFile__ ( string *filename*, string | Buffer | TypedArray | DataView *data* )

*   void | Promise(void)  
    __writeJSON__ ( string *filename*, JSON *json* )

ATTENTIONS:
*   In asynchronous mode, the leading type names represent NOT what the function will return on invoked, BUT *data* in `.then(data)`. Actually, each function will return an instance of `Promise` in asynchronous mode.

*   When pathname (dirname or filename) occurs in methods of `new AsyncDir()` and `new SyncDir()`, it will be regarded to be relative to the `basepath`.

*   Some methods accept same arguments with the homonynic methods in `fs`. But not each method has a symmetrical one in `fs`.

*   All methods in `qir.asyncing` and `new AsyncDir()` will return an instance of Promise.

*   All methods will automatically create parent directories if necessary.

##  Why *qir*

It is tedious to create an embedded directory with built-in module `fs`. E.g.

```javascript
// If you wannt to create a directory /foo/bar/quz while /foo doesnot exist:
fs.mkdirSync('/foo');
fs.mkdirSync('/foo/bar');
fs.mkdirSync('/foo/bar/quz');

// You may complete these operations in one step via `qir`.
qir.syncing.mkd('/foo/bar/quz');
```

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