UNPKG

kitchensink

Version:

Dispatch's awesome components and style guide

27 lines (21 loc) 550 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = hash; // a simple djb2 hash based on hash-string: // https://github.com/MatthewBarker/hash-string/blob/master/source/hash-string.js // returns a hex-encoded hash function hash(text) { if (!text) { return ''; } var hashValue = 5381; var index = text.length - 1; while (index) { hashValue = hashValue * 33 ^ text.charCodeAt(index); index -= 1; } return (hashValue >>> 0).toString(16); } module.exports = exports['default'];