emotionのdata-属性で使っているような値が欲しかった。emotionは@emotion/hashとして持っているものの、内部用かなぁと思うのでmurmurhashを使ってみた。TextEncoderを使っているので環境によりpolyfillが必要。
import murmurhash from "murmurhash";
function hashString(s) {
return murmurhash.v3(s).toString(36);
}
console.log(hashString("hfogfffe")); // 6bmwh9
参考