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

Function generateID

packages/app/src/utils/id.ts:25–35  ·  view source on GitHub ↗
(prefix: Prefix, descending: boolean, given?: string)

Source from the content-addressed store, hash-verified

23}
24
25function generateID(prefix: Prefix, descending: boolean, given?: string): string {
26 if (!given) {
27 return create(prefix, descending)
28 }
29
30 if (!given.startsWith(prefixes[prefix])) {
31 throw new Error(`ID ${given} does not start with ${prefixes[prefix]}`)
32 }
33
34 return given
35}
36
37function create(prefix: Prefix, descending: boolean, timestamp?: number): string {
38 const currentTimestamp = timestamp ?? Date.now()

Callers 2

ascendingFunction · 0.70
descendingFunction · 0.70

Calls 1

createFunction · 0.70

Tested by

no test coverage detected