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

browserify-through

v2.0.0

Published

Handy dandy helper to assist you with writing Browserify transforms.

Downloads

12

Readme

browserify-through

Dependency status devDependency Status Build Status

NPM

Handy dandy helper to assist you with writing Browserify transforms.

Installation

npm install browserify-through

Usage Example

Via package.json

{
  "name": "fixtures",
  "version": "1.0.0",
  "browserify": {
    "transform": [
      ["./transform", {"token": "__token__"}]
    ]
  }
}
var through = require('browserify-through');

module.exports = through({
  map: function (filepath, opts, data, done) {
    done(null, data.replace(opts.token, '__new_token__'));
  },

  filter: function (filepath, opts) {
    return /\.js$/.test(filepath);
  }
});

Via Browserify API

var browserify = require('browserify');
var through = require('browserify-through');
var bundler = browserify('./src/index.js');

bundler.transform(through({
  map: function (filepath, opts, data, done) {
    done(null, data.replace(/foo/, 'bar'));
  },

  // optional filter
  filter: function (filepath, opts) {
    return /\.js$/.test(filepath);
  }
}));

API

through({opts})

  • opts.map - function(filepath, opts, data, [callback]) - Function should either return final data or call callback(err, data). opts are passed via package.json.
  • opts.filter - function(filepath, opts) - If filter function returns true for a givel filepath, the content will be passed to the map function. It's much more efficient to do this step separately from the map function because if you want to just ignore the file, it will be passed through without being stored in memory to be passed into map. opts are passed via package.json.

Testing

npm test

License

The MIT License (MIT)

Copyright 2014 Alex Gorbatchev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.