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

Function sort

packages/opencode/test/server/httpapi-exercise/assertions.ts:20–28  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

18}
19
20function sort(value: unknown): unknown {
21 if (Array.isArray(value)) return value.map(sort)
22 if (!value || typeof value !== "object") return value
23 return Object.fromEntries(
24 Object.entries(value)
25 .sort(([left], [right]) => left.localeCompare(right))
26 .map(([key, item]) => [key, sort(item)]),
27 )
28}
29
30export function array(value: unknown): asserts value is unknown[] {
31 if (!Array.isArray(value)) throw new Error("expected array")

Callers 1

stableFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected