@llm-tools/embedjs-utils
Advanced tools
{ | ||
"name": "@llm-tools/embedjs-utils", | ||
"version": "0.1.26", | ||
"version": "0.1.27", | ||
"description": "Useful util functions when extending the embedjs ecosystem", | ||
"dependencies": { | ||
"@llm-tools/embedjs-interfaces": "0.1.26" | ||
"@llm-tools/embedjs-interfaces": "0.1.27" | ||
}, | ||
@@ -8,0 +8,0 @@ "type": "module", |
import { Stream } from 'stream'; | ||
export declare function stream2buffer(stream: Stream): Promise<Buffer>; | ||
export declare function streamToBuffer(stream: Stream): Promise<Buffer>; | ||
export declare function streamToString(stream: Stream): Promise<string>; | ||
export declare function contentTypeToMimeType(contentType: string): string; |
@@ -1,2 +0,2 @@ | ||
export async function stream2buffer(stream) { | ||
export async function streamToBuffer(stream) { | ||
return new Promise((resolve, reject) => { | ||
@@ -9,2 +9,10 @@ const _buf = Array(); | ||
} | ||
export async function streamToString(stream) { | ||
return new Promise((resolve, reject) => { | ||
const chunks = []; | ||
stream.on('data', (chunk) => chunks.push(Buffer.from(chunk))); | ||
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8'))); | ||
stream.on('error', (err) => reject(`error converting stream - ${err}`)); | ||
}); | ||
} | ||
export function contentTypeToMimeType(contentType) { | ||
@@ -11,0 +19,0 @@ if (!contentType) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24528
5.85%310
6.16%