# flipfile

> file helpers for reading, writing, deleting, checking types & existence, extracting metadata, walking, globbing, and more.

Latest version **0.0.13** (published 2017-04-18) · 0 weekly downloads

## Install

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

## 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.13 |
| Published | 2017-04-18 |
| First published | 2017-03-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | James |
| Maintainers | aretecode |
| Keywords | file, fs, read, write, exists, walk, isAbsolute, fliphub, flipbox |

## Links

- npm: https://www.npmjs.com/package/flipfile
- Repository: https://github.com/fliphub/fliphub
- Homepage: https://github.com/fliphub/fliphub#readme
- Issues: https://github.com/fliphub/fliphub/issues
- npm.io page: https://npm.io/package/flipfile

## Dependencies (5)

- [glob](https://npm.io/package/glob.md) 7.1.1
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [fs-extra](https://npm.io/package/fs-extra.md) 2.1.2
- [expose-hidden](https://npm.io/package/expose-hidden.md) *
- [node-path-extras](https://npm.io/package/node-path-extras.md) 0.4.1

## 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.13 (latest) — 2017-04-18
- 0.0.1-alpha.17585ee1 (lerna-temp) — 2017-03-23
- 0.0.12 — 2017-04-16
- 0.0.10 — 2017-04-03
- 0.0.9 — 2017-04-03
- 0.0.8 — 2017-03-30
- 0.0.7 — 2017-03-29
- 0.0.6 — 2017-03-29
- 0.0.4 — 2017-03-26
- 0.0.3 — 2017-03-23
- 0.0.2 — 2017-03-23
- 0.0.1 — 2017-03-16

## README

# 🙃📒 flipfile

[![NPM version][flipfile-npm-image]][flipfile-npm-url]
[![MIT License][license-image]][license-url]
[![fliphub][gitter-badge]][gitter-url]
[![flipfam][flipfam-image]][flipfam-url]

[flipfile-npm-image]: https://img.shields.io/npm/v/flipfile.svg
[flipfile-npm-url]: https://npmjs.org/package/flipfile
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: https://spdx.org/licenses/MIT
[gitter-badge]: https://img.shields.io/gitter/room/fliphub/pink.svg
[gitter-url]: https://gitter.im/fliphub/Lobby
[flipfam-image]: https://img.shields.io/badge/%F0%9F%8F%97%20%F0%9F%92%A0-flipfam-9659F7.svg
[flipfam-url]: https://www.npmjs.com/package/flipfam

> file helpers for reading, writing, deleting, checking types & existence, extracting metadata, walking, globbing, and more.

## 📦 usage
```bash
yarn add flipfile
npm i flipfile --save
```

```js
const flipfile = require('flipfile')
```


## 🌐 api (everything is synchronous)

- getFileAndPath `(file: stringPath) => {file: string, dir: string}`
- getDirectories `(src: string, blacklist: Array<string>) => array<string>`
- isDir `(file: stringPath) => boolean`
- isFile `(file: stringPath) => boolean`
- isRel `(file: stringPath) => boolean`
- isFile `(file: stringPath) => boolean`
- read `(dir: stringPath) => string`
- write `(file: stringPath, contents: string) => void` writes to folder, uses mkdir if it does not exist
- exists `(file: stringPath) => boolean`
- fileName `(file: stringPath) => string`
- isFileOrDir `(file: stringPath) => bool`
- walk `(dir: stringPath, {recursive: true}) => Array<string | Array<Array<string>>`
- [mkdirp](https://www.npmjs.com/package/mkdirp)
- [node-path-extras exports](https://www.npmjs.com/package/node-path-extras)

## size

everything in [#api](#api) is exported in the main entry point, so it can be used as

```js
const {exists, isFile} = require('flipfile')
const file = './index.js'
if (exists(file)) console.log(read(file))
```

or as modular imports for fastest / smallest access

```js
const isRel = require('flipfile/isRel')
const write = require('flipfile/write')

const file = './src'
if (isRel(file)) write(file, 'eh')
```


## convenience

additionally there are 3 files not exported in the index
- they can be used by requiring them by name,
- or if you prefer destructuring, from `flipfile/all`
  - exports everything in [#api](#api) alongside these additional ones
  - exports a flattened `path` module
- [glob](https://www.npmjs.com/package/glob)
  - `require('flipfile/glob')`
- [extra](https://www.npmjs.com/package/fs-extra)
  - `require('flipfile/extra')`
  - @NOTE: everything in `extra` is exported flat as well
- [promise](https://www.npmjs.com/package/fs-promise)     
  - `require('flipfile/glob')`
  - @NOTE:
    - [fs-promise](https://www.npmjs.com/package/fs-promise) is not a dependency, so it will check if it's installed and if not, export is an empty object
    - [glob-fs](https://www.npmjs.com/package/glob-fs) got 💩 depreciated in favor of [node-glob](https://www.npmjs.com/package/glob)

```js
const {
  extra,    // fs-extra module
  promise,  // fs-promise or empty object
  exists,   // flipfile.exists
  copySync, // flat export from fs-extra
  glob,     // glob-fs
  fs,       // real 'fs'
  resolve,  // flat export from path
  join,     // flat export from path
} = require('flipfile/all')

const out = resolve(__dirname, './out')
const src = resolve(__dirname, './src')
if (exists(src)) {
  glob(src).forEach(fileOrDir => {
    copySync(fileOrDir, join(out, fileOrDir))
  })
}
```





-------

### 📝 TODO:

#### ⛓ chain:

```js
const flipfile = require('flipfile')
flipfile
  .file('./file')
  .isRel()
  .exists()
    .write('contents')
    .del()
    .exists()
```

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