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

Function toBuffer

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

Source from the content-addressed store, hash-verified

85}
86
87function toBuffer(value: ArrayBuffer | ArrayBufferView | Buffer | string): Buffer {
88 if (Buffer.isBuffer(value)) return value;
89 if (typeof value === 'string') return Buffer.from(value);
90 if (ArrayBuffer.isView(value)) {
91 return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
92 }
93 return Buffer.from(value);
94}
95
96function sha256(bytes: Buffer | Uint8Array | string): string {
97 return createHash('sha256').update(bytes).digest('hex');

Callers 2

ensureNativeAssetTreeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected