npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vinyl-tapper

v1.3.2

Published

A vinyl-passthrough-stream for testing purposes

Downloads

21

Readme

vinyl-tapper

npm version

A transform-stream for vinyl stream that emits a 'tap'-event for every file

Features

Works with buffer- and file- vinyl-streams, optionally terminates the stream.

Usage

Check meta data

Check if gulp-unzip correctly strips the .gz - extension:

import assert from 'assert';
import path from 'path';
import gunzip from 'gulp-gunzip';
import vinylFs from 'vinyl-fs';
import vinylTapper from 'vinyl-tapper';

const tapper = vinylTapper();
tapper.on('tap', function(file) {
  assert(!file.path.match(/\.gz$/));
});

vinylFs.src(['**/*.gz'], {cwd: 'src', buffer: false}) 
// works with 'buffer: true', too 
  .pipe(gunzip())
  .pipe(tapper)
  .pipe(vinylFs.dest('dist'));

Check contents

Check if gulp-unzip does some expansion

import assert from 'assert';
import path from 'path';
import gunzip from 'gulp-gunzip';
import vinylFs from 'vinyl-fs';
import vinylTapper from 'vinyl-tapper';

const tapper = vinylTapper({provideBuffer: true});
tapper.on('tap', function(file, buffer) {
  var contents = buffer.toString('utf8');
  assert(contents.match(/exports/)) // all our modules do export something
});

vinylFs.src(['**/*.gz'], {cwd: 'src', buffer: false}) 
// works with 'buffer: true', too 
  .pipe(gunzip())
  .pipe(tapper)
  .pipe(vinylFs.dest('dist'));

The passed file-object are not modified in any manner.

Termination

If there is no need to pipe along the resulting stream, you can specify terminate: true to get it eaten up right here:

const tapper = vinylTapper({provideBuffer: true, terminate: true});
tapper.on('tap', function(file, buffer) {
  // do some checks
});

vinylFs.src(['**/*.gz'], {cwd: 'src', buffer: false})
  .pipe(gunzip())
  .pipe(tapper)
  .on('end', function() {
    // all files have been tapped now...
  });

API

const tapper = tapper(options);

Creates a new tapper-stream. Available options:

  • single: If true, creates a tapper for a single data-stream. If false (default), create a tapper for a vinyl-file-stream.
  • provideBuffer: If true, 'tap'-events will provide a buffer.
  • terminate: If true, the incoming stream will be consumed by the tapper.

Event 'tap'

  • file (only if not single): the vinyl-file object
  • buffer (only if provideBuffer): the buffered contents of the vinyl-file.

This event will be emitted as soon as possible: With not provideBuffer or if a file already holds a buffer, this will be when the file enters the tapper. For stream-files with provideBuffer the event will be emmitted when the file has passed completely.