# glob-map

> Glob, and map a callback over files

Latest version **1.0.0** (published 2018-05-10) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-05-10 |
| First published | 2018-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 2.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Quentin Engles |
| Maintainers | hollowdoor |
| Keywords | glob, map, files |

## Links

- npm: https://www.npmjs.com/package/glob-map
- Repository: https://github.com/hollowdoor/glob-map
- Homepage: https://github.com/hollowdoor/glob-map#readme
- Issues: https://github.com/hollowdoor/glob-map/issues
- npm.io page: https://npm.io/package/glob-map

## Dependencies (2)

- [p-map](https://npm.io/package/p-map.md) ^1.2.0
- [globby](https://npm.io/package/globby.md) ^8.0.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

- 1.0.0 (latest) — 2018-05-10

## README

glob-map
===

Install
---

`npm install glob-map`

Usage
---

```javascript
const globMap = require('glob-map');

globMap('./files/*.md', file=>{
    console.log('file ',file);
});
```

API
---

### globMap(globs, options|cb, cb|undefined)

`globMap()` returns a promise on completion. The second argument can be an object, or a callback. The third argument can be a callback, or undefined.

### options

`options` should be an object.

See [globby](https://github.com/sindresorhus/globby) for most of the options. Also see [fast-glob](https://github.com/mrmlnc/fast-glob#options-1).

There is also an extra option `options.concurrency` which is the amount of concurrent runs of cb. See [p-map](https://github.com/sindresorhus/p-map).

### cb

`cb` should be a function that will run once for each file name, and be passed each one of those file names.

#### cb(filename)

For each file name `cb` is run.

Write code that will do work inside `cb`, and when that work is done return a promise. You can return whatever value from `cb`, but to take advantage of the async nature of `glob-map` returning a promise is advantageous.

Using an async function for `cb` is also valid.

```javascript
const globMap = require('glob-map');
const Promise = require('bluebird');
const readFile = require('fs').readFile;
const read = Promise.promisify(readFile);
//Some function that you create
const sendContent = require('./send_content');

globMap('./files/*', async file=>{
    let content = await read(file, 'utf8');
    return sendContent(content);
});
```

About
---

Under the hood `glob-map` uses [p-map](https://github.com/sindresorhus/p-map) to take advantage of concurrency.

This module codifies a super common pattern in file operations. :)

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