streaming interface to the window location hash
Emits the location hash whenever it changes. Uses the hashchange event under the hood, so browser support is dictated therein.
const hashStream = require('location-hash-stream')
const stream = hashStream()
hashStream.on('data', data => console.log(data))
window.location.hash = 'lol'
// logs '#lol'
Writing to the stream sets the location hash.
const hashStream = require('location-hash-stream')
const stream = hashStream()
hashStream.write('hash')
// window.location.hash is now '#hash'
hashStream([opts]) -> stream
opts
is an optional configuration object. Available options are:stripHash
aBoolean
specifying whether the emitted location hash should be stripped of its leading#
character. Defaults tofalse
.
stream.getHash()
-> Retrieve the current hash string, respects thestripHash
parameter.
MIT