# vinyl-transform

> Use standard text transform streams to write fewer gulp plugins

Latest version **1.0.0** (published 2014-11-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install vinyl-transform
pnpm add vinyl-transform
yarn add vinyl-transform
bun add vinyl-transform
```

## 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 | 2014-11-26 |
| First published | 2014-01-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 55 |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | vinyl, gulp, gulpfriendly, text, transform, streaming, through |

## Links

- npm: https://www.npmjs.com/package/vinyl-transform
- Repository: https://github.com/hughsk/vinyl-transform
- Issues: https://github.com/hughsk/vinyl-transform/issues
- npm.io page: https://npm.io/package/vinyl-transform

## Dependencies (3)

- [bl](https://npm.io/package/bl.md) ~0.7.0
- [new-from](https://npm.io/package/new-from.md) 0.0.3
- [through2](https://npm.io/package/through2.md) ~0.4.1

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2014-11-26
- 0.0.1 — 2014-01-27
- 0.0.0 — 2014-01-26

## README

# vinyl-transform [![Flattr this!](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=hughskennedy&url=http://github.com/hughsk/vinyl-transform&title=vinyl-transform&description=hughsk/vinyl-transform%20on%20GitHub&language=en_GB&tags=flattr,github,javascript&category=software)[![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #

**vinyl-transform** wraps standard text transform streams so you can
[write fewer gulp plugins](http://blog.overzealous.com/post/74121048393/why-you-shouldnt-create-a-gulp-plugin-or-how-to-stop).
Fulfills a similar use case to [vinyl-map](http://github.com/hughsk/vinyl-map)
and [vinyl-source-stream](http://github.com/hughsk/vinyl-source-stream).

This module lets you take your standard text transform streams from npm,
(e.g. [envify](http://github.com/hughsk/envify)), and use them in a
[vinyl](http://github.com/gulpjs) pipeline. It'll transparently take care of
handling both buffered and streaming vinyl instances for you too.

## Usage ##

[![vinyl-transform](https://nodei.co/npm/vinyl-transform.png?mini=true)](https://nodei.co/npm/vinyl-transform)

### `createStream(transformFn)` ###

Creates a vinyl transform stream. `transformFn(filename)` is a function which
takes the file's path and returns a text transform stream. If you've used
[browserify](http://github.com/substack/node-browserify)'s
[transform API](https://github.com/substack/node-browserify#btransformopts-tr)
you'll recognise this pattern: it's effectively the same API used here.

Here's an example of using this to... uppercase a bunch of files:

``` javascript
var transform = require('vinyl-tranform')
var map = require('map-stream')
var gulp = require('gulp')

gulp.task('uppercase', function() {
  var uppercaser = transform(function(filename) {
    return map(function(chunk, next) {
      return next(null, chunk.toString().toUpperCase())
    })
  })

  gulp.src('*.txt')
    .pipe(uppercaser)
    .pipe(gulp.dest('dist/'))
})
```

And convert `.gif` images into `.webm` videos:

``` javascript
var createGIFStream = require('gif-video')
var transform = require('vinyl-transform')
var gulp = require('gulp')

gulp.task('gif-to-webm', function() {
  gulp.src('images/*.gif')
    .pipe(transform(createGIFStream))
    .pipe(gulp.dest('dist/videos/'))
})
```

Or inject scripts into your HTML:

``` javascript
var transform = require('vinyl-transform')
var inject = require('script-injector')
var gulp = require('gulp')

gulp.task('pages', function() {
  var injector = transform(function() {
    return inject(function() {
      console.log('this script wasn\'t here before')
    })
  })

  gulp.src('*.html')
    .pipe(injector)
    .pipe(gulp.dest('dist/'))
})
```

## License ##

MIT. See [LICENSE.md](http://github.com/hughsk/vinyl-transform/blob/master/LICENSE.md) for details.

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