@nxtedition/lib 14.1.3 → 14.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/stream.js +23 -0
- package/undici.js +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "14.1.
|
|
3
|
+
"version": "14.1.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"files": [
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"errors.js",
|
|
24
24
|
"worker.js",
|
|
25
25
|
"proxy.js",
|
|
26
|
+
"stream.js",
|
|
26
27
|
"undici.js",
|
|
27
28
|
"timeline.js",
|
|
28
29
|
"docker-secrets.js"
|
package/stream.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function isReadableNodeStream(obj, strict = false) {
|
|
2
|
+
return !!(
|
|
3
|
+
(
|
|
4
|
+
obj &&
|
|
5
|
+
typeof obj.pipe === 'function' &&
|
|
6
|
+
typeof obj.on === 'function' &&
|
|
7
|
+
(!strict || (typeof obj.pause === 'function' && typeof obj.resume === 'function')) &&
|
|
8
|
+
(!obj._writableState || obj._readableState?.readable !== false) && // Duplex
|
|
9
|
+
(!obj._writableState || obj._readableState)
|
|
10
|
+
) // Writable has .pipe.
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isStream(obj) {
|
|
15
|
+
return (
|
|
16
|
+
obj && typeof obj === 'object' && typeof obj.pipe === 'function' && typeof obj.on === 'function'
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = {
|
|
21
|
+
isStream,
|
|
22
|
+
isReadableNodeStream,
|
|
23
|
+
}
|
package/undici.js
CHANGED
|
@@ -64,6 +64,14 @@ module.exports.request = async function request(
|
|
|
64
64
|
|
|
65
65
|
assert(ures.statusCode >= 200 && ures.statusCode < 300)
|
|
66
66
|
|
|
67
|
+
if (method === 'HEAD' || method === 'DELETE' || method === 'OPTIONS') {
|
|
68
|
+
await ures.body.dump()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (ures.headers['content-length'] === '0') {
|
|
72
|
+
await ures.body.dump()
|
|
73
|
+
}
|
|
74
|
+
|
|
67
75
|
// TODO (fix): Wrap response to handle error that can continue with range request...
|
|
68
76
|
|
|
69
77
|
return ures
|