MCPcopy Create free account
hub / github.com/anomalyco/opencode / generateID

Function generateID

packages/opencode/src/id/id.ts:30–39  ·  view source on GitHub ↗
(prefix: keyof typeof prefixes, direction: "descending" | "ascending", given?: string)

Source from the content-addressed store, hash-verified

28}
29
30function generateID(prefix: keyof typeof prefixes, direction: "descending" | "ascending", given?: string): string {
31 if (!given) {
32 return create(prefixes[prefix], direction)
33 }
34
35 if (!given.startsWith(prefixes[prefix])) {
36 throw new Error(`ID ${given} does not start with ${prefixes[prefix]}`)
37 }
38 return given
39}
40
41function randomBase62(length: number): string {
42 const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

Callers 2

ascendingFunction · 0.70
descendingFunction · 0.70

Calls 1

createFunction · 0.70

Tested by

no test coverage detected