MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / toBuffer

Function toBuffer

src/workspaces/persistent-session.ts:598–605  ·  view source on GitHub ↗
(raw: unknown)

Source from the content-addressed store, hash-verified

596}
597
598function toBuffer(raw: unknown): Buffer | null {
599 if (Buffer.isBuffer(raw)) return raw;
600 if (raw instanceof ArrayBuffer) return Buffer.from(raw);
601 if (Array.isArray(raw)) {
602 return Buffer.concat(raw.map((r) => toBuffer(r) ?? Buffer.alloc(0)));
603 }
604 return null;
605}
606
607function clamp(n: number, lo: number, hi: number): number {
608 if (!Number.isFinite(n)) return lo;

Callers 1

onWsMessageMethod · 0.85

Calls 1

fromMethod · 0.80

Tested by

no test coverage detected