node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

fingerprinter

fingerprinter

Build Status

Generic assests fingerprint generator. Generates md5 hash for a set of files or strings that you can append to URL to flush browser cache.

Installation

npm install --save fingerprinter

Example

var Fingerprinter = require('fingerprinter');
var fp = new Fingerprinter();
fp.addFiles(['build/scripts.js', 'build/styles.css']);
fp.get(function(err, fingerprint) {
    if (!err) {
        console.log(fingerprint);
    }
});

API

add(string)

Add string.

fp.add('body { color:red; }');

fn.addFile(file) / fn.addFiles([file1, file2...])

Add file(s).

fp.addFile('build/scripts.js');
fp.addFiles(['build/scripts.js', 'build/styles.css']);

get(callback)

Get hash.

fp.get(function(err, fingerprint) {
    // fingerprint = '73287dcc3d1ba241d7556412b7201af6'
});

makeUrl(uri, callback)

Append hash to URL.

fp.makeUrl('build/scripts.js', function(err, uri) {
    // uri = 'build/scripts.js?73287dcc3d1ba241d7556412b7201af6'
});

Changelog

The changelog can be found in the Changelog.md file.

Author


License

The MIT License, see the included License.md file.