# gulp-map

> (A)synchronous mapping and filtering of object streams

Latest version **0.0.2** (published 2014-06-09) · MIT license · 0 weekly downloads

## Install

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

## 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.2 |
| Published | 2014-06-09 |
| First published | 2014-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Jelle 'wires' Herold |
| Maintainers | wires |
| Keywords | gulpplugin, gulpfriendly |

## Links

- npm: https://www.npmjs.com/package/gulp-map
- Repository: https://github.com/0x01/gulp-map
- Homepage: http://github.com/0x01/gulp-map
- Issues: https://github.com/0x01/gulp-map/issues
- npm.io page: https://npm.io/package/gulp-map

## Dependencies (3)

- [kew](https://npm.io/package/kew.md) ^0.4.0
- [through2](https://npm.io/package/through2.md) ^0.5.1
- [is-promise](https://npm.io/package/is-promise.md) ^1.0.1

## Recent versions

- 0.0.2 (latest) — 2014-06-09
- 0.0.1 — 2014-06-09

## README

# Better mapping.

Works with 

```js
$ = require('gulp-load-plugins');
// $.map(fn)
```

When returning a promise, it is mapped asynchronously (in parallel):

```js
var Q = require('kew');
// ...
.pipe($.map(function(file){
	return Q.delay(500).then(function(){
		file.tags = (file.tags || []).push('slow');
		return file;
	});
}))
```

The stream 'end' event delayed until all promisses are finished.

When you return `undefined` from your promise or regular function, the file is
filtered from the stream.

```js
.pipe($.map(function(file){
	if(file.path.match(/gulpfile\.js/))
		return file;
	// other files not emitted
}))
```

That's it.

## Alternatives

For regular callback style mapping, just use `map-stream`.

```js
var map = require('map-stream');
// ...
.pipe(map(function(file, done){
	done(null, file);
}))
```

For both `data` and `end` events, `through2` works well:

```js
var Through = require('through2').obj;
// ...
.pipe(Through(
	function handle_data(file, encoding, done) {
		this.push(file);
		done();
	}
	function handle_end(done) {
		done();
	}
))
```

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