@travetto/base
Advanced tools
Comparing version 3.3.0 to 3.3.1
@@ -1,3 +0,1 @@ | ||
/// <reference path="./src/fetch.d.ts" /> | ||
export * from './src/console'; | ||
@@ -4,0 +2,0 @@ export * from './src/data'; |
{ | ||
"name": "@travetto/base", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "Environment config and common utilities for travetto applications.", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@travetto/manifest": "^3.3.0", | ||
"@travetto/manifest": "^3.3.1", | ||
"@types/source-map-support": "^0.5.6", | ||
@@ -32,0 +32,0 @@ "source-map-support": "^0.5.21" |
@@ -91,3 +91,3 @@ <!-- This file was generated by @travetto/doc and should not be modified directly --> | ||
NODE_ENV: detectNodeEnv(envName), | ||
DEBUG: envName !== TEST ? (cfg.debug ?? GlobalEnv.debug) : false, | ||
DEBUG: envName !== TEST ? (cfg.debug ?? GlobalEnv.debug ?? false) : false, | ||
TRV_ENV: envName, | ||
@@ -94,0 +94,0 @@ TRV_DYNAMIC: cfg.dynamic ?? GlobalEnv.dynamic, |
import fs from 'fs/promises'; | ||
import { createWriteStream, createReadStream } from 'fs'; | ||
import { PassThrough, Readable, Writable } from 'stream'; | ||
import { ReadableStream as WebReadableStream } from 'stream/web'; | ||
import rl from 'readline'; | ||
@@ -9,5 +10,4 @@ | ||
import type { ExecutionState } from './exec'; | ||
import type { _Fetch } from './fetch'; | ||
type All = Buffer | string | Readable | Uint8Array | NodeJS.ReadableStream | _Fetch.ReadableStream; | ||
type All = Buffer | string | Readable | Uint8Array | NodeJS.ReadableStream | WebReadableStream; | ||
@@ -20,25 +20,2 @@ /** | ||
/** | ||
* Convert a fetch/ReadableStream into a standard node Readable | ||
* @param src | ||
* @returns | ||
*/ | ||
static fetchBodyToStream(src: _Fetch.ReadableStream): Readable { | ||
const reader = src.getReader(); | ||
return new Readable({ | ||
read(): void { | ||
reader.read().then(({ done, value }) => { | ||
if (value) { | ||
this.push(value); | ||
} | ||
if (done) { | ||
this.push(null); | ||
} | ||
}); | ||
}, | ||
emitClose: true | ||
}); | ||
} | ||
/** | ||
* Convert buffer to a stream | ||
@@ -57,5 +34,5 @@ * @param src The buffer to stream | ||
*/ | ||
static async streamToBuffer(src: Readable | NodeJS.ReadableStream | _Fetch.ReadableStream): Promise<Buffer> { | ||
static async streamToBuffer(src: Readable | NodeJS.ReadableStream | WebReadableStream): Promise<Buffer> { | ||
if ('getReader' in src) { | ||
return this.streamToBuffer(this.fetchBodyToStream(src)); | ||
return this.streamToBuffer(Readable.fromWeb(src)); | ||
} | ||
@@ -97,3 +74,3 @@ return new Promise<Buffer>((res, rej) => { | ||
} else if (typeof src !== 'string' && 'getReader' in src) { | ||
return this.fetchBodyToStream(src); | ||
return Readable.fromWeb(src); | ||
} else { | ||
@@ -100,0 +77,0 @@ return this.bufferToStream(await this.toBuffer(src)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103005
24
2230
Updated@travetto/manifest@^3.3.1