unique-resource
v0.1.0
Published
Get a short, unique key for a given file path based on the content of the file or its path.
Downloads
6
Maintainers
Readme
unique-resource
Get a short, unique key for a given file path based on the content of the file or its path.
Key is compatible with CSS classes and URLs. The file's basename is included in the key to make debugging easier (both in dev and production).
API
var getKey = require('unique-resource')
getKey('./styles/page.css', {root: __dirname}) // => "C4L8HPDXPJ-page"
getKey(path, options={})
Specify the path
of the file to get a unique key for.
options
:
root
: resolve relative paths based on this directoryhashPath
: whentrue
, don't read the content of the file, instead just hash the full resolved path.cache
: Defaults totrue
. Specifyfalse
to ignore previously cached file hashes, or pass in an object to use as a custom cache.
License
MIT