Wraps browserify transforms in a caching stream.
Cacheify is a caching layer for browserify transforms. You specify a transform and a cache and it handles the rest by wrapping everything in its own browserify transform that you'll pass to the bundling process.
You can also specify custom filter and hash functions to be specific about which files get cached, and how a file is decided to be unique.
var cacheify = require('cacheify'), coffeeify = require('coffeeify'), level = require('level'), db = level('./cache');...var cachingCoffeeify = cacheify(coffeeify, db)...b.transform(cachingCoffeeify)
Creates a new cacheify transform.
transform: The transform you want to cache the output of
db: A levelup-api compatible database object, or a function that returns such an object. This is where the results of cached transforms are stored.
Replaces the default filter function (always returns true) with a function of your choosing. The filter function is called per file and if it returns a truthy value we will cache the results of the transform of the file, or read from the cache if it's already there. If it returns false we will apply the original transform without caching.
fn: The filter function you want to use. It takes one argument, the file path. If
fnis a RegExp object,
cacheify.filterwill wrap it in a function that tests each filename against it.
Replaces the default hash function (md5 of the file's contents) with a function of your choosing. The hash function will be used to generate a unique key for a file, that we will check to see if it exists in the DB before applying the original transform.
fn: The hash function you want to use. It takes two arguments, the file contents and the file path.
0.4.0 Now passes transform options through to cachee streams.
0.3.2 Now handles multiple errors in the cachee stream instead of only one.
0.3.1 the second argument, db, can now be a function that returns a db. Useful if you need to close connections and unlock the leveldb between bundles.
0.2.1: When the filter returns false, instead of passing an empty through pass the original uncached transform. That way it can handle what gets transformed and we only handle what gets cached.
0.2.0: Do not use, has breaking bugs!! 0.2.1 fixes them. Apologies!
BSD, see the LICENSE.md for more information.