MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / toBuffer

Function toBuffer

apps/kimi-code/src/native/web-assets.ts:52–59  ·  view source on GitHub ↗
(value: ArrayBuffer | ArrayBufferView | Buffer | string)

Source from the content-addressed store, hash-verified

50}
51
52function toBuffer(value: ArrayBuffer | ArrayBufferView | Buffer | string): Buffer {
53 if (Buffer.isBuffer(value)) return value;
54 if (typeof value === 'string') return Buffer.from(value);
55 if (ArrayBuffer.isView(value)) {
56 return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
57 }
58 return Buffer.from(value);
59}
60
61function sha256(bytes: Buffer | Uint8Array | string): string {
62 return createHash('sha256').update(bytes).digest('hex');

Callers 2

getNativeWebAssetsDirFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected