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 🙏

© 2026 – Pkg Stats / Ryan Hefner

factor-bundle-reset-patch

v1.0.0

Published

Patch for factor-bundle to work with watchify

Readme

factor-bundle-reset-patch

Patch for [email protected] to work with watchify.

There is a problem to use 2.4.1 with watchify: output streams are finished after bundle and thus not writable anymore, so you will run into errors when watchify fires update to rebundle.

To solve this problem, output streams are rebuilt every time reset.

Example

example/gulpfile.js

var path = require('path');
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var buffer = require('gulp-buffer');
var gutil = require('gulp-util');

var factor = require('factor-bundle-reset-patch');
var browserify = require('browserify');
var watchify = require('watchify');

var source = require('vinyl-source-stream');
var merge = require('merge-stream');
var readonly = require('read-only-stream');
var del = require('del');

var PassThrough = require('stream').PassThrough;

var fixtures = path.resolve.bind(path, __dirname);

gulp.task('clean', function (cb) {
    del(fixtures('dist'), cb);
});

gulp.task('default', ['clean'], function () {
    return bundle(getBundle());
});

gulp.task('watch', ['clean'], function (cb) {
    var b = watchify(getBundle());
    b.on('update', _bundle);
    _bundle();

    function _bundle() {
        bundle(b);
    }
});

function bundle(b) {
    return b.bundle()
        // from now on, use gulp plugins to transform contents
        .pipe(buffer())
        .pipe(uglify())
        .pipe(gulp.dest(fixtures('dist')))
        ;
}

function getBundle() {
    var entries = ['a.js', 'b.js'];
    var basedir = fixtures('src');
    var b = browserify(entries, { basedir: basedir })
    b.plugin(factor, {
        entries: entries,
        basedir: basedir,
        outputs: entries,
        // overwrite default `fs.createWriteStream` to make vinyl streams
        createWriteStream: source,
    });
    b.on('log', gutil.log);
    b.on('error', gutil.log);
    // make `bundle` return a vinyl stream.
    // perhaps another plugin to gulpify `bundle`
    b.bundle = function () {
        var pipeline = PassThrough({ objectMode: true });
        var common = browserify.prototype.bundle.call(b)
            .pipe(source('common.js'));
        b.once('factor.pipelines', function (files, pipelines, outputs) {
            merge(outputs.concat(common)).pipe(pipeline);
        });
        return readonly(pipeline);
    };
    return b;
}
⌘ tree example/
example/
├── dist
│   ├── a.js
│   ├── b.js
│   └── common.js
├── gulpfile.js
└── src
    ├── a.js
    ├── b.js
    └── c.js

b.plugin(factor, opts)

opts

entries

Type: Array

Entry file paths. Absolute or relative to opts.basedir

basedir

Type: String

outputs

Type: Array, String

Output destinations. Passed to opts.createWriteStream to make output streams.

Type: Function

It receives opts.entries, opts.basedir, and should return output streams.

createWriteStream

Type: Function

Default: fs.createWriteStream

pack

Type: Function, browser-plugin

Default: browser-pack

theshold

Same with that in factor-bundle.

events

b.on('factor.pipelines', function(files, pipelines, outputStreams){})

Emits all absolute entry files, pipelines, and output streams.