# map-file

> Map a file into another file

Latest version **0.2.0** (published 2018-01-14) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install map-file
pnpm add map-file
yarn add map-file
bun add map-file
```

## 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.2.0 |
| Published | 2018-01-14 |
| First published | 2017-10-11 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Ryan Van Etten |
| Maintainers | ryanve |
| Keywords | javascript, filesystem, edit, file, fs |

## Links

- npm: https://www.npmjs.com/package/map-file
- Repository: https://github.com/ryanve/map-file
- Issues: https://github.com/ryanve/map-file/issues
- npm.io page: https://npm.io/package/map-file

## 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.2.0 (latest) — 2018-01-14
- 0.1.0 — 2017-10-11

## README

# [`map-file`](https://www.npmjs.com/package/map-file)
Map a file into another file in Node.js

```
npm install map-file
```

## API

### <code>mapFile({from, to, map=<var>identity</var>}, callback=<var>done</var>)</code>

- `from` is the reading filename
  - supports relative or absolute
- `to` is the writing filename
  - supports relative or absolute
  - makes nonexistent directories via `fs.mkdir`
- `map` is the function you use to map the content
  - default returns the original text
- `callback` is a function to call after mapping
  - default throws errors and logs success

## Usage

```js
const mapFile = require("map-file")
```

### Copy file

```js
mapFile({
  from: "original.css",
  to: "copy.css",
})
```

### Trim file

```js
mapFile({
  from: "example.css",
  to: "example.css",
  map: text => text.trim(),
})
```

### Slice file

```js
mapFile({
  from: "full.md",
  to: "summary.md",
  map: text => text.slice(0, 200),
})
```

### Callback

```js
mapFile({
  from: "source.txt",
  to: "target.txt",
  map: text => text,
}, err => {
  if (err) throw err
  // ...
})
```

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