node-datachannel 0.2.3 → 0.2.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/.github/workflows/build-linux.yml +2 -0
- package/CMakeLists.txt +2 -2
- package/lib/datachannel-stream.js +86 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +3 -1
- package/node_modules/decompress-response/index.d.ts +14 -21
- package/node_modules/decompress-response/index.js +34 -16
- package/node_modules/decompress-response/license +1 -1
- package/node_modules/decompress-response/package.json +23 -17
- package/node_modules/decompress-response/readme.md +2 -6
- package/node_modules/detect-libc/README.md +124 -42
- package/node_modules/detect-libc/index.d.ts +11 -0
- package/node_modules/detect-libc/lib/detect-libc.js +166 -80
- package/node_modules/detect-libc/lib/process.js +16 -0
- package/node_modules/detect-libc/package.json +20 -20
- package/node_modules/{semver → lru-cache}/LICENSE +0 -0
- package/node_modules/lru-cache/README.md +166 -0
- package/node_modules/lru-cache/index.js +334 -0
- package/node_modules/lru-cache/node_modules/yallist/LICENSE +15 -0
- package/node_modules/lru-cache/node_modules/yallist/README.md +204 -0
- package/node_modules/lru-cache/node_modules/yallist/iterator.js +8 -0
- package/node_modules/lru-cache/node_modules/yallist/package.json +65 -0
- package/node_modules/lru-cache/node_modules/yallist/yallist.js +426 -0
- package/node_modules/lru-cache/package.json +74 -0
- package/node_modules/mimic-response/index.d.ts +2 -2
- package/node_modules/mimic-response/index.js +41 -2
- package/node_modules/mimic-response/package.json +17 -17
- package/node_modules/mimic-response/readme.md +22 -1
- package/node_modules/node-abi/.circleci/config.yml +63 -0
- package/node_modules/node-abi/.releaserc.json +9 -0
- package/node_modules/node-abi/abi_registry.json +45 -3
- package/node_modules/node-abi/index.js +5 -2
- package/node_modules/node-abi/node_modules/semver/CHANGELOG.md +111 -0
- package/node_modules/node-abi/node_modules/semver/LICENSE +15 -0
- package/node_modules/{semver → node-abi/node_modules/semver}/README.md +180 -26
- package/node_modules/node-abi/node_modules/semver/bin/semver.js +173 -0
- package/node_modules/node-abi/node_modules/semver/classes/comparator.js +135 -0
- package/node_modules/node-abi/node_modules/semver/classes/index.js +5 -0
- package/node_modules/node-abi/node_modules/semver/classes/range.js +510 -0
- package/node_modules/node-abi/node_modules/semver/classes/semver.js +287 -0
- package/node_modules/node-abi/node_modules/semver/functions/clean.js +6 -0
- package/node_modules/node-abi/node_modules/semver/functions/cmp.js +48 -0
- package/node_modules/node-abi/node_modules/semver/functions/coerce.js +51 -0
- package/node_modules/node-abi/node_modules/semver/functions/compare-build.js +7 -0
- package/node_modules/node-abi/node_modules/semver/functions/compare-loose.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/compare.js +5 -0
- package/node_modules/node-abi/node_modules/semver/functions/diff.js +23 -0
- package/node_modules/node-abi/node_modules/semver/functions/eq.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/gt.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/gte.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/inc.js +15 -0
- package/node_modules/node-abi/node_modules/semver/functions/lt.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/lte.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/major.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/minor.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/neq.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/parse.js +33 -0
- package/node_modules/node-abi/node_modules/semver/functions/patch.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/prerelease.js +6 -0
- package/node_modules/node-abi/node_modules/semver/functions/rcompare.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/rsort.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/satisfies.js +10 -0
- package/node_modules/node-abi/node_modules/semver/functions/sort.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/valid.js +6 -0
- package/node_modules/node-abi/node_modules/semver/index.js +48 -0
- package/node_modules/node-abi/node_modules/semver/internal/constants.js +17 -0
- package/node_modules/node-abi/node_modules/semver/internal/debug.js +9 -0
- package/node_modules/node-abi/node_modules/semver/internal/identifiers.js +23 -0
- package/node_modules/node-abi/node_modules/semver/internal/parse-options.js +11 -0
- package/node_modules/node-abi/node_modules/semver/internal/re.js +182 -0
- package/node_modules/{semver → node-abi/node_modules/semver}/package.json +32 -23
- package/node_modules/node-abi/node_modules/semver/preload.js +2 -0
- package/node_modules/{semver → node-abi/node_modules/semver}/range.bnf +0 -0
- package/node_modules/node-abi/node_modules/semver/ranges/gtr.js +4 -0
- package/node_modules/node-abi/node_modules/semver/ranges/intersects.js +7 -0
- package/node_modules/node-abi/node_modules/semver/ranges/ltr.js +4 -0
- package/node_modules/node-abi/node_modules/semver/ranges/max-satisfying.js +25 -0
- package/node_modules/node-abi/node_modules/semver/ranges/min-satisfying.js +24 -0
- package/node_modules/node-abi/node_modules/semver/ranges/min-version.js +60 -0
- package/node_modules/node-abi/node_modules/semver/ranges/outside.js +80 -0
- package/node_modules/node-abi/node_modules/semver/ranges/simplify.js +44 -0
- package/node_modules/node-abi/node_modules/semver/ranges/subset.js +222 -0
- package/node_modules/node-abi/node_modules/semver/ranges/to-comparators.js +8 -0
- package/node_modules/node-abi/node_modules/semver/ranges/valid.js +11 -0
- package/node_modules/node-abi/package.json +20 -17
- package/node_modules/node-abi/test/index.js +7 -15
- package/node_modules/prebuild-install/CHANGELOG.md +24 -7
- package/node_modules/prebuild-install/README.md +24 -4
- package/node_modules/prebuild-install/asset.js +10 -10
- package/node_modules/prebuild-install/bin.js +13 -13
- package/node_modules/prebuild-install/download.js +22 -22
- package/node_modules/prebuild-install/log.js +4 -4
- package/node_modules/prebuild-install/package.json +18 -19
- package/node_modules/prebuild-install/proxy.js +10 -10
- package/node_modules/prebuild-install/rc.js +12 -12
- package/node_modules/prebuild-install/util.js +14 -14
- package/node_modules/simple-get/.github/dependabot.yml +15 -0
- package/node_modules/simple-get/.github/workflows/ci.yml +23 -0
- package/node_modules/simple-get/README.md +17 -3
- package/node_modules/simple-get/index.js +9 -0
- package/node_modules/simple-get/package.json +27 -13
- package/package.json +6 -5
- package/test/test.js +45 -0
- package/node_modules/detect-libc/.npmignore +0 -7
- package/node_modules/detect-libc/bin/detect-libc.js +0 -18
- package/node_modules/node-abi/.travis.yml +0 -17
- package/node_modules/semver/CHANGELOG.md +0 -39
- package/node_modules/semver/bin/semver +0 -160
- package/node_modules/semver/semver.js +0 -1483
|
@@ -45,6 +45,7 @@ jobs:
|
|
|
45
45
|
- uses: actions/checkout@v2
|
|
46
46
|
- name: Prepare Cross Compile
|
|
47
47
|
run: |
|
|
48
|
+
sudo apt update
|
|
48
49
|
sudo apt install -y g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf
|
|
49
50
|
mkdir sysroot && cd sysroot
|
|
50
51
|
wget https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/ef5c4f84bcafb7a3796d36bb1db7826317dde51c/debian_sid_arm_sysroot.tar.xz
|
|
@@ -72,6 +73,7 @@ jobs:
|
|
|
72
73
|
- uses: actions/checkout@v2
|
|
73
74
|
- name: Prepare Cross Compile
|
|
74
75
|
run: |
|
|
76
|
+
sudo apt update
|
|
75
77
|
sudo apt install -y g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
|
|
76
78
|
mkdir sysroot && cd sysroot
|
|
77
79
|
wget https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/953c2471bc7e71a788309f6c2d2003e8b703305d/debian_sid_arm64_sysroot.tar.xz
|
package/CMakeLists.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
cmake_minimum_required(VERSION 3.15)
|
|
2
2
|
cmake_policy(SET CMP0091 NEW)
|
|
3
|
-
project(node_datachannel VERSION 0.2.
|
|
3
|
+
project(node_datachannel VERSION 0.2.4)
|
|
4
4
|
|
|
5
5
|
include_directories(${CMAKE_JS_INC})
|
|
6
6
|
|
|
@@ -27,7 +27,7 @@ include(FetchContent)
|
|
|
27
27
|
FetchContent_Declare(
|
|
28
28
|
libdatachannel
|
|
29
29
|
GIT_REPOSITORY https://github.com/paullouisageneau/libdatachannel.git
|
|
30
|
-
GIT_TAG "v0.16.
|
|
30
|
+
GIT_TAG "v0.16.6"
|
|
31
31
|
)
|
|
32
32
|
|
|
33
33
|
option(NO_MEDIA "Disable media transport support in libdatachannel" OFF)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const stream = require('stream');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Turns a node-datachannel DataChannel into a real Node.js stream, complete with buffering,
|
|
5
|
+
* backpressure (up to a point - if the buffer fills up, messages are dropped), and
|
|
6
|
+
* support for piping data elsewhere.
|
|
7
|
+
*
|
|
8
|
+
* Read & written data may be either UTF-8 strings or Buffers - this difference exists at
|
|
9
|
+
* the protocol level, and is preserved here throughout.
|
|
10
|
+
*/
|
|
11
|
+
module.exports = class DataChannelStream extends stream.Duplex {
|
|
12
|
+
|
|
13
|
+
constructor(rawChannel, streamOptions) {
|
|
14
|
+
super({
|
|
15
|
+
allowHalfOpen: false, // Default to autoclose on end().
|
|
16
|
+
...streamOptions,
|
|
17
|
+
objectMode: true // Preserve the string/buffer distinction (WebRTC treats them differently)
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
this._rawChannel = rawChannel;
|
|
21
|
+
this._readActive = true;
|
|
22
|
+
|
|
23
|
+
rawChannel.onMessage((msg) => {
|
|
24
|
+
if (!this._readActive) return; // If the buffer is full, drop messages.
|
|
25
|
+
|
|
26
|
+
// If the push is rejected, we pause reading until the next call to _read().
|
|
27
|
+
this._readActive = this.push(msg);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// When the DataChannel closes, the readable & writable ends close
|
|
31
|
+
rawChannel.onClosed(() => {
|
|
32
|
+
this.push(null);
|
|
33
|
+
this.destroy();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
rawChannel.onError((errMsg) => {
|
|
37
|
+
this.destroy(new Error(`DataChannel error: ${errMsg}`));
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Buffer all writes until the DataChannel opens
|
|
41
|
+
if (!rawChannel.isOpen()) {
|
|
42
|
+
this.cork();
|
|
43
|
+
rawChannel.onOpen(() => this.uncork());
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_read() {
|
|
48
|
+
// Stop dropping messages, if the buffer filling up meant we were doing so before.
|
|
49
|
+
this._readActive = true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_write(chunk, encoding, callback) {
|
|
53
|
+
let sentOk;
|
|
54
|
+
if (Buffer.isBuffer(chunk)) {
|
|
55
|
+
sentOk = this._rawChannel.sendMessageBinary(chunk);
|
|
56
|
+
} else if (typeof chunk === 'string') {
|
|
57
|
+
sentOk = this._rawChannel.sendMessage(chunk);
|
|
58
|
+
} else {
|
|
59
|
+
const typeName = chunk.constructor.name || typeof chunk;
|
|
60
|
+
callback(new Error(`Cannot write ${typeName} to DataChannel stream`));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (sentOk) {
|
|
65
|
+
callback(null);
|
|
66
|
+
} else {
|
|
67
|
+
callback(new Error("Failed to write to DataChannel"));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_final(callback) {
|
|
72
|
+
if (!this.allowHalfOpen) this.destroy();
|
|
73
|
+
callback(null);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_destroy(maybeErr, callback) {
|
|
77
|
+
// When the stream is destroyed, we close the DataChannel.
|
|
78
|
+
this._rawChannel.close();
|
|
79
|
+
callback(maybeErr);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get label() {
|
|
83
|
+
return this._rawChannel.getLabel();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as stream from 'stream';
|
|
2
|
+
|
|
1
3
|
export as namespace NodeDataChannel;
|
|
2
4
|
|
|
3
5
|
// Enum in d.ts is tricky
|
|
@@ -220,3 +222,11 @@ export class PeerConnection {
|
|
|
220
222
|
rtt: () => number;
|
|
221
223
|
getSelectedCandidatePair: () => { local: SelectedCandidateInfo, remote: SelectedCandidateInfo } | null;
|
|
222
224
|
}
|
|
225
|
+
|
|
226
|
+
export class DataChannelStream extends stream.Duplex {
|
|
227
|
+
constructor(
|
|
228
|
+
rawChannel: DataChannel,
|
|
229
|
+
options?: Omit<stream.DuplexOptions, 'objectMode'>
|
|
230
|
+
);
|
|
231
|
+
get label(): string;
|
|
232
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
/// <reference types="node"/>
|
|
2
2
|
import {IncomingMessage} from 'http';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Decompress a HTTP response if needed.
|
|
4
|
+
/**
|
|
5
|
+
Decompress a HTTP response if needed.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
@param response - The HTTP incoming stream with compressed data.
|
|
8
|
+
@returns The decompressed HTTP response stream.
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
@example
|
|
11
|
+
```
|
|
12
|
+
import {http} from 'http';
|
|
13
|
+
import decompressResponse = require('decompress-response');
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// TODO: remove this in the next major version, refactor the whole definition to:
|
|
24
|
-
// declare function decompressResponse(response: IncomingMessage): IncomingMessage;
|
|
25
|
-
// export = decompressResponse;
|
|
26
|
-
default: typeof decompressResponse;
|
|
27
|
-
};
|
|
15
|
+
http.get('https://sindresorhus.com', response => {
|
|
16
|
+
response = decompressResponse(response);
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
*/
|
|
20
|
+
declare function decompressResponse(response: IncomingMessage): IncomingMessage;
|
|
28
21
|
|
|
29
22
|
export = decompressResponse;
|
|
@@ -1,40 +1,58 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const {PassThrough
|
|
2
|
+
const {Transform, PassThrough} = require('stream');
|
|
3
3
|
const zlib = require('zlib');
|
|
4
4
|
const mimicResponse = require('mimic-response');
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
module.exports = response => {
|
|
7
7
|
const contentEncoding = (response.headers['content-encoding'] || '').toLowerCase();
|
|
8
8
|
|
|
9
9
|
if (!['gzip', 'deflate', 'br'].includes(contentEncoding)) {
|
|
10
10
|
return response;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
// TODO: Remove this when targeting Node.js 12.
|
|
13
14
|
const isBrotli = contentEncoding === 'br';
|
|
14
15
|
if (isBrotli && typeof zlib.createBrotliDecompress !== 'function') {
|
|
16
|
+
response.destroy(new Error('Brotli is not supported on Node.js < 12'));
|
|
15
17
|
return response;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
const stream = new PassThroughStream();
|
|
20
|
+
let isEmpty = true;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
const checker = new Transform({
|
|
23
|
+
transform(data, _encoding, callback) {
|
|
24
|
+
isEmpty = false;
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
callback(null, data);
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
flush(callback) {
|
|
30
|
+
callback();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const finalStream = new PassThrough({
|
|
35
|
+
autoDestroy: false,
|
|
36
|
+
destroy(error, callback) {
|
|
37
|
+
response.destroy();
|
|
38
|
+
|
|
39
|
+
callback(error);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const decompressStream = isBrotli ? zlib.createBrotliDecompress() : zlib.createUnzip();
|
|
44
|
+
|
|
45
|
+
decompressStream.once('error', error => {
|
|
46
|
+
if (isEmpty && !response.readable) {
|
|
47
|
+
finalStream.end();
|
|
27
48
|
return;
|
|
28
49
|
}
|
|
29
50
|
|
|
30
|
-
|
|
51
|
+
finalStream.destroy(error);
|
|
31
52
|
});
|
|
32
53
|
|
|
33
|
-
response
|
|
54
|
+
mimicResponse(response, finalStream);
|
|
55
|
+
response.pipe(checker).pipe(decompressStream).pipe(finalStream);
|
|
34
56
|
|
|
35
|
-
return
|
|
57
|
+
return finalStream;
|
|
36
58
|
};
|
|
37
|
-
|
|
38
|
-
module.exports = decompressResponse;
|
|
39
|
-
// TODO: remove this in the next major version
|
|
40
|
-
module.exports.default = decompressResponse;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
|
@@ -1,59 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_args": [
|
|
3
3
|
[
|
|
4
|
-
"decompress-response@
|
|
4
|
+
"decompress-response@6.0.0",
|
|
5
5
|
"/home/runner/work/node-datachannel/node-datachannel"
|
|
6
6
|
]
|
|
7
7
|
],
|
|
8
|
-
"_from": "decompress-response@
|
|
9
|
-
"_id": "decompress-response@
|
|
8
|
+
"_from": "decompress-response@6.0.0",
|
|
9
|
+
"_id": "decompress-response@6.0.0",
|
|
10
10
|
"_inBundle": false,
|
|
11
|
-
"_integrity": "sha512-
|
|
11
|
+
"_integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
|
|
12
12
|
"_location": "/decompress-response",
|
|
13
13
|
"_phantomChildren": {},
|
|
14
14
|
"_requested": {
|
|
15
15
|
"type": "version",
|
|
16
16
|
"registry": true,
|
|
17
|
-
"raw": "decompress-response@
|
|
17
|
+
"raw": "decompress-response@6.0.0",
|
|
18
18
|
"name": "decompress-response",
|
|
19
19
|
"escapedName": "decompress-response",
|
|
20
|
-
"rawSpec": "
|
|
20
|
+
"rawSpec": "6.0.0",
|
|
21
21
|
"saveSpec": null,
|
|
22
|
-
"fetchSpec": "
|
|
22
|
+
"fetchSpec": "6.0.0"
|
|
23
23
|
},
|
|
24
24
|
"_requiredBy": [
|
|
25
25
|
"/simple-get"
|
|
26
26
|
],
|
|
27
|
-
"_resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-
|
|
28
|
-
"_spec": "
|
|
27
|
+
"_resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
|
|
28
|
+
"_spec": "6.0.0",
|
|
29
29
|
"_where": "/home/runner/work/node-datachannel/node-datachannel",
|
|
30
30
|
"author": {
|
|
31
31
|
"name": "Sindre Sorhus",
|
|
32
32
|
"email": "sindresorhus@gmail.com",
|
|
33
|
-
"url": "sindresorhus.com"
|
|
33
|
+
"url": "https://sindresorhus.com"
|
|
34
34
|
},
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/sindresorhus/decompress-response/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"mimic-response": "^
|
|
39
|
+
"mimic-response": "^3.1.0"
|
|
40
40
|
},
|
|
41
41
|
"description": "Decompress a HTTP response if needed",
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^
|
|
43
|
+
"@types/node": "^14.0.1",
|
|
44
44
|
"ava": "^2.2.0",
|
|
45
45
|
"get-stream": "^5.0.0",
|
|
46
|
-
"pify": "^
|
|
47
|
-
"tsd": "^0.
|
|
48
|
-
"xo": "^0.
|
|
46
|
+
"pify": "^5.0.0",
|
|
47
|
+
"tsd": "^0.11.0",
|
|
48
|
+
"xo": "^0.30.0"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
51
|
+
"node": ">=10"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|
|
54
54
|
"index.js",
|
|
55
55
|
"index.d.ts"
|
|
56
56
|
],
|
|
57
|
+
"funding": "https://github.com/sponsors/sindresorhus",
|
|
57
58
|
"homepage": "https://github.com/sindresorhus/decompress-response#readme",
|
|
58
59
|
"keywords": [
|
|
59
60
|
"decompress",
|
|
@@ -81,5 +82,10 @@
|
|
|
81
82
|
"scripts": {
|
|
82
83
|
"test": "xo && ava && tsd"
|
|
83
84
|
},
|
|
84
|
-
"version": "
|
|
85
|
+
"version": "6.0.0",
|
|
86
|
+
"xo": {
|
|
87
|
+
"rules": {
|
|
88
|
+
"@typescript-eslint/prefer-readonly-parameter-types": "off"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
85
91
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# decompress-response [](https://travis-ci.com/sindresorhus/decompress-response)
|
|
2
2
|
|
|
3
3
|
> Decompress a HTTP response if needed
|
|
4
4
|
|
|
@@ -6,14 +6,12 @@ Decompresses the [response](https://nodejs.org/api/http.html#http_class_http_inc
|
|
|
6
6
|
|
|
7
7
|
Used by [`got`](https://github.com/sindresorhus/got).
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
## Install
|
|
11
10
|
|
|
12
11
|
```
|
|
13
12
|
$ npm install decompress-response
|
|
14
13
|
```
|
|
15
14
|
|
|
16
|
-
|
|
17
15
|
## Usage
|
|
18
16
|
|
|
19
17
|
```js
|
|
@@ -25,7 +23,6 @@ http.get('https://sindresorhus.com', response => {
|
|
|
25
23
|
});
|
|
26
24
|
```
|
|
27
25
|
|
|
28
|
-
|
|
29
26
|
## API
|
|
30
27
|
|
|
31
28
|
### decompressResponse(response)
|
|
@@ -38,12 +35,11 @@ Type: [`http.IncomingMessage`](https://nodejs.org/api/http.html#http_class_http_
|
|
|
38
35
|
|
|
39
36
|
The HTTP incoming stream with compressed data.
|
|
40
37
|
|
|
41
|
-
|
|
42
38
|
---
|
|
43
39
|
|
|
44
40
|
<div align="center">
|
|
45
41
|
<b>
|
|
46
|
-
<a href="https://tidelift.com/subscription/pkg/npm-
|
|
42
|
+
<a href="https://tidelift.com/subscription/pkg/npm-decompress-response?utm_source=npm-decompress-response&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
|
47
43
|
</b>
|
|
48
44
|
<br>
|
|
49
45
|
<sub>
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
# detect-libc
|
|
2
2
|
|
|
3
|
-
Node.js module to detect the C standard library (libc)
|
|
4
|
-
|
|
3
|
+
Node.js module to detect details of the C standard library (libc)
|
|
4
|
+
implementation provided by a given Linux system.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
[prebuild](https://www.npmjs.com/package/prebuild),
|
|
8
|
-
[prebuild-ci](https://www.npmjs.com/package/prebuild-ci) and
|
|
9
|
-
[prebuild-install](https://www.npmjs.com/package/prebuild-install),
|
|
10
|
-
therefore allowing build and provision of pre-compiled binaries
|
|
11
|
-
for musl-based Linux e.g. Alpine as well as glibc-based.
|
|
6
|
+
Currently supports detection of GNU glibc and MUSL libc.
|
|
12
7
|
|
|
13
|
-
|
|
8
|
+
Provides asychronous and synchronous functions for the
|
|
9
|
+
family (e.g. `glibc`, `musl`) and version (e.g. `1.23`, `1.2.3`).
|
|
10
|
+
|
|
11
|
+
For previous v1.x releases, please see the
|
|
12
|
+
[v1](https://github.com/lovell/detect-libc/tree/v1) branch.
|
|
14
13
|
|
|
15
14
|
## Install
|
|
16
15
|
|
|
@@ -18,54 +17,137 @@ Currently supports libc detection of `glibc` and `musl`.
|
|
|
18
17
|
npm install detect-libc
|
|
19
18
|
```
|
|
20
19
|
|
|
21
|
-
##
|
|
20
|
+
## API
|
|
21
|
+
|
|
22
|
+
### GLIBC
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
const GLIBC: string = 'glibc';
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
A String constant containing the value `glibc`.
|
|
29
|
+
|
|
30
|
+
### MUSL
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
const MUSL: string = 'musl';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
A String constant containing the value `musl`.
|
|
37
|
+
|
|
38
|
+
### family
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
function family(): Promise<string | null>;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Resolves asychronously with:
|
|
22
45
|
|
|
23
|
-
|
|
46
|
+
* `glibc` or `musl` when the libc family can be determined
|
|
47
|
+
* `null` when the libc family cannot be determined
|
|
48
|
+
* `null` when run on a non-Linux platform
|
|
24
49
|
|
|
25
50
|
```js
|
|
26
|
-
const {
|
|
51
|
+
const { family, GLIBC, MUSL } = require('detect-libc');
|
|
52
|
+
|
|
53
|
+
switch (await family()) {
|
|
54
|
+
case GLIBC: ...
|
|
55
|
+
case MUSL: ...
|
|
56
|
+
case null: ...
|
|
57
|
+
}
|
|
27
58
|
```
|
|
28
59
|
|
|
29
|
-
|
|
30
|
-
* `MUSL` is a String containing the value "musl" for comparison with `family`.
|
|
31
|
-
* `family` is a String representing the system libc family.
|
|
32
|
-
* `version` is a String representing the system libc version number.
|
|
33
|
-
* `isNonGlibcLinux` is a Boolean representing whether the system is a non-glibc Linux, e.g. Alpine.
|
|
60
|
+
### familySync
|
|
34
61
|
|
|
35
|
-
|
|
62
|
+
```ts
|
|
63
|
+
function familySync(): string | null;
|
|
64
|
+
```
|
|
36
65
|
|
|
37
|
-
|
|
38
|
-
the child command will be run with the `LIBC` environment variable
|
|
39
|
-
set to the relevant value.
|
|
66
|
+
Synchronous version of `family()`.
|
|
40
67
|
|
|
41
|
-
|
|
68
|
+
```js
|
|
69
|
+
const { familySync, GLIBC, MUSL } = require('detect-libc');
|
|
42
70
|
|
|
43
|
-
|
|
71
|
+
switch (familySync()) {
|
|
72
|
+
case GLIBC: ...
|
|
73
|
+
case MUSL: ...
|
|
74
|
+
case null: ...
|
|
75
|
+
}
|
|
76
|
+
```
|
|
44
77
|
|
|
45
|
-
|
|
46
|
-
|
|
78
|
+
### version
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
function version(): Promise<string | null>;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Resolves asychronously with:
|
|
85
|
+
|
|
86
|
+
* The version when it can be determined
|
|
87
|
+
* `null` when the libc family cannot be determined
|
|
88
|
+
* `null` when run on a non-Linux platform
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
const { version } = require('detect-libc');
|
|
92
|
+
|
|
93
|
+
const v = await version();
|
|
94
|
+
if (v) {
|
|
95
|
+
const [major, minor, patch] = v.split('.');
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### versionSync
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
function versionSync(): string | null;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Synchronous version of `version()`.
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
const { versionSync } = require('detect-libc');
|
|
109
|
+
|
|
110
|
+
const v = versionSync();
|
|
111
|
+
if (v) {
|
|
112
|
+
const [major, minor, patch] = v.split('.');
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### isNonGlibcLinux
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
function isNonGlibcLinux(): Promise<boolean>;
|
|
47
120
|
```
|
|
48
121
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
122
|
+
Resolves asychronously with:
|
|
123
|
+
|
|
124
|
+
* `false` when the libc family is `glibc`
|
|
125
|
+
* `true` when the libc family is not `glibc`
|
|
126
|
+
* `false` when run on a non-Linux platform
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
const { isNonGlibcLinux } = require('detect-libc');
|
|
130
|
+
|
|
131
|
+
if (await isNonGlibcLinux()) { ... }
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### isNonGlibcLinuxSync
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
function isNonGlibcLinuxSync(): boolean;
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Synchronous version of `isNonGlibcLinux()`.
|
|
141
|
+
|
|
142
|
+
```js
|
|
143
|
+
const { isNonGlibcLinuxSync } = require('detect-libc');
|
|
144
|
+
|
|
145
|
+
if (isNonGlibcLinuxSync()) { ... }
|
|
64
146
|
```
|
|
65
147
|
|
|
66
|
-
##
|
|
148
|
+
## Licensing
|
|
67
149
|
|
|
68
|
-
Copyright 2017 Lovell Fuller
|
|
150
|
+
Copyright 2017, 2022 Lovell Fuller
|
|
69
151
|
|
|
70
152
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
71
153
|
you may not use this file except in compliance with the License.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const GLIBC: 'glibc';
|
|
2
|
+
export const MUSL: 'musl';
|
|
3
|
+
|
|
4
|
+
export function family(): Promise<string | null>;
|
|
5
|
+
export function familySync(): string | null;
|
|
6
|
+
|
|
7
|
+
export function isNonGlibcLinux(): Promise<boolean>;
|
|
8
|
+
export function isNonGlibcLinuxSync(): boolean;
|
|
9
|
+
|
|
10
|
+
export function version(): Promise<string | null>;
|
|
11
|
+
export function versionSync(): string | null;
|