balena-request
Advanced tools
Comparing version 11.0.4 to 11.1.0-lazy-loading-45042aca602e44a8e4eefdf0fb57ab188530a48e
@@ -20,6 +20,2 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const webStreams = require("@balena/node-web-streams"); | ||
const progress = require("progress-stream"); | ||
const zlib = require("zlib"); | ||
const stream = require("stream"); | ||
const utils = require("./utils"); | ||
@@ -45,2 +41,3 @@ /** | ||
const getProgressStream = function (total, onState) { | ||
const progress = require('progress-stream'); | ||
const progressStream = progress({ | ||
@@ -100,3 +97,3 @@ time: 500, | ||
const response = yield requestAsync(options); | ||
let responseStream; | ||
const stream = require('stream'); | ||
const output = new stream.PassThrough(); | ||
@@ -107,3 +104,5 @@ // @ts-expect-error | ||
const total = responseLength.uncompressed || responseLength.compressed; | ||
let responseStream; | ||
if (response.body.getReader) { | ||
const webStreams = require('@balena/node-web-streams'); | ||
// Convert browser (WHATWG) streams to Node streams | ||
@@ -118,3 +117,4 @@ responseStream = webStreams.toNodeReadable(response.body); | ||
if (!isBrowser && utils.isResponseCompressed(response)) { | ||
const gunzip = zlib.createGunzip(); | ||
const { createGunzip } = require('zlib'); | ||
const gunzip = createGunzip(); | ||
// Uncompress after or before piping through progress | ||
@@ -121,0 +121,0 @@ // depending on the response length available to us |
@@ -24,6 +24,4 @@ "use strict"; | ||
const urlLib = require("url"); | ||
const fetchReadableStream = require("fetch-readablestream"); | ||
const errors = require("balena-errors"); | ||
const utils = require("./utils"); | ||
const progress = require("./progress"); | ||
/** | ||
@@ -39,3 +37,5 @@ * @param {object} options | ||
const requestAsync = utils.getRequestAsync(); | ||
const requestBrowserStream = utils.getRequestAsync(fetchReadableStream); | ||
const requestStream = isBrowser | ||
? utils.getRequestAsync(require('fetch-readablestream')) | ||
: requestAsync; | ||
const debugRequest = !debug | ||
@@ -232,3 +232,3 @@ ? function () { | ||
exports.stream = function (options) { | ||
const requestStream = isBrowser ? requestBrowserStream : requestAsync; | ||
const progress = require('./progress'); | ||
return prepareOptions(options) | ||
@@ -235,0 +235,0 @@ .then(interceptRequestOptions, interceptRequestError) |
@@ -7,2 +7,7 @@ # Change Log | ||
# v11.1.0 | ||
## (2020-07-16) | ||
* Add lazy loading for most modules [Pagan Gazzard] | ||
# v11.0.4 | ||
@@ -9,0 +14,0 @@ ## (2020-07-14) |
@@ -17,7 +17,2 @@ /* | ||
import * as webStreams from '@balena/node-web-streams'; | ||
import * as progress from 'progress-stream'; | ||
import * as zlib from 'zlib'; | ||
import * as stream from 'stream'; | ||
import * as utils from './utils'; | ||
@@ -45,2 +40,3 @@ | ||
const getProgressStream = function (total, onState) { | ||
const progress = require('progress-stream'); | ||
const progressStream = progress({ | ||
@@ -112,3 +108,3 @@ time: 500, | ||
let responseStream; | ||
const stream = require('stream'); | ||
const output = new stream.PassThrough(); | ||
@@ -121,3 +117,5 @@ // @ts-expect-error | ||
let responseStream; | ||
if (response.body.getReader) { | ||
const webStreams = require('@balena/node-web-streams'); | ||
// Convert browser (WHATWG) streams to Node streams | ||
@@ -135,3 +133,4 @@ responseStream = webStreams.toNodeReadable(response.body); | ||
if (!isBrowser && utils.isResponseCompressed(response)) { | ||
const gunzip = zlib.createGunzip(); | ||
const { createGunzip } = require('zlib'); | ||
const gunzip = createGunzip(); | ||
@@ -138,0 +137,0 @@ // Uncompress after or before piping through progress |
@@ -22,6 +22,4 @@ /* | ||
import * as urlLib from 'url'; | ||
import * as fetchReadableStream from 'fetch-readablestream'; | ||
import * as errors from 'balena-errors'; | ||
import * as utils from './utils'; | ||
import * as progress from './progress'; | ||
@@ -44,3 +42,5 @@ /** | ||
const requestAsync = utils.getRequestAsync(); | ||
const requestBrowserStream = utils.getRequestAsync(fetchReadableStream); | ||
const requestStream = isBrowser | ||
? utils.getRequestAsync(require('fetch-readablestream')) | ||
: requestAsync; | ||
@@ -266,4 +266,3 @@ const debugRequest = !debug | ||
exports.stream = function (options) { | ||
const requestStream = isBrowser ? requestBrowserStream : requestAsync; | ||
const progress = require('./progress'); | ||
return prepareOptions(options) | ||
@@ -270,0 +269,0 @@ .then(interceptRequestOptions, interceptRequestError) |
{ | ||
"name": "balena-request", | ||
"version": "11.0.4", | ||
"version": "11.1.0-lazy-loading-45042aca602e44a8e4eefdf0fb57ab188530a48e", | ||
"description": "Balena HTTP client", | ||
@@ -5,0 +5,0 @@ "main": "build/request.js", |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
166804
12263
1