nanohistory
Version:
Small browser history library
13 lines (10 loc) • 298 B
JavaScript
var assert = require('assert')
module.exports = history
// listen to html5 pushstate events
// and update router accordingly
function history (cb) {
assert.equal(typeof cb, 'function', 'nanohistory: cb must be type function')
window.onpopstate = function () {
cb(document.location)
}
}