JSPM

@koura/unique-hash

2.6.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q30947F
  • License MIT

Generate a unique and repeatable hash id for strings like names and urls

Package Exports

  • @koura/unique-hash

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@koura/unique-hash) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

The best package to create hash ids.

npm version npm version PR Stats Issue Stats Join the chat

unique-hash

Useful for saving to

import uniqueHash from "unique-hash"

//or es5
//var uniqueHash = require("unique-hash").default
let url = "https://www.npmjs.com/package/unique-hash"

uniqueHash(url)
//>> output 88870086

uniqueHash(url)
//>> output 88870086

uniqueHash(url,{format:"string"})
//>> output "iIIHaAIG"

uniqueHash(url,{format:"string"})
//>> output "iIIHaAIG"


uniqueHash("John H. Smith")
//>> output 983277668
uniqueHash("John H Smith")
//>> output  983277668
uniqueHash("JohnHSmith")
//>> output 983277668


uniqueHash("John H. Smith",{format:"kebabCase"})
//>> output "john-h-smith"
uniqueHash("John H Smith",{format:"kebabCase"})
//>> output "john-h-smith"
uniqueHash("JohnHSmith",{format:"kebabCase"})
//>> output "john-h-smith"


uniqueHash(url,{
  prepend:"articles",
  date:new Date(),
 })
 //>> output "articles/2017/08/27/88870086"


uniqueHash(url,{
  prepend:"articles",
  append:"videos",
  appendDate:"hot",
  date:new Date(),
  formatDate:"yyyy/DD",
  format:"string"
 })
 //>> output "articles/2017/08/hot/iIIHaAIG/videos"

Parameters

Parameter Default Description
format "number" options: "number", "string" or "kebabCase"
prepend "" string to prepend output path
append "" string to append output path
appendDate "" string to center between date and hash id (eg. output /yyyy/MM/dd/[HERE]/:hashId)
date n/a pass in date to append /YYYY/MM/DD to save path
dateFormat "yyyy/MM/dd" Date format
hashId n/a override the output hashId, useful if you want to use with date.