bare-bundle-id
Construct a unique ID for a bundle
stable
Source
bare-bundle-id — Construct a unique ID for a bundle.
npm i bare-bundle-idUsage
const Bundle = require('bare-bundle')
const id = require('bare-bundle-id')
const bundle = new Bundle()
.write('/foo.js', "module.exports = require('./bar')", {
main: true,
imports: {
'./bar': '/bar.js'
}
})
.write('/bar.js', 'module.exports = 42')
bundle.id = id(bundle).toString('hex')
// 33824862...API
Functions
id(bundle: Bundle): Buffer
Source
Returns a 32-byte BLAKE2b hash of bundle's sorted file entries (path, contents, and mode), uniquely identifying the bundle's contents.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
bundle | Bundle | — | The bare-bundle instance to hash; its file entries are sorted by path before hashing, so the ID is stable regardless of the order they were written in. |
See also
- Bare modules — the full
bare-*catalog. - Bare runtime API — the runtime these modules extend.