MCPcopy Create free account
hub / github.com/dfinity/orbit / hashString

Function hashString

cli/src/utils.ts:22–30  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

20
21// Hash a string using the djb2 algorithm.
22export const hashString = (str: string): string => {
23 let hash = 5381;
24 for (let i = 0; i < str.length; i++) {
25 const char = str.charCodeAt(i);
26 hash = (hash << 5) - hash + char;
27 hash = hash & hash;
28 }
29 return hash.toString();
30};
31
32export const gitTagExists = (tag: string): boolean => {
33 const output = execSync(`git tag --list "${tag}"`).toString().trim();

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected