MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / getBytes

Function getBytes

packages/core/src/v3/apiClient/core.ts:417–441  ·  view source on GitHub ↗
(value: ToFileInput)

Source from the content-addressed store, hash-verified

415};
416
417async function getBytes(value: ToFileInput): Promise<Array<BlobPart>> {
418 let parts: Array<BlobPart> = [];
419 if (
420 typeof value === "string" ||
421 ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
422 value instanceof ArrayBuffer
423 ) {
424 parts.push(value);
425 } else if (isBlobLike(value)) {
426 parts.push(await value.arrayBuffer());
427 } else if (
428 isAsyncIterableIterator(value) // includes Readable, ReadableStream, etc.
429 ) {
430 for await (const chunk of value) {
431 parts.push(chunk as BlobPart); // TODO, consider validating?
432 }
433 } else {
434 throw new Error(
435 `Unexpected data type: ${typeof value}; constructor: ${value?.constructor
436 ?.name}; props: ${propsForError(value)}`
437 );
438 }
439
440 return parts;
441}
442
443function propsForError(value: any): string {
444 const props = Object.getOwnPropertyNames(value);

Callers 1

toFileFunction · 0.85

Calls 3

isBlobLikeFunction · 0.85
isAsyncIterableIteratorFunction · 0.85
propsForErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…