Spaces:
Paused
Paused
Upload folder using huggingface_hub (part 9)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- node_modules/decimal.js/decimal.mjs +0 -0
- node_modules/decimal.js/package.json +55 -0
- node_modules/decompress-response/index.d.ts +22 -0
- node_modules/decompress-response/index.js +58 -0
- node_modules/decompress-response/license +9 -0
- node_modules/decompress-response/package.json +56 -0
- node_modules/decompress-response/readme.md +48 -0
- node_modules/deep-extend/CHANGELOG.md +46 -0
- node_modules/deep-extend/LICENSE +20 -0
- node_modules/deep-extend/README.md +91 -0
- node_modules/deep-extend/index.js +1 -0
- node_modules/deep-extend/lib/deep-extend.js +150 -0
- node_modules/deep-extend/package.json +62 -0
- node_modules/deep-is/.travis.yml +5 -0
- node_modules/deep-is/LICENSE +22 -0
- node_modules/deep-is/README.markdown +70 -0
- node_modules/deep-is/example/cmp.js +11 -0
- node_modules/deep-is/index.js +102 -0
- node_modules/deep-is/package.json +58 -0
- node_modules/deep-is/test/NaN.js +16 -0
- node_modules/deep-is/test/cmp.js +23 -0
- node_modules/deep-is/test/neg-vs-pos-0.js +15 -0
- node_modules/defu/LICENSE +21 -0
- node_modules/defu/README.md +171 -0
- node_modules/defu/lib/defu.cjs +10 -0
- node_modules/defu/lib/defu.d.cts +24 -0
- node_modules/defu/package.json +48 -0
- node_modules/delayed-stream/.npmignore +1 -0
- node_modules/delayed-stream/License +19 -0
- node_modules/delayed-stream/Makefile +7 -0
- node_modules/delayed-stream/Readme.md +141 -0
- node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- node_modules/delayed-stream/package.json +27 -0
- node_modules/depd/History.md +103 -0
- node_modules/depd/LICENSE +22 -0
- node_modules/depd/Readme.md +280 -0
- node_modules/depd/index.js +538 -0
- node_modules/depd/lib/browser/index.js +77 -0
- node_modules/depd/package.json +45 -0
- node_modules/destroy/LICENSE +23 -0
- node_modules/destroy/README.md +63 -0
- node_modules/destroy/index.js +209 -0
- node_modules/destroy/package.json +48 -0
- node_modules/detect-libc/LICENSE +201 -0
- node_modules/detect-libc/README.md +163 -0
- node_modules/detect-libc/index.d.ts +14 -0
- node_modules/detect-libc/lib/detect-libc.js +313 -0
- node_modules/detect-libc/lib/elf.js +39 -0
- node_modules/detect-libc/lib/filesystem.js +51 -0
- node_modules/detect-libc/lib/process.js +24 -0
node_modules/decimal.js/decimal.mjs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
node_modules/decimal.js/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "decimal.js",
|
| 3 |
+
"description": "An arbitrary-precision Decimal type for JavaScript.",
|
| 4 |
+
"version": "10.6.0",
|
| 5 |
+
"keywords": [
|
| 6 |
+
"arbitrary",
|
| 7 |
+
"precision",
|
| 8 |
+
"arithmetic",
|
| 9 |
+
"big",
|
| 10 |
+
"number",
|
| 11 |
+
"decimal",
|
| 12 |
+
"float",
|
| 13 |
+
"biginteger",
|
| 14 |
+
"bigdecimal",
|
| 15 |
+
"bignumber",
|
| 16 |
+
"bigint",
|
| 17 |
+
"bignum"
|
| 18 |
+
],
|
| 19 |
+
"repository" : {
|
| 20 |
+
"type": "git",
|
| 21 |
+
"url": "https://github.com/MikeMcl/decimal.js.git"
|
| 22 |
+
},
|
| 23 |
+
"main": "decimal",
|
| 24 |
+
"module": "decimal.mjs",
|
| 25 |
+
"browser": "decimal.js",
|
| 26 |
+
"exports": {
|
| 27 |
+
".": {
|
| 28 |
+
"types": "./decimal.d.ts",
|
| 29 |
+
"import": "./decimal.mjs",
|
| 30 |
+
"require": "./decimal.js"
|
| 31 |
+
},
|
| 32 |
+
"./decimal.mjs": "./decimal.mjs",
|
| 33 |
+
"./decimal.js": "./decimal.js",
|
| 34 |
+
"./package.json": "./package.json",
|
| 35 |
+
"./decimal": {
|
| 36 |
+
"types": "./decimal.d.ts",
|
| 37 |
+
"import": "./decimal.mjs",
|
| 38 |
+
"require": "./decimal.js"
|
| 39 |
+
}
|
| 40 |
+
},
|
| 41 |
+
"author": {
|
| 42 |
+
"name": "Michael Mclaughlin",
|
| 43 |
+
"email": "M8ch88l@gmail.com"
|
| 44 |
+
},
|
| 45 |
+
"license": "MIT",
|
| 46 |
+
"scripts": {
|
| 47 |
+
"test": "node ./test/test.js"
|
| 48 |
+
},
|
| 49 |
+
"types": "decimal.d.ts",
|
| 50 |
+
"files": [
|
| 51 |
+
"decimal.js",
|
| 52 |
+
"decimal.mjs",
|
| 53 |
+
"decimal.d.ts"
|
| 54 |
+
]
|
| 55 |
+
}
|
node_modules/decompress-response/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/// <reference types="node"/>
|
| 2 |
+
import {IncomingMessage} from 'http';
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
Decompress a HTTP response if needed.
|
| 6 |
+
|
| 7 |
+
@param response - The HTTP incoming stream with compressed data.
|
| 8 |
+
@returns The decompressed HTTP response stream.
|
| 9 |
+
|
| 10 |
+
@example
|
| 11 |
+
```
|
| 12 |
+
import {http} from 'http';
|
| 13 |
+
import decompressResponse = require('decompress-response');
|
| 14 |
+
|
| 15 |
+
http.get('https://sindresorhus.com', response => {
|
| 16 |
+
response = decompressResponse(response);
|
| 17 |
+
});
|
| 18 |
+
```
|
| 19 |
+
*/
|
| 20 |
+
declare function decompressResponse(response: IncomingMessage): IncomingMessage;
|
| 21 |
+
|
| 22 |
+
export = decompressResponse;
|
node_modules/decompress-response/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
const {Transform, PassThrough} = require('stream');
|
| 3 |
+
const zlib = require('zlib');
|
| 4 |
+
const mimicResponse = require('mimic-response');
|
| 5 |
+
|
| 6 |
+
module.exports = response => {
|
| 7 |
+
const contentEncoding = (response.headers['content-encoding'] || '').toLowerCase();
|
| 8 |
+
|
| 9 |
+
if (!['gzip', 'deflate', 'br'].includes(contentEncoding)) {
|
| 10 |
+
return response;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
// TODO: Remove this when targeting Node.js 12.
|
| 14 |
+
const isBrotli = contentEncoding === 'br';
|
| 15 |
+
if (isBrotli && typeof zlib.createBrotliDecompress !== 'function') {
|
| 16 |
+
response.destroy(new Error('Brotli is not supported on Node.js < 12'));
|
| 17 |
+
return response;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
let isEmpty = true;
|
| 21 |
+
|
| 22 |
+
const checker = new Transform({
|
| 23 |
+
transform(data, _encoding, callback) {
|
| 24 |
+
isEmpty = false;
|
| 25 |
+
|
| 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();
|
| 48 |
+
return;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
finalStream.destroy(error);
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
mimicResponse(response, finalStream);
|
| 55 |
+
response.pipe(checker).pipe(decompressStream).pipe(finalStream);
|
| 56 |
+
|
| 57 |
+
return finalStream;
|
| 58 |
+
};
|
node_modules/decompress-response/license
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
| 4 |
+
|
| 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 |
+
|
| 7 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 8 |
+
|
| 9 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
node_modules/decompress-response/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "decompress-response",
|
| 3 |
+
"version": "6.0.0",
|
| 4 |
+
"description": "Decompress a HTTP response if needed",
|
| 5 |
+
"license": "MIT",
|
| 6 |
+
"repository": "sindresorhus/decompress-response",
|
| 7 |
+
"funding": "https://github.com/sponsors/sindresorhus",
|
| 8 |
+
"author": {
|
| 9 |
+
"name": "Sindre Sorhus",
|
| 10 |
+
"email": "sindresorhus@gmail.com",
|
| 11 |
+
"url": "https://sindresorhus.com"
|
| 12 |
+
},
|
| 13 |
+
"engines": {
|
| 14 |
+
"node": ">=10"
|
| 15 |
+
},
|
| 16 |
+
"scripts": {
|
| 17 |
+
"test": "xo && ava && tsd"
|
| 18 |
+
},
|
| 19 |
+
"files": [
|
| 20 |
+
"index.js",
|
| 21 |
+
"index.d.ts"
|
| 22 |
+
],
|
| 23 |
+
"keywords": [
|
| 24 |
+
"decompress",
|
| 25 |
+
"response",
|
| 26 |
+
"http",
|
| 27 |
+
"https",
|
| 28 |
+
"zlib",
|
| 29 |
+
"gzip",
|
| 30 |
+
"zip",
|
| 31 |
+
"deflate",
|
| 32 |
+
"unzip",
|
| 33 |
+
"ungzip",
|
| 34 |
+
"incoming",
|
| 35 |
+
"message",
|
| 36 |
+
"stream",
|
| 37 |
+
"compressed",
|
| 38 |
+
"brotli"
|
| 39 |
+
],
|
| 40 |
+
"dependencies": {
|
| 41 |
+
"mimic-response": "^3.1.0"
|
| 42 |
+
},
|
| 43 |
+
"devDependencies": {
|
| 44 |
+
"@types/node": "^14.0.1",
|
| 45 |
+
"ava": "^2.2.0",
|
| 46 |
+
"get-stream": "^5.0.0",
|
| 47 |
+
"pify": "^5.0.0",
|
| 48 |
+
"tsd": "^0.11.0",
|
| 49 |
+
"xo": "^0.30.0"
|
| 50 |
+
},
|
| 51 |
+
"xo": {
|
| 52 |
+
"rules": {
|
| 53 |
+
"@typescript-eslint/prefer-readonly-parameter-types": "off"
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
}
|
node_modules/decompress-response/readme.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# decompress-response [](https://travis-ci.com/sindresorhus/decompress-response)
|
| 2 |
+
|
| 3 |
+
> Decompress a HTTP response if needed
|
| 4 |
+
|
| 5 |
+
Decompresses the [response](https://nodejs.org/api/http.html#http_class_http_incomingmessage) from [`http.request`](https://nodejs.org/api/http.html#http_http_request_options_callback) if it's gzipped, deflated or compressed with Brotli, otherwise just passes it through.
|
| 6 |
+
|
| 7 |
+
Used by [`got`](https://github.com/sindresorhus/got).
|
| 8 |
+
|
| 9 |
+
## Install
|
| 10 |
+
|
| 11 |
+
```
|
| 12 |
+
$ npm install decompress-response
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
## Usage
|
| 16 |
+
|
| 17 |
+
```js
|
| 18 |
+
const http = require('http');
|
| 19 |
+
const decompressResponse = require('decompress-response');
|
| 20 |
+
|
| 21 |
+
http.get('https://sindresorhus.com', response => {
|
| 22 |
+
response = decompressResponse(response);
|
| 23 |
+
});
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
## API
|
| 27 |
+
|
| 28 |
+
### decompressResponse(response)
|
| 29 |
+
|
| 30 |
+
Returns the decompressed HTTP response stream.
|
| 31 |
+
|
| 32 |
+
#### response
|
| 33 |
+
|
| 34 |
+
Type: [`http.IncomingMessage`](https://nodejs.org/api/http.html#http_class_http_incomingmessage)
|
| 35 |
+
|
| 36 |
+
The HTTP incoming stream with compressed data.
|
| 37 |
+
|
| 38 |
+
---
|
| 39 |
+
|
| 40 |
+
<div align="center">
|
| 41 |
+
<b>
|
| 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>
|
| 43 |
+
</b>
|
| 44 |
+
<br>
|
| 45 |
+
<sub>
|
| 46 |
+
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
| 47 |
+
</sub>
|
| 48 |
+
</div>
|
node_modules/deep-extend/CHANGELOG.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Changelog
|
| 2 |
+
=========
|
| 3 |
+
|
| 4 |
+
v0.6.0
|
| 5 |
+
------
|
| 6 |
+
|
| 7 |
+
- Updated "devDependencies" versions to fix vulnerability alerts
|
| 8 |
+
- Dropped support of io.js and node.js v0.12.x and lower since new versions of
|
| 9 |
+
"devDependencies" couldn't work with those old node.js versions
|
| 10 |
+
(minimal supported version of node.js now is v4.0.0)
|
| 11 |
+
|
| 12 |
+
v0.5.1
|
| 13 |
+
------
|
| 14 |
+
|
| 15 |
+
- Fix prototype pollution vulnerability (thanks to @mwakerman for the PR)
|
| 16 |
+
- Avoid using deprecated Buffer API (thanks to @ChALkeR for the PR)
|
| 17 |
+
|
| 18 |
+
v0.5.0
|
| 19 |
+
------
|
| 20 |
+
|
| 21 |
+
- Auto-testing provided by Travis CI;
|
| 22 |
+
- Support older Node.JS versions (`v0.11.x` and `v0.10.x`);
|
| 23 |
+
- Removed tests files from npm package.
|
| 24 |
+
|
| 25 |
+
v0.4.2
|
| 26 |
+
------
|
| 27 |
+
|
| 28 |
+
- Fix for `null` as an argument.
|
| 29 |
+
|
| 30 |
+
v0.4.1
|
| 31 |
+
------
|
| 32 |
+
|
| 33 |
+
- Removed test code from <b>npm</b> package
|
| 34 |
+
([see pull request #21](https://github.com/unclechu/node-deep-extend/pull/21));
|
| 35 |
+
- Increased minimal version of Node from `0.4.0` to `0.12.0`
|
| 36 |
+
(because can't run tests on lesser version anyway).
|
| 37 |
+
|
| 38 |
+
v0.4.0
|
| 39 |
+
------
|
| 40 |
+
|
| 41 |
+
- **WARNING!** Broken backward compatibility with `v0.3.x`;
|
| 42 |
+
- Fixed bug with extending arrays instead of cloning;
|
| 43 |
+
- Deep cloning for arrays;
|
| 44 |
+
- Check for own property;
|
| 45 |
+
- Fixed some documentation issues;
|
| 46 |
+
- Strict JS mode.
|
node_modules/deep-extend/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2013-2018, Viacheslav Lotsmanov
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
| 6 |
+
this software and associated documentation files (the "Software"), to deal in
|
| 7 |
+
the Software without restriction, including without limitation the rights to
|
| 8 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
| 9 |
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
| 10 |
+
subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
| 17 |
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
| 18 |
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
| 19 |
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 20 |
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
node_modules/deep-extend/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Deep Extend
|
| 2 |
+
===========
|
| 3 |
+
|
| 4 |
+
Recursive object extending.
|
| 5 |
+
|
| 6 |
+
[](https://travis-ci.org/unclechu/node-deep-extend)
|
| 7 |
+
|
| 8 |
+
[](https://nodei.co/npm/deep-extend/)
|
| 9 |
+
|
| 10 |
+
Install
|
| 11 |
+
-------
|
| 12 |
+
|
| 13 |
+
```bash
|
| 14 |
+
$ npm install deep-extend
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
Usage
|
| 18 |
+
-----
|
| 19 |
+
|
| 20 |
+
```javascript
|
| 21 |
+
var deepExtend = require('deep-extend');
|
| 22 |
+
var obj1 = {
|
| 23 |
+
a: 1,
|
| 24 |
+
b: 2,
|
| 25 |
+
d: {
|
| 26 |
+
a: 1,
|
| 27 |
+
b: [],
|
| 28 |
+
c: { test1: 123, test2: 321 }
|
| 29 |
+
},
|
| 30 |
+
f: 5,
|
| 31 |
+
g: 123,
|
| 32 |
+
i: 321,
|
| 33 |
+
j: [1, 2]
|
| 34 |
+
};
|
| 35 |
+
var obj2 = {
|
| 36 |
+
b: 3,
|
| 37 |
+
c: 5,
|
| 38 |
+
d: {
|
| 39 |
+
b: { first: 'one', second: 'two' },
|
| 40 |
+
c: { test2: 222 }
|
| 41 |
+
},
|
| 42 |
+
e: { one: 1, two: 2 },
|
| 43 |
+
f: [],
|
| 44 |
+
g: (void 0),
|
| 45 |
+
h: /abc/g,
|
| 46 |
+
i: null,
|
| 47 |
+
j: [3, 4]
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
deepExtend(obj1, obj2);
|
| 51 |
+
|
| 52 |
+
console.log(obj1);
|
| 53 |
+
/*
|
| 54 |
+
{ a: 1,
|
| 55 |
+
b: 3,
|
| 56 |
+
d:
|
| 57 |
+
{ a: 1,
|
| 58 |
+
b: { first: 'one', second: 'two' },
|
| 59 |
+
c: { test1: 123, test2: 222 } },
|
| 60 |
+
f: [],
|
| 61 |
+
g: undefined,
|
| 62 |
+
c: 5,
|
| 63 |
+
e: { one: 1, two: 2 },
|
| 64 |
+
h: /abc/g,
|
| 65 |
+
i: null,
|
| 66 |
+
j: [3, 4] }
|
| 67 |
+
*/
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
Unit testing
|
| 71 |
+
------------
|
| 72 |
+
|
| 73 |
+
```bash
|
| 74 |
+
$ npm test
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
Changelog
|
| 78 |
+
---------
|
| 79 |
+
|
| 80 |
+
[CHANGELOG.md](./CHANGELOG.md)
|
| 81 |
+
|
| 82 |
+
Any issues?
|
| 83 |
+
-----------
|
| 84 |
+
|
| 85 |
+
Please, report about issues
|
| 86 |
+
[here](https://github.com/unclechu/node-deep-extend/issues).
|
| 87 |
+
|
| 88 |
+
License
|
| 89 |
+
-------
|
| 90 |
+
|
| 91 |
+
[MIT](./LICENSE)
|
node_modules/deep-extend/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
module.exports = require('./lib/deep-extend');
|
node_modules/deep-extend/lib/deep-extend.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*!
|
| 2 |
+
* @description Recursive object extending
|
| 3 |
+
* @author Viacheslav Lotsmanov <lotsmanov89@gmail.com>
|
| 4 |
+
* @license MIT
|
| 5 |
+
*
|
| 6 |
+
* The MIT License (MIT)
|
| 7 |
+
*
|
| 8 |
+
* Copyright (c) 2013-2018 Viacheslav Lotsmanov
|
| 9 |
+
*
|
| 10 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
| 11 |
+
* this software and associated documentation files (the "Software"), to deal in
|
| 12 |
+
* the Software without restriction, including without limitation the rights to
|
| 13 |
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
| 14 |
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
| 15 |
+
* subject to the following conditions:
|
| 16 |
+
*
|
| 17 |
+
* The above copyright notice and this permission notice shall be included in all
|
| 18 |
+
* copies or substantial portions of the Software.
|
| 19 |
+
*
|
| 20 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 21 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
| 22 |
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
| 23 |
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
| 24 |
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 25 |
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
'use strict';
|
| 29 |
+
|
| 30 |
+
function isSpecificValue(val) {
|
| 31 |
+
return (
|
| 32 |
+
val instanceof Buffer
|
| 33 |
+
|| val instanceof Date
|
| 34 |
+
|| val instanceof RegExp
|
| 35 |
+
) ? true : false;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
function cloneSpecificValue(val) {
|
| 39 |
+
if (val instanceof Buffer) {
|
| 40 |
+
var x = Buffer.alloc
|
| 41 |
+
? Buffer.alloc(val.length)
|
| 42 |
+
: new Buffer(val.length);
|
| 43 |
+
val.copy(x);
|
| 44 |
+
return x;
|
| 45 |
+
} else if (val instanceof Date) {
|
| 46 |
+
return new Date(val.getTime());
|
| 47 |
+
} else if (val instanceof RegExp) {
|
| 48 |
+
return new RegExp(val);
|
| 49 |
+
} else {
|
| 50 |
+
throw new Error('Unexpected situation');
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* Recursive cloning array.
|
| 56 |
+
*/
|
| 57 |
+
function deepCloneArray(arr) {
|
| 58 |
+
var clone = [];
|
| 59 |
+
arr.forEach(function (item, index) {
|
| 60 |
+
if (typeof item === 'object' && item !== null) {
|
| 61 |
+
if (Array.isArray(item)) {
|
| 62 |
+
clone[index] = deepCloneArray(item);
|
| 63 |
+
} else if (isSpecificValue(item)) {
|
| 64 |
+
clone[index] = cloneSpecificValue(item);
|
| 65 |
+
} else {
|
| 66 |
+
clone[index] = deepExtend({}, item);
|
| 67 |
+
}
|
| 68 |
+
} else {
|
| 69 |
+
clone[index] = item;
|
| 70 |
+
}
|
| 71 |
+
});
|
| 72 |
+
return clone;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
function safeGetProperty(object, property) {
|
| 76 |
+
return property === '__proto__' ? undefined : object[property];
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Extening object that entered in first argument.
|
| 81 |
+
*
|
| 82 |
+
* Returns extended object or false if have no target object or incorrect type.
|
| 83 |
+
*
|
| 84 |
+
* If you wish to clone source object (without modify it), just use empty new
|
| 85 |
+
* object as first argument, like this:
|
| 86 |
+
* deepExtend({}, yourObj_1, [yourObj_N]);
|
| 87 |
+
*/
|
| 88 |
+
var deepExtend = module.exports = function (/*obj_1, [obj_2], [obj_N]*/) {
|
| 89 |
+
if (arguments.length < 1 || typeof arguments[0] !== 'object') {
|
| 90 |
+
return false;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
if (arguments.length < 2) {
|
| 94 |
+
return arguments[0];
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
var target = arguments[0];
|
| 98 |
+
|
| 99 |
+
// convert arguments to array and cut off target object
|
| 100 |
+
var args = Array.prototype.slice.call(arguments, 1);
|
| 101 |
+
|
| 102 |
+
var val, src, clone;
|
| 103 |
+
|
| 104 |
+
args.forEach(function (obj) {
|
| 105 |
+
// skip argument if isn't an object, is null, or is an array
|
| 106 |
+
if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
|
| 107 |
+
return;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
Object.keys(obj).forEach(function (key) {
|
| 111 |
+
src = safeGetProperty(target, key); // source value
|
| 112 |
+
val = safeGetProperty(obj, key); // new value
|
| 113 |
+
|
| 114 |
+
// recursion prevention
|
| 115 |
+
if (val === target) {
|
| 116 |
+
return;
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* if new value isn't object then just overwrite by new value
|
| 120 |
+
* instead of extending.
|
| 121 |
+
*/
|
| 122 |
+
} else if (typeof val !== 'object' || val === null) {
|
| 123 |
+
target[key] = val;
|
| 124 |
+
return;
|
| 125 |
+
|
| 126 |
+
// just clone arrays (and recursive clone objects inside)
|
| 127 |
+
} else if (Array.isArray(val)) {
|
| 128 |
+
target[key] = deepCloneArray(val);
|
| 129 |
+
return;
|
| 130 |
+
|
| 131 |
+
// custom cloning and overwrite for specific objects
|
| 132 |
+
} else if (isSpecificValue(val)) {
|
| 133 |
+
target[key] = cloneSpecificValue(val);
|
| 134 |
+
return;
|
| 135 |
+
|
| 136 |
+
// overwrite by new value if source isn't object or array
|
| 137 |
+
} else if (typeof src !== 'object' || src === null || Array.isArray(src)) {
|
| 138 |
+
target[key] = deepExtend({}, val);
|
| 139 |
+
return;
|
| 140 |
+
|
| 141 |
+
// source value and new value is objects both, extending...
|
| 142 |
+
} else {
|
| 143 |
+
target[key] = deepExtend(src, val);
|
| 144 |
+
return;
|
| 145 |
+
}
|
| 146 |
+
});
|
| 147 |
+
});
|
| 148 |
+
|
| 149 |
+
return target;
|
| 150 |
+
};
|
node_modules/deep-extend/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "deep-extend",
|
| 3 |
+
"description": "Recursive object extending",
|
| 4 |
+
"license": "MIT",
|
| 5 |
+
"version": "0.6.0",
|
| 6 |
+
"homepage": "https://github.com/unclechu/node-deep-extend",
|
| 7 |
+
"keywords": [
|
| 8 |
+
"deep-extend",
|
| 9 |
+
"extend",
|
| 10 |
+
"deep",
|
| 11 |
+
"recursive",
|
| 12 |
+
"xtend",
|
| 13 |
+
"clone",
|
| 14 |
+
"merge",
|
| 15 |
+
"json"
|
| 16 |
+
],
|
| 17 |
+
"licenses": [
|
| 18 |
+
{
|
| 19 |
+
"type": "MIT",
|
| 20 |
+
"url": "https://raw.githubusercontent.com/unclechu/node-deep-extend/master/LICENSE"
|
| 21 |
+
}
|
| 22 |
+
],
|
| 23 |
+
"repository": {
|
| 24 |
+
"type": "git",
|
| 25 |
+
"url": "git://github.com/unclechu/node-deep-extend.git"
|
| 26 |
+
},
|
| 27 |
+
"author": "Viacheslav Lotsmanov <lotsmanov89@gmail.com>",
|
| 28 |
+
"bugs": "https://github.com/unclechu/node-deep-extend/issues",
|
| 29 |
+
"contributors": [
|
| 30 |
+
{
|
| 31 |
+
"name": "Romain Prieto",
|
| 32 |
+
"url": "https://github.com/rprieto"
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"name": "Max Maximov",
|
| 36 |
+
"url": "https://github.com/maxmaximov"
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"name": "Marshall Bowers",
|
| 40 |
+
"url": "https://github.com/maxdeviant"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"name": "Misha Wakerman",
|
| 44 |
+
"url": "https://github.com/mwakerman"
|
| 45 |
+
}
|
| 46 |
+
],
|
| 47 |
+
"main": "lib/deep-extend.js",
|
| 48 |
+
"engines": {
|
| 49 |
+
"node": ">=4.0.0"
|
| 50 |
+
},
|
| 51 |
+
"scripts": {
|
| 52 |
+
"test": "./node_modules/.bin/mocha"
|
| 53 |
+
},
|
| 54 |
+
"devDependencies": {
|
| 55 |
+
"mocha": "5.2.0",
|
| 56 |
+
"should": "13.2.1"
|
| 57 |
+
},
|
| 58 |
+
"files": [
|
| 59 |
+
"index.js",
|
| 60 |
+
"lib/"
|
| 61 |
+
]
|
| 62 |
+
}
|
node_modules/deep-is/.travis.yml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
language: node_js
|
| 2 |
+
node_js:
|
| 3 |
+
- 0.6
|
| 4 |
+
- 0.8
|
| 5 |
+
- 0.10
|
node_modules/deep-is/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 2012, 2013 Thorsten Lorenz <thlorenz@gmx.de>
|
| 2 |
+
Copyright (c) 2012 James Halliday <mail@substack.net>
|
| 3 |
+
Copyright (c) 2009 Thomas Robinson <280north.com>
|
| 4 |
+
|
| 5 |
+
This software is released under the MIT license:
|
| 6 |
+
|
| 7 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
| 8 |
+
this software and associated documentation files (the "Software"), to deal in
|
| 9 |
+
the Software without restriction, including without limitation the rights to
|
| 10 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
| 11 |
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
| 12 |
+
subject to the following conditions:
|
| 13 |
+
|
| 14 |
+
The above copyright notice and this permission notice shall be included in all
|
| 15 |
+
copies or substantial portions of the Software.
|
| 16 |
+
|
| 17 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 18 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
| 19 |
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
| 20 |
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
| 21 |
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 22 |
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
node_modules/deep-is/README.markdown
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
deep-is
|
| 2 |
+
==========
|
| 3 |
+
|
| 4 |
+
Node's `assert.deepEqual() algorithm` as a standalone module. Exactly like
|
| 5 |
+
[deep-equal](https://github.com/substack/node-deep-equal) except for the fact that `deepEqual(NaN, NaN) === true`.
|
| 6 |
+
|
| 7 |
+
This module is around [5 times faster](https://gist.github.com/2790507)
|
| 8 |
+
than wrapping `assert.deepEqual()` in a `try/catch`.
|
| 9 |
+
|
| 10 |
+
[](http://ci.testling.com/thlorenz/deep-is)
|
| 11 |
+
|
| 12 |
+
[](http://travis-ci.org/thlorenz/deep-is)
|
| 13 |
+
|
| 14 |
+
example
|
| 15 |
+
=======
|
| 16 |
+
|
| 17 |
+
``` js
|
| 18 |
+
var equal = require('deep-is');
|
| 19 |
+
console.dir([
|
| 20 |
+
equal(
|
| 21 |
+
{ a : [ 2, 3 ], b : [ 4 ] },
|
| 22 |
+
{ a : [ 2, 3 ], b : [ 4 ] }
|
| 23 |
+
),
|
| 24 |
+
equal(
|
| 25 |
+
{ x : 5, y : [6] },
|
| 26 |
+
{ x : 5, y : 6 }
|
| 27 |
+
)
|
| 28 |
+
]);
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
methods
|
| 32 |
+
=======
|
| 33 |
+
|
| 34 |
+
var deepIs = require('deep-is')
|
| 35 |
+
|
| 36 |
+
deepIs(a, b)
|
| 37 |
+
---------------
|
| 38 |
+
|
| 39 |
+
Compare objects `a` and `b`, returning whether they are equal according to a
|
| 40 |
+
recursive equality algorithm.
|
| 41 |
+
|
| 42 |
+
install
|
| 43 |
+
=======
|
| 44 |
+
|
| 45 |
+
With [npm](http://npmjs.org) do:
|
| 46 |
+
|
| 47 |
+
```
|
| 48 |
+
npm install deep-is
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
test
|
| 52 |
+
====
|
| 53 |
+
|
| 54 |
+
With [npm](http://npmjs.org) do:
|
| 55 |
+
|
| 56 |
+
```
|
| 57 |
+
npm test
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
license
|
| 61 |
+
=======
|
| 62 |
+
|
| 63 |
+
Copyright (c) 2012, 2013 Thorsten Lorenz <thlorenz@gmx.de>
|
| 64 |
+
Copyright (c) 2012 James Halliday <mail@substack.net>
|
| 65 |
+
|
| 66 |
+
Derived largely from node's assert module, which has the copyright statement:
|
| 67 |
+
|
| 68 |
+
Copyright (c) 2009 Thomas Robinson <280north.com>
|
| 69 |
+
|
| 70 |
+
Released under the MIT license, see LICENSE for details.
|
node_modules/deep-is/example/cmp.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var equal = require('../');
|
| 2 |
+
console.dir([
|
| 3 |
+
equal(
|
| 4 |
+
{ a : [ 2, 3 ], b : [ 4 ] },
|
| 5 |
+
{ a : [ 2, 3 ], b : [ 4 ] }
|
| 6 |
+
),
|
| 7 |
+
equal(
|
| 8 |
+
{ x : 5, y : [6] },
|
| 9 |
+
{ x : 5, y : 6 }
|
| 10 |
+
)
|
| 11 |
+
]);
|
node_modules/deep-is/index.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var pSlice = Array.prototype.slice;
|
| 2 |
+
var Object_keys = typeof Object.keys === 'function'
|
| 3 |
+
? Object.keys
|
| 4 |
+
: function (obj) {
|
| 5 |
+
var keys = [];
|
| 6 |
+
for (var key in obj) keys.push(key);
|
| 7 |
+
return keys;
|
| 8 |
+
}
|
| 9 |
+
;
|
| 10 |
+
|
| 11 |
+
var deepEqual = module.exports = function (actual, expected) {
|
| 12 |
+
// enforce Object.is +0 !== -0
|
| 13 |
+
if (actual === 0 && expected === 0) {
|
| 14 |
+
return areZerosEqual(actual, expected);
|
| 15 |
+
|
| 16 |
+
// 7.1. All identical values are equivalent, as determined by ===.
|
| 17 |
+
} else if (actual === expected) {
|
| 18 |
+
return true;
|
| 19 |
+
|
| 20 |
+
} else if (actual instanceof Date && expected instanceof Date) {
|
| 21 |
+
return actual.getTime() === expected.getTime();
|
| 22 |
+
|
| 23 |
+
} else if (isNumberNaN(actual)) {
|
| 24 |
+
return isNumberNaN(expected);
|
| 25 |
+
|
| 26 |
+
// 7.3. Other pairs that do not both pass typeof value == 'object',
|
| 27 |
+
// equivalence is determined by ==.
|
| 28 |
+
} else if (typeof actual != 'object' && typeof expected != 'object') {
|
| 29 |
+
return actual == expected;
|
| 30 |
+
|
| 31 |
+
// 7.4. For all other Object pairs, including Array objects, equivalence is
|
| 32 |
+
// determined by having the same number of owned properties (as verified
|
| 33 |
+
// with Object.prototype.hasOwnProperty.call), the same set of keys
|
| 34 |
+
// (although not necessarily the same order), equivalent values for every
|
| 35 |
+
// corresponding key, and an identical 'prototype' property. Note: this
|
| 36 |
+
// accounts for both named and indexed properties on Arrays.
|
| 37 |
+
} else {
|
| 38 |
+
return objEquiv(actual, expected);
|
| 39 |
+
}
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
function isUndefinedOrNull(value) {
|
| 43 |
+
return value === null || value === undefined;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
function isArguments(object) {
|
| 47 |
+
return Object.prototype.toString.call(object) == '[object Arguments]';
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
function isNumberNaN(value) {
|
| 51 |
+
// NaN === NaN -> false
|
| 52 |
+
return typeof value == 'number' && value !== value;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
function areZerosEqual(zeroA, zeroB) {
|
| 56 |
+
// (1 / +0|0) -> Infinity, but (1 / -0) -> -Infinity and (Infinity !== -Infinity)
|
| 57 |
+
return (1 / zeroA) === (1 / zeroB);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
function objEquiv(a, b) {
|
| 61 |
+
if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
|
| 62 |
+
return false;
|
| 63 |
+
|
| 64 |
+
// an identical 'prototype' property.
|
| 65 |
+
if (a.prototype !== b.prototype) return false;
|
| 66 |
+
//~~~I've managed to break Object.keys through screwy arguments passing.
|
| 67 |
+
// Converting to array solves the problem.
|
| 68 |
+
if (isArguments(a)) {
|
| 69 |
+
if (!isArguments(b)) {
|
| 70 |
+
return false;
|
| 71 |
+
}
|
| 72 |
+
a = pSlice.call(a);
|
| 73 |
+
b = pSlice.call(b);
|
| 74 |
+
return deepEqual(a, b);
|
| 75 |
+
}
|
| 76 |
+
try {
|
| 77 |
+
var ka = Object_keys(a),
|
| 78 |
+
kb = Object_keys(b),
|
| 79 |
+
key, i;
|
| 80 |
+
} catch (e) {//happens when one is a string literal and the other isn't
|
| 81 |
+
return false;
|
| 82 |
+
}
|
| 83 |
+
// having the same number of owned properties (keys incorporates
|
| 84 |
+
// hasOwnProperty)
|
| 85 |
+
if (ka.length != kb.length)
|
| 86 |
+
return false;
|
| 87 |
+
//the same set of keys (although not necessarily the same order),
|
| 88 |
+
ka.sort();
|
| 89 |
+
kb.sort();
|
| 90 |
+
//~~~cheap key test
|
| 91 |
+
for (i = ka.length - 1; i >= 0; i--) {
|
| 92 |
+
if (ka[i] != kb[i])
|
| 93 |
+
return false;
|
| 94 |
+
}
|
| 95 |
+
//equivalent values for every corresponding key, and
|
| 96 |
+
//~~~possibly expensive deep test
|
| 97 |
+
for (i = ka.length - 1; i >= 0; i--) {
|
| 98 |
+
key = ka[i];
|
| 99 |
+
if (!deepEqual(a[key], b[key])) return false;
|
| 100 |
+
}
|
| 101 |
+
return true;
|
| 102 |
+
}
|
node_modules/deep-is/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "deep-is",
|
| 3 |
+
"version": "0.1.4",
|
| 4 |
+
"description": "node's assert.deepEqual algorithm except for NaN being equal to NaN",
|
| 5 |
+
"main": "index.js",
|
| 6 |
+
"directories": {
|
| 7 |
+
"lib": ".",
|
| 8 |
+
"example": "example",
|
| 9 |
+
"test": "test"
|
| 10 |
+
},
|
| 11 |
+
"scripts": {
|
| 12 |
+
"test": "tape test/*.js"
|
| 13 |
+
},
|
| 14 |
+
"devDependencies": {
|
| 15 |
+
"tape": "~1.0.2"
|
| 16 |
+
},
|
| 17 |
+
"repository": {
|
| 18 |
+
"type": "git",
|
| 19 |
+
"url": "http://github.com/thlorenz/deep-is.git"
|
| 20 |
+
},
|
| 21 |
+
"keywords": [
|
| 22 |
+
"equality",
|
| 23 |
+
"equal",
|
| 24 |
+
"compare"
|
| 25 |
+
],
|
| 26 |
+
"author": {
|
| 27 |
+
"name": "Thorsten Lorenz",
|
| 28 |
+
"email": "thlorenz@gmx.de",
|
| 29 |
+
"url": "http://thlorenz.com"
|
| 30 |
+
},
|
| 31 |
+
"license": "MIT",
|
| 32 |
+
"testling": {
|
| 33 |
+
"files": "test/*.js",
|
| 34 |
+
"browsers": {
|
| 35 |
+
"ie": [
|
| 36 |
+
6,
|
| 37 |
+
7,
|
| 38 |
+
8,
|
| 39 |
+
9
|
| 40 |
+
],
|
| 41 |
+
"ff": [
|
| 42 |
+
3.5,
|
| 43 |
+
10,
|
| 44 |
+
15
|
| 45 |
+
],
|
| 46 |
+
"chrome": [
|
| 47 |
+
10,
|
| 48 |
+
22
|
| 49 |
+
],
|
| 50 |
+
"safari": [
|
| 51 |
+
5.1
|
| 52 |
+
],
|
| 53 |
+
"opera": [
|
| 54 |
+
12
|
| 55 |
+
]
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
}
|
node_modules/deep-is/test/NaN.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var test = require('tape');
|
| 2 |
+
var equal = require('../');
|
| 3 |
+
|
| 4 |
+
test('NaN and 0 values', function (t) {
|
| 5 |
+
t.ok(equal(NaN, NaN));
|
| 6 |
+
t.notOk(equal(0, NaN));
|
| 7 |
+
t.ok(equal(0, 0));
|
| 8 |
+
t.notOk(equal(0, 1));
|
| 9 |
+
t.end();
|
| 10 |
+
});
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
test('nested NaN values', function (t) {
|
| 14 |
+
t.ok(equal([ NaN, 1, NaN ], [ NaN, 1, NaN ]));
|
| 15 |
+
t.end();
|
| 16 |
+
});
|
node_modules/deep-is/test/cmp.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var test = require('tape');
|
| 2 |
+
var equal = require('../');
|
| 3 |
+
|
| 4 |
+
test('equal', function (t) {
|
| 5 |
+
t.ok(equal(
|
| 6 |
+
{ a : [ 2, 3 ], b : [ 4 ] },
|
| 7 |
+
{ a : [ 2, 3 ], b : [ 4 ] }
|
| 8 |
+
));
|
| 9 |
+
t.end();
|
| 10 |
+
});
|
| 11 |
+
|
| 12 |
+
test('not equal', function (t) {
|
| 13 |
+
t.notOk(equal(
|
| 14 |
+
{ x : 5, y : [6] },
|
| 15 |
+
{ x : 5, y : 6 }
|
| 16 |
+
));
|
| 17 |
+
t.end();
|
| 18 |
+
});
|
| 19 |
+
|
| 20 |
+
test('nested nulls', function (t) {
|
| 21 |
+
t.ok(equal([ null, null, null ], [ null, null, null ]));
|
| 22 |
+
t.end();
|
| 23 |
+
});
|
node_modules/deep-is/test/neg-vs-pos-0.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var test = require('tape');
|
| 2 |
+
var equal = require('../');
|
| 3 |
+
|
| 4 |
+
test('0 values', function (t) {
|
| 5 |
+
t.ok(equal( 0, 0), ' 0 === 0');
|
| 6 |
+
t.ok(equal( 0, +0), ' 0 === +0');
|
| 7 |
+
t.ok(equal(+0, +0), '+0 === +0');
|
| 8 |
+
t.ok(equal(-0, -0), '-0 === -0');
|
| 9 |
+
|
| 10 |
+
t.notOk(equal(-0, 0), '-0 !== 0');
|
| 11 |
+
t.notOk(equal(-0, +0), '-0 !== +0');
|
| 12 |
+
|
| 13 |
+
t.end();
|
| 14 |
+
});
|
| 15 |
+
|
node_modules/defu/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
node_modules/defu/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🌊 defu
|
| 2 |
+
|
| 3 |
+
Assign default properties, recursively. Lightweight and Fast.
|
| 4 |
+
|
| 5 |
+
[![npm version][npm-version-src]][npm-version-href]
|
| 6 |
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
| 7 |
+
[![bundle][bundle-src]][bundle-href]
|
| 8 |
+
[![Codecov][codecov-src]][codecov-href]
|
| 9 |
+
[![License][license-src]][license-href]
|
| 10 |
+
|
| 11 |
+
## Install
|
| 12 |
+
|
| 13 |
+
Install package:
|
| 14 |
+
|
| 15 |
+
```bash
|
| 16 |
+
# yarn
|
| 17 |
+
yarn add defu
|
| 18 |
+
# npm
|
| 19 |
+
npm install defu
|
| 20 |
+
# pnpm
|
| 21 |
+
pnpm install defu
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
## Usage
|
| 25 |
+
|
| 26 |
+
```js
|
| 27 |
+
import { defu } from "defu";
|
| 28 |
+
|
| 29 |
+
const options = defu(object, ...defaults);
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
Leftmost arguments have more priority when assigning defaults.
|
| 33 |
+
|
| 34 |
+
### Arguments
|
| 35 |
+
|
| 36 |
+
- **object (Object):** The destination object.
|
| 37 |
+
- **source (Object):** The source object.
|
| 38 |
+
|
| 39 |
+
```js
|
| 40 |
+
import { defu } from "defu";
|
| 41 |
+
|
| 42 |
+
console.log(defu({ a: { b: 2 } }, { a: { b: 1, c: 3 } }));
|
| 43 |
+
// => { a: { b: 2, c: 3 } }
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
### Using with CommonJS
|
| 47 |
+
|
| 48 |
+
```js
|
| 49 |
+
const { defu } = require("defu");
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
## Custom Merger
|
| 53 |
+
|
| 54 |
+
Sometimes default merging strategy is not desirable. Using `createDefu` we can create a custom instance with different merging strategy.
|
| 55 |
+
|
| 56 |
+
This function accepts `obj` (source object), `key` and `value` (current value) and should return `true` if applied custom merging.
|
| 57 |
+
|
| 58 |
+
**Example:** Sum numbers instead of overriding
|
| 59 |
+
|
| 60 |
+
```js
|
| 61 |
+
import { createDefu } from "defu";
|
| 62 |
+
|
| 63 |
+
const ext = createDefu((obj, key, value) => {
|
| 64 |
+
if (typeof obj[key] === "number" && typeof value === "number") {
|
| 65 |
+
obj[key] += value;
|
| 66 |
+
return true;
|
| 67 |
+
}
|
| 68 |
+
});
|
| 69 |
+
|
| 70 |
+
ext({ cost: 15 }, { cost: 10 }); // { cost: 25 }
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
## Function Merger
|
| 74 |
+
|
| 75 |
+
Using `defuFn`, if user provided a function, it will be called with default value instead of merging.
|
| 76 |
+
|
| 77 |
+
It can be useful for default values manipulation.
|
| 78 |
+
|
| 79 |
+
**Example:** Filter some items from defaults (array) and add 20 to the count default value.
|
| 80 |
+
|
| 81 |
+
```js
|
| 82 |
+
import { defuFn } from "defu";
|
| 83 |
+
|
| 84 |
+
defuFn(
|
| 85 |
+
{
|
| 86 |
+
ignore: (val) => val.filter((item) => item !== "dist"),
|
| 87 |
+
count: (count) => count + 20,
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
ignore: ["node_modules", "dist"],
|
| 91 |
+
count: 10,
|
| 92 |
+
},
|
| 93 |
+
);
|
| 94 |
+
/*
|
| 95 |
+
{
|
| 96 |
+
ignore: ['node_modules'],
|
| 97 |
+
count: 30
|
| 98 |
+
}
|
| 99 |
+
*/
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
**Note:** if the default value is not defined, the function defined won't be called and kept as value.
|
| 103 |
+
|
| 104 |
+
## Array Function Merger
|
| 105 |
+
|
| 106 |
+
`defuArrayFn` is similar to `defuFn` but **only applies to array values defined in defaults**.
|
| 107 |
+
|
| 108 |
+
**Example:** Filter some items from defaults (array) and add 20 to the count default value.
|
| 109 |
+
|
| 110 |
+
```js
|
| 111 |
+
import { defuArrayFn } from "defu";
|
| 112 |
+
|
| 113 |
+
defuArrayFn(
|
| 114 |
+
{
|
| 115 |
+
ignore: (val) => val.filter((i) => i !== "dist"),
|
| 116 |
+
count: () => 20,
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
ignore: ["node_modules", "dist"],
|
| 120 |
+
count: 10,
|
| 121 |
+
},
|
| 122 |
+
);
|
| 123 |
+
/*
|
| 124 |
+
{
|
| 125 |
+
ignore: ['node_modules'],
|
| 126 |
+
count: () => 20
|
| 127 |
+
}
|
| 128 |
+
*/
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
**Note:** the function is called only if the value defined in defaults is an aray.
|
| 132 |
+
|
| 133 |
+
### Remarks
|
| 134 |
+
|
| 135 |
+
- `object` and `defaults` are not modified
|
| 136 |
+
- Nullish values ([`null`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null) and [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)) are skipped. Please use [defaults-deep](https://www.npmjs.com/package/defaults-deep) or [omit-deep](http://npmjs.com/package/omit-deep) or [lodash.defaultsdeep](https://www.npmjs.com/package/lodash.defaultsdeep) if you need to preserve or different behavior.
|
| 137 |
+
- Assignment of `__proto__` and `constructor` keys will be skipped to prevent security issues with object pollution.
|
| 138 |
+
- Will concat `array` values (if default property is defined)
|
| 139 |
+
|
| 140 |
+
```js
|
| 141 |
+
console.log(defu({ array: ["b", "c"] }, { array: ["a"] }));
|
| 142 |
+
// => { array: ['b', 'c', 'a'] }
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
## Type
|
| 146 |
+
|
| 147 |
+
We expose `Defu` as a type utility to return a merged type that follows the rules that defu follows.
|
| 148 |
+
|
| 149 |
+
```js
|
| 150 |
+
import type { Defu } from 'defu'
|
| 151 |
+
|
| 152 |
+
type Options = Defu<{ foo: 'bar' }, [{}, { bar: 'baz' }, { something: 42 }]>
|
| 153 |
+
// returns { foo: 'bar', bar: 'baz', 'something': 42 }
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
## License
|
| 157 |
+
|
| 158 |
+
MIT. Made with 💖
|
| 159 |
+
|
| 160 |
+
<!-- Refs -->
|
| 161 |
+
|
| 162 |
+
[npm-version-src]: https://img.shields.io/npm/v/defu?style=flat&colorA=18181B&colorB=F0DB4F
|
| 163 |
+
[npm-version-href]: https://npmjs.com/package/defu
|
| 164 |
+
[npm-downloads-src]: https://img.shields.io/npm/dm/defu?style=flat&colorA=18181B&colorB=F0DB4F
|
| 165 |
+
[npm-downloads-href]: https://npmjs.com/package/defu
|
| 166 |
+
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/defu/main?style=flat&colorA=18181B&colorB=F0DB4F
|
| 167 |
+
[codecov-href]: https://codecov.io/gh/unjs/defu
|
| 168 |
+
[bundle-src]: https://img.shields.io/bundlephobia/minzip/defu?style=flat&colorA=18181B&colorB=F0DB4F
|
| 169 |
+
[bundle-href]: https://bundlephobia.com/result?p=defu
|
| 170 |
+
[license-src]: https://img.shields.io/github/license/unjs/defu.svg?style=flat&colorA=18181B&colorB=F0DB4F
|
| 171 |
+
[license-href]: https://github.com/unjs/defu/blob/main/LICENSE
|
node_modules/defu/lib/defu.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const { defu, createDefu, defuFn, defuArrayFn } = require("../dist/defu.cjs");
|
| 2 |
+
|
| 3 |
+
module.exports = defu;
|
| 4 |
+
|
| 5 |
+
module.exports.defu = defu;
|
| 6 |
+
module.exports.default = defu;
|
| 7 |
+
|
| 8 |
+
module.exports.createDefu = createDefu;
|
| 9 |
+
module.exports.defuFn = defuFn;
|
| 10 |
+
module.exports.defuArrayFn = defuArrayFn;
|
node_modules/defu/lib/defu.d.cts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Defu, DefuInstance, DefuFn } from "../dist/defu.mts";
|
| 2 |
+
|
| 3 |
+
type _Input = Record<string | number | symbol, any>;
|
| 4 |
+
type _IgnoredInput = boolean | number | null | any[] | Record<never, any> | undefined;
|
| 5 |
+
|
| 6 |
+
declare function defuProxy<Source extends _Input, Defaults extends Array<_Input | _IgnoredInput>>(
|
| 7 |
+
source: Source | _IgnoredInput,
|
| 8 |
+
...defaults: Defaults
|
| 9 |
+
): Defu<Source, Defaults>;
|
| 10 |
+
|
| 11 |
+
declare namespace defuProxy {
|
| 12 |
+
export type { Defu, DefuFn, DefuInstance };
|
| 13 |
+
export var fn: DefuFn;
|
| 14 |
+
export var arrayFn: DefuFn;
|
| 15 |
+
export function extend(merger?: (...args: any[]) => any): DefuFn;
|
| 16 |
+
var _default: DefuInstance;
|
| 17 |
+
export { _default as default };
|
| 18 |
+
export var defu: DefuInstance;
|
| 19 |
+
export var createDefu: typeof import("../dist/defu.mts").createDefu;
|
| 20 |
+
export var defuFn: DefuFn;
|
| 21 |
+
export var defuArrayFn: DefuFn;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
export = defuProxy;
|
node_modules/defu/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "defu",
|
| 3 |
+
"version": "6.1.7",
|
| 4 |
+
"description": "Recursively assign default properties. Lightweight and Fast!",
|
| 5 |
+
"license": "MIT",
|
| 6 |
+
"repository": "unjs/defu",
|
| 7 |
+
"files": [
|
| 8 |
+
"dist",
|
| 9 |
+
"lib"
|
| 10 |
+
],
|
| 11 |
+
"main": "./lib/defu.cjs",
|
| 12 |
+
"module": "./dist/defu.mjs",
|
| 13 |
+
"types": "./dist/defu.d.ts",
|
| 14 |
+
"exports": {
|
| 15 |
+
".": {
|
| 16 |
+
"import": {
|
| 17 |
+
"types": "./dist/defu.d.mts",
|
| 18 |
+
"default": "./dist/defu.mjs"
|
| 19 |
+
},
|
| 20 |
+
"require": {
|
| 21 |
+
"types": "./lib/defu.d.cts",
|
| 22 |
+
"default": "./lib/defu.cjs"
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
},
|
| 26 |
+
"devDependencies": {
|
| 27 |
+
"@types/node": "^25.5.0",
|
| 28 |
+
"@typescript/native-preview": "7.0.0-dev.20260401.1",
|
| 29 |
+
"@vitest/coverage-v8": "^4.1.2",
|
| 30 |
+
"changelogen": "^0.6.2",
|
| 31 |
+
"eslint-config-unjs": "^0.6.2",
|
| 32 |
+
"expect-type": "^1.3.0",
|
| 33 |
+
"oxfmt": "^0.43.0",
|
| 34 |
+
"oxlint": "^1.58.0",
|
| 35 |
+
"typescript": "^6.0.2",
|
| 36 |
+
"unbuild": "^3.6.1",
|
| 37 |
+
"vitest": "^4.1.2"
|
| 38 |
+
},
|
| 39 |
+
"scripts": {
|
| 40 |
+
"build": "unbuild",
|
| 41 |
+
"dev": "vitest",
|
| 42 |
+
"lint": "oxlint src && oxfmt --check src test",
|
| 43 |
+
"lint:fix": "oxlint src --fix && oxfmt src test",
|
| 44 |
+
"release": "pnpm test && pnpm build && changelogen --release && git push --follow-tags && pnpm publish",
|
| 45 |
+
"test": "pnpm lint && pnpm test:types && pnpm vitest run",
|
| 46 |
+
"test:types": "tsgo --noEmit"
|
| 47 |
+
}
|
| 48 |
+
}
|
node_modules/delayed-stream/.npmignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
test
|
node_modules/delayed-stream/License
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 2011 Debuggable Limited <felix@debuggable.com>
|
| 2 |
+
|
| 3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 4 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 5 |
+
in the Software without restriction, including without limitation the rights
|
| 6 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 7 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 8 |
+
furnished to do so, subject to the following conditions:
|
| 9 |
+
|
| 10 |
+
The above copyright notice and this permission notice shall be included in
|
| 11 |
+
all copies or substantial portions of the Software.
|
| 12 |
+
|
| 13 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 14 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 15 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 16 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 17 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 18 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 19 |
+
THE SOFTWARE.
|
node_modules/delayed-stream/Makefile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
SHELL := /bin/bash
|
| 2 |
+
|
| 3 |
+
test:
|
| 4 |
+
@./test/run.js
|
| 5 |
+
|
| 6 |
+
.PHONY: test
|
| 7 |
+
|
node_modules/delayed-stream/Readme.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# delayed-stream
|
| 2 |
+
|
| 3 |
+
Buffers events from a stream until you are ready to handle them.
|
| 4 |
+
|
| 5 |
+
## Installation
|
| 6 |
+
|
| 7 |
+
``` bash
|
| 8 |
+
npm install delayed-stream
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
## Usage
|
| 12 |
+
|
| 13 |
+
The following example shows how to write a http echo server that delays its
|
| 14 |
+
response by 1000 ms.
|
| 15 |
+
|
| 16 |
+
``` javascript
|
| 17 |
+
var DelayedStream = require('delayed-stream');
|
| 18 |
+
var http = require('http');
|
| 19 |
+
|
| 20 |
+
http.createServer(function(req, res) {
|
| 21 |
+
var delayed = DelayedStream.create(req);
|
| 22 |
+
|
| 23 |
+
setTimeout(function() {
|
| 24 |
+
res.writeHead(200);
|
| 25 |
+
delayed.pipe(res);
|
| 26 |
+
}, 1000);
|
| 27 |
+
});
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
If you are not using `Stream#pipe`, you can also manually release the buffered
|
| 31 |
+
events by calling `delayedStream.resume()`:
|
| 32 |
+
|
| 33 |
+
``` javascript
|
| 34 |
+
var delayed = DelayedStream.create(req);
|
| 35 |
+
|
| 36 |
+
setTimeout(function() {
|
| 37 |
+
// Emit all buffered events and resume underlaying source
|
| 38 |
+
delayed.resume();
|
| 39 |
+
}, 1000);
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
## Implementation
|
| 43 |
+
|
| 44 |
+
In order to use this meta stream properly, here are a few things you should
|
| 45 |
+
know about the implementation.
|
| 46 |
+
|
| 47 |
+
### Event Buffering / Proxying
|
| 48 |
+
|
| 49 |
+
All events of the `source` stream are hijacked by overwriting the `source.emit`
|
| 50 |
+
method. Until node implements a catch-all event listener, this is the only way.
|
| 51 |
+
|
| 52 |
+
However, delayed-stream still continues to emit all events it captures on the
|
| 53 |
+
`source`, regardless of whether you have released the delayed stream yet or
|
| 54 |
+
not.
|
| 55 |
+
|
| 56 |
+
Upon creation, delayed-stream captures all `source` events and stores them in
|
| 57 |
+
an internal event buffer. Once `delayedStream.release()` is called, all
|
| 58 |
+
buffered events are emitted on the `delayedStream`, and the event buffer is
|
| 59 |
+
cleared. After that, delayed-stream merely acts as a proxy for the underlaying
|
| 60 |
+
source.
|
| 61 |
+
|
| 62 |
+
### Error handling
|
| 63 |
+
|
| 64 |
+
Error events on `source` are buffered / proxied just like any other events.
|
| 65 |
+
However, `delayedStream.create` attaches a no-op `'error'` listener to the
|
| 66 |
+
`source`. This way you only have to handle errors on the `delayedStream`
|
| 67 |
+
object, rather than in two places.
|
| 68 |
+
|
| 69 |
+
### Buffer limits
|
| 70 |
+
|
| 71 |
+
delayed-stream provides a `maxDataSize` property that can be used to limit
|
| 72 |
+
the amount of data being buffered. In order to protect you from bad `source`
|
| 73 |
+
streams that don't react to `source.pause()`, this feature is enabled by
|
| 74 |
+
default.
|
| 75 |
+
|
| 76 |
+
## API
|
| 77 |
+
|
| 78 |
+
### DelayedStream.create(source, [options])
|
| 79 |
+
|
| 80 |
+
Returns a new `delayedStream`. Available options are:
|
| 81 |
+
|
| 82 |
+
* `pauseStream`
|
| 83 |
+
* `maxDataSize`
|
| 84 |
+
|
| 85 |
+
The description for those properties can be found below.
|
| 86 |
+
|
| 87 |
+
### delayedStream.source
|
| 88 |
+
|
| 89 |
+
The `source` stream managed by this object. This is useful if you are
|
| 90 |
+
passing your `delayedStream` around, and you still want to access properties
|
| 91 |
+
on the `source` object.
|
| 92 |
+
|
| 93 |
+
### delayedStream.pauseStream = true
|
| 94 |
+
|
| 95 |
+
Whether to pause the underlaying `source` when calling
|
| 96 |
+
`DelayedStream.create()`. Modifying this property afterwards has no effect.
|
| 97 |
+
|
| 98 |
+
### delayedStream.maxDataSize = 1024 * 1024
|
| 99 |
+
|
| 100 |
+
The amount of data to buffer before emitting an `error`.
|
| 101 |
+
|
| 102 |
+
If the underlaying source is emitting `Buffer` objects, the `maxDataSize`
|
| 103 |
+
refers to bytes.
|
| 104 |
+
|
| 105 |
+
If the underlaying source is emitting JavaScript strings, the size refers to
|
| 106 |
+
characters.
|
| 107 |
+
|
| 108 |
+
If you know what you are doing, you can set this property to `Infinity` to
|
| 109 |
+
disable this feature. You can also modify this property during runtime.
|
| 110 |
+
|
| 111 |
+
### delayedStream.dataSize = 0
|
| 112 |
+
|
| 113 |
+
The amount of data buffered so far.
|
| 114 |
+
|
| 115 |
+
### delayedStream.readable
|
| 116 |
+
|
| 117 |
+
An ECMA5 getter that returns the value of `source.readable`.
|
| 118 |
+
|
| 119 |
+
### delayedStream.resume()
|
| 120 |
+
|
| 121 |
+
If the `delayedStream` has not been released so far, `delayedStream.release()`
|
| 122 |
+
is called.
|
| 123 |
+
|
| 124 |
+
In either case, `source.resume()` is called.
|
| 125 |
+
|
| 126 |
+
### delayedStream.pause()
|
| 127 |
+
|
| 128 |
+
Calls `source.pause()`.
|
| 129 |
+
|
| 130 |
+
### delayedStream.pipe(dest)
|
| 131 |
+
|
| 132 |
+
Calls `delayedStream.resume()` and then proxies the arguments to `source.pipe`.
|
| 133 |
+
|
| 134 |
+
### delayedStream.release()
|
| 135 |
+
|
| 136 |
+
Emits and clears all events that have been buffered up so far. This does not
|
| 137 |
+
resume the underlaying source, use `delayedStream.resume()` instead.
|
| 138 |
+
|
| 139 |
+
## License
|
| 140 |
+
|
| 141 |
+
delayed-stream is licensed under the MIT license.
|
node_modules/delayed-stream/lib/delayed_stream.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var Stream = require('stream').Stream;
|
| 2 |
+
var util = require('util');
|
| 3 |
+
|
| 4 |
+
module.exports = DelayedStream;
|
| 5 |
+
function DelayedStream() {
|
| 6 |
+
this.source = null;
|
| 7 |
+
this.dataSize = 0;
|
| 8 |
+
this.maxDataSize = 1024 * 1024;
|
| 9 |
+
this.pauseStream = true;
|
| 10 |
+
|
| 11 |
+
this._maxDataSizeExceeded = false;
|
| 12 |
+
this._released = false;
|
| 13 |
+
this._bufferedEvents = [];
|
| 14 |
+
}
|
| 15 |
+
util.inherits(DelayedStream, Stream);
|
| 16 |
+
|
| 17 |
+
DelayedStream.create = function(source, options) {
|
| 18 |
+
var delayedStream = new this();
|
| 19 |
+
|
| 20 |
+
options = options || {};
|
| 21 |
+
for (var option in options) {
|
| 22 |
+
delayedStream[option] = options[option];
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
delayedStream.source = source;
|
| 26 |
+
|
| 27 |
+
var realEmit = source.emit;
|
| 28 |
+
source.emit = function() {
|
| 29 |
+
delayedStream._handleEmit(arguments);
|
| 30 |
+
return realEmit.apply(source, arguments);
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
+
source.on('error', function() {});
|
| 34 |
+
if (delayedStream.pauseStream) {
|
| 35 |
+
source.pause();
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
return delayedStream;
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
Object.defineProperty(DelayedStream.prototype, 'readable', {
|
| 42 |
+
configurable: true,
|
| 43 |
+
enumerable: true,
|
| 44 |
+
get: function() {
|
| 45 |
+
return this.source.readable;
|
| 46 |
+
}
|
| 47 |
+
});
|
| 48 |
+
|
| 49 |
+
DelayedStream.prototype.setEncoding = function() {
|
| 50 |
+
return this.source.setEncoding.apply(this.source, arguments);
|
| 51 |
+
};
|
| 52 |
+
|
| 53 |
+
DelayedStream.prototype.resume = function() {
|
| 54 |
+
if (!this._released) {
|
| 55 |
+
this.release();
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
this.source.resume();
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
DelayedStream.prototype.pause = function() {
|
| 62 |
+
this.source.pause();
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
DelayedStream.prototype.release = function() {
|
| 66 |
+
this._released = true;
|
| 67 |
+
|
| 68 |
+
this._bufferedEvents.forEach(function(args) {
|
| 69 |
+
this.emit.apply(this, args);
|
| 70 |
+
}.bind(this));
|
| 71 |
+
this._bufferedEvents = [];
|
| 72 |
+
};
|
| 73 |
+
|
| 74 |
+
DelayedStream.prototype.pipe = function() {
|
| 75 |
+
var r = Stream.prototype.pipe.apply(this, arguments);
|
| 76 |
+
this.resume();
|
| 77 |
+
return r;
|
| 78 |
+
};
|
| 79 |
+
|
| 80 |
+
DelayedStream.prototype._handleEmit = function(args) {
|
| 81 |
+
if (this._released) {
|
| 82 |
+
this.emit.apply(this, args);
|
| 83 |
+
return;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
if (args[0] === 'data') {
|
| 87 |
+
this.dataSize += args[1].length;
|
| 88 |
+
this._checkIfMaxDataSizeExceeded();
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
this._bufferedEvents.push(args);
|
| 92 |
+
};
|
| 93 |
+
|
| 94 |
+
DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
| 95 |
+
if (this._maxDataSizeExceeded) {
|
| 96 |
+
return;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
if (this.dataSize <= this.maxDataSize) {
|
| 100 |
+
return;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
this._maxDataSizeExceeded = true;
|
| 104 |
+
var message =
|
| 105 |
+
'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'
|
| 106 |
+
this.emit('error', new Error(message));
|
| 107 |
+
};
|
node_modules/delayed-stream/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)",
|
| 3 |
+
"contributors": [
|
| 4 |
+
"Mike Atkins <apeherder@gmail.com>"
|
| 5 |
+
],
|
| 6 |
+
"name": "delayed-stream",
|
| 7 |
+
"description": "Buffers events from a stream until you are ready to handle them.",
|
| 8 |
+
"license": "MIT",
|
| 9 |
+
"version": "1.0.0",
|
| 10 |
+
"homepage": "https://github.com/felixge/node-delayed-stream",
|
| 11 |
+
"repository": {
|
| 12 |
+
"type": "git",
|
| 13 |
+
"url": "git://github.com/felixge/node-delayed-stream.git"
|
| 14 |
+
},
|
| 15 |
+
"main": "./lib/delayed_stream",
|
| 16 |
+
"engines": {
|
| 17 |
+
"node": ">=0.4.0"
|
| 18 |
+
},
|
| 19 |
+
"scripts": {
|
| 20 |
+
"test": "make test"
|
| 21 |
+
},
|
| 22 |
+
"dependencies": {},
|
| 23 |
+
"devDependencies": {
|
| 24 |
+
"fake": "0.2.0",
|
| 25 |
+
"far": "0.0.1"
|
| 26 |
+
}
|
| 27 |
+
}
|
node_modules/depd/History.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
2.0.0 / 2018-10-26
|
| 2 |
+
==================
|
| 3 |
+
|
| 4 |
+
* Drop support for Node.js 0.6
|
| 5 |
+
* Replace internal `eval` usage with `Function` constructor
|
| 6 |
+
* Use instance methods on `process` to check for listeners
|
| 7 |
+
|
| 8 |
+
1.1.2 / 2018-01-11
|
| 9 |
+
==================
|
| 10 |
+
|
| 11 |
+
* perf: remove argument reassignment
|
| 12 |
+
* Support Node.js 0.6 to 9.x
|
| 13 |
+
|
| 14 |
+
1.1.1 / 2017-07-27
|
| 15 |
+
==================
|
| 16 |
+
|
| 17 |
+
* Remove unnecessary `Buffer` loading
|
| 18 |
+
* Support Node.js 0.6 to 8.x
|
| 19 |
+
|
| 20 |
+
1.1.0 / 2015-09-14
|
| 21 |
+
==================
|
| 22 |
+
|
| 23 |
+
* Enable strict mode in more places
|
| 24 |
+
* Support io.js 3.x
|
| 25 |
+
* Support io.js 2.x
|
| 26 |
+
* Support web browser loading
|
| 27 |
+
- Requires bundler like Browserify or webpack
|
| 28 |
+
|
| 29 |
+
1.0.1 / 2015-04-07
|
| 30 |
+
==================
|
| 31 |
+
|
| 32 |
+
* Fix `TypeError`s when under `'use strict'` code
|
| 33 |
+
* Fix useless type name on auto-generated messages
|
| 34 |
+
* Support io.js 1.x
|
| 35 |
+
* Support Node.js 0.12
|
| 36 |
+
|
| 37 |
+
1.0.0 / 2014-09-17
|
| 38 |
+
==================
|
| 39 |
+
|
| 40 |
+
* No changes
|
| 41 |
+
|
| 42 |
+
0.4.5 / 2014-09-09
|
| 43 |
+
==================
|
| 44 |
+
|
| 45 |
+
* Improve call speed to functions using the function wrapper
|
| 46 |
+
* Support Node.js 0.6
|
| 47 |
+
|
| 48 |
+
0.4.4 / 2014-07-27
|
| 49 |
+
==================
|
| 50 |
+
|
| 51 |
+
* Work-around v8 generating empty stack traces
|
| 52 |
+
|
| 53 |
+
0.4.3 / 2014-07-26
|
| 54 |
+
==================
|
| 55 |
+
|
| 56 |
+
* Fix exception when global `Error.stackTraceLimit` is too low
|
| 57 |
+
|
| 58 |
+
0.4.2 / 2014-07-19
|
| 59 |
+
==================
|
| 60 |
+
|
| 61 |
+
* Correct call site for wrapped functions and properties
|
| 62 |
+
|
| 63 |
+
0.4.1 / 2014-07-19
|
| 64 |
+
==================
|
| 65 |
+
|
| 66 |
+
* Improve automatic message generation for function properties
|
| 67 |
+
|
| 68 |
+
0.4.0 / 2014-07-19
|
| 69 |
+
==================
|
| 70 |
+
|
| 71 |
+
* Add `TRACE_DEPRECATION` environment variable
|
| 72 |
+
* Remove non-standard grey color from color output
|
| 73 |
+
* Support `--no-deprecation` argument
|
| 74 |
+
* Support `--trace-deprecation` argument
|
| 75 |
+
* Support `deprecate.property(fn, prop, message)`
|
| 76 |
+
|
| 77 |
+
0.3.0 / 2014-06-16
|
| 78 |
+
==================
|
| 79 |
+
|
| 80 |
+
* Add `NO_DEPRECATION` environment variable
|
| 81 |
+
|
| 82 |
+
0.2.0 / 2014-06-15
|
| 83 |
+
==================
|
| 84 |
+
|
| 85 |
+
* Add `deprecate.property(obj, prop, message)`
|
| 86 |
+
* Remove `supports-color` dependency for node.js 0.8
|
| 87 |
+
|
| 88 |
+
0.1.0 / 2014-06-15
|
| 89 |
+
==================
|
| 90 |
+
|
| 91 |
+
* Add `deprecate.function(fn, message)`
|
| 92 |
+
* Add `process.on('deprecation', fn)` emitter
|
| 93 |
+
* Automatically generate message when omitted from `deprecate()`
|
| 94 |
+
|
| 95 |
+
0.0.1 / 2014-06-15
|
| 96 |
+
==================
|
| 97 |
+
|
| 98 |
+
* Fix warning for dynamic calls at singe call site
|
| 99 |
+
|
| 100 |
+
0.0.0 / 2014-06-15
|
| 101 |
+
==================
|
| 102 |
+
|
| 103 |
+
* Initial implementation
|
node_modules/depd/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(The MIT License)
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2014-2018 Douglas Christopher Wilson
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining
|
| 6 |
+
a copy of this software and associated documentation files (the
|
| 7 |
+
'Software'), to deal in the Software without restriction, including
|
| 8 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 9 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 10 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 11 |
+
the following conditions:
|
| 12 |
+
|
| 13 |
+
The above copyright notice and this permission notice shall be
|
| 14 |
+
included in all copies or substantial portions of the Software.
|
| 15 |
+
|
| 16 |
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
| 17 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 18 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
| 19 |
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
| 20 |
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
| 21 |
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
| 22 |
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
node_modules/depd/Readme.md
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# depd
|
| 2 |
+
|
| 3 |
+
[![NPM Version][npm-version-image]][npm-url]
|
| 4 |
+
[![NPM Downloads][npm-downloads-image]][npm-url]
|
| 5 |
+
[![Node.js Version][node-image]][node-url]
|
| 6 |
+
[![Linux Build][travis-image]][travis-url]
|
| 7 |
+
[![Windows Build][appveyor-image]][appveyor-url]
|
| 8 |
+
[![Coverage Status][coveralls-image]][coveralls-url]
|
| 9 |
+
|
| 10 |
+
Deprecate all the things
|
| 11 |
+
|
| 12 |
+
> With great modules comes great responsibility; mark things deprecated!
|
| 13 |
+
|
| 14 |
+
## Install
|
| 15 |
+
|
| 16 |
+
This module is installed directly using `npm`:
|
| 17 |
+
|
| 18 |
+
```sh
|
| 19 |
+
$ npm install depd
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
This module can also be bundled with systems like
|
| 23 |
+
[Browserify](http://browserify.org/) or [webpack](https://webpack.github.io/),
|
| 24 |
+
though by default this module will alter it's API to no longer display or
|
| 25 |
+
track deprecations.
|
| 26 |
+
|
| 27 |
+
## API
|
| 28 |
+
|
| 29 |
+
<!-- eslint-disable no-unused-vars -->
|
| 30 |
+
|
| 31 |
+
```js
|
| 32 |
+
var deprecate = require('depd')('my-module')
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
This library allows you to display deprecation messages to your users.
|
| 36 |
+
This library goes above and beyond with deprecation warnings by
|
| 37 |
+
introspection of the call stack (but only the bits that it is interested
|
| 38 |
+
in).
|
| 39 |
+
|
| 40 |
+
Instead of just warning on the first invocation of a deprecated
|
| 41 |
+
function and never again, this module will warn on the first invocation
|
| 42 |
+
of a deprecated function per unique call site, making it ideal to alert
|
| 43 |
+
users of all deprecated uses across the code base, rather than just
|
| 44 |
+
whatever happens to execute first.
|
| 45 |
+
|
| 46 |
+
The deprecation warnings from this module also include the file and line
|
| 47 |
+
information for the call into the module that the deprecated function was
|
| 48 |
+
in.
|
| 49 |
+
|
| 50 |
+
**NOTE** this library has a similar interface to the `debug` module, and
|
| 51 |
+
this module uses the calling file to get the boundary for the call stacks,
|
| 52 |
+
so you should always create a new `deprecate` object in each file and not
|
| 53 |
+
within some central file.
|
| 54 |
+
|
| 55 |
+
### depd(namespace)
|
| 56 |
+
|
| 57 |
+
Create a new deprecate function that uses the given namespace name in the
|
| 58 |
+
messages and will display the call site prior to the stack entering the
|
| 59 |
+
file this function was called from. It is highly suggested you use the
|
| 60 |
+
name of your module as the namespace.
|
| 61 |
+
|
| 62 |
+
### deprecate(message)
|
| 63 |
+
|
| 64 |
+
Call this function from deprecated code to display a deprecation message.
|
| 65 |
+
This message will appear once per unique caller site. Caller site is the
|
| 66 |
+
first call site in the stack in a different file from the caller of this
|
| 67 |
+
function.
|
| 68 |
+
|
| 69 |
+
If the message is omitted, a message is generated for you based on the site
|
| 70 |
+
of the `deprecate()` call and will display the name of the function called,
|
| 71 |
+
similar to the name displayed in a stack trace.
|
| 72 |
+
|
| 73 |
+
### deprecate.function(fn, message)
|
| 74 |
+
|
| 75 |
+
Call this function to wrap a given function in a deprecation message on any
|
| 76 |
+
call to the function. An optional message can be supplied to provide a custom
|
| 77 |
+
message.
|
| 78 |
+
|
| 79 |
+
### deprecate.property(obj, prop, message)
|
| 80 |
+
|
| 81 |
+
Call this function to wrap a given property on object in a deprecation message
|
| 82 |
+
on any accessing or setting of the property. An optional message can be supplied
|
| 83 |
+
to provide a custom message.
|
| 84 |
+
|
| 85 |
+
The method must be called on the object where the property belongs (not
|
| 86 |
+
inherited from the prototype).
|
| 87 |
+
|
| 88 |
+
If the property is a data descriptor, it will be converted to an accessor
|
| 89 |
+
descriptor in order to display the deprecation message.
|
| 90 |
+
|
| 91 |
+
### process.on('deprecation', fn)
|
| 92 |
+
|
| 93 |
+
This module will allow easy capturing of deprecation errors by emitting the
|
| 94 |
+
errors as the type "deprecation" on the global `process`. If there are no
|
| 95 |
+
listeners for this type, the errors are written to STDERR as normal, but if
|
| 96 |
+
there are any listeners, nothing will be written to STDERR and instead only
|
| 97 |
+
emitted. From there, you can write the errors in a different format or to a
|
| 98 |
+
logging source.
|
| 99 |
+
|
| 100 |
+
The error represents the deprecation and is emitted only once with the same
|
| 101 |
+
rules as writing to STDERR. The error has the following properties:
|
| 102 |
+
|
| 103 |
+
- `message` - This is the message given by the library
|
| 104 |
+
- `name` - This is always `'DeprecationError'`
|
| 105 |
+
- `namespace` - This is the namespace the deprecation came from
|
| 106 |
+
- `stack` - This is the stack of the call to the deprecated thing
|
| 107 |
+
|
| 108 |
+
Example `error.stack` output:
|
| 109 |
+
|
| 110 |
+
```
|
| 111 |
+
DeprecationError: my-cool-module deprecated oldfunction
|
| 112 |
+
at Object.<anonymous> ([eval]-wrapper:6:22)
|
| 113 |
+
at Module._compile (module.js:456:26)
|
| 114 |
+
at evalScript (node.js:532:25)
|
| 115 |
+
at startup (node.js:80:7)
|
| 116 |
+
at node.js:902:3
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
### process.env.NO_DEPRECATION
|
| 120 |
+
|
| 121 |
+
As a user of modules that are deprecated, the environment variable `NO_DEPRECATION`
|
| 122 |
+
is provided as a quick solution to silencing deprecation warnings from being
|
| 123 |
+
output. The format of this is similar to that of `DEBUG`:
|
| 124 |
+
|
| 125 |
+
```sh
|
| 126 |
+
$ NO_DEPRECATION=my-module,othermod node app.js
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
This will suppress deprecations from being output for "my-module" and "othermod".
|
| 130 |
+
The value is a list of comma-separated namespaces. To suppress every warning
|
| 131 |
+
across all namespaces, use the value `*` for a namespace.
|
| 132 |
+
|
| 133 |
+
Providing the argument `--no-deprecation` to the `node` executable will suppress
|
| 134 |
+
all deprecations (only available in Node.js 0.8 or higher).
|
| 135 |
+
|
| 136 |
+
**NOTE** This will not suppress the deperecations given to any "deprecation"
|
| 137 |
+
event listeners, just the output to STDERR.
|
| 138 |
+
|
| 139 |
+
### process.env.TRACE_DEPRECATION
|
| 140 |
+
|
| 141 |
+
As a user of modules that are deprecated, the environment variable `TRACE_DEPRECATION`
|
| 142 |
+
is provided as a solution to getting more detailed location information in deprecation
|
| 143 |
+
warnings by including the entire stack trace. The format of this is the same as
|
| 144 |
+
`NO_DEPRECATION`:
|
| 145 |
+
|
| 146 |
+
```sh
|
| 147 |
+
$ TRACE_DEPRECATION=my-module,othermod node app.js
|
| 148 |
+
```
|
| 149 |
+
|
| 150 |
+
This will include stack traces for deprecations being output for "my-module" and
|
| 151 |
+
"othermod". The value is a list of comma-separated namespaces. To trace every
|
| 152 |
+
warning across all namespaces, use the value `*` for a namespace.
|
| 153 |
+
|
| 154 |
+
Providing the argument `--trace-deprecation` to the `node` executable will trace
|
| 155 |
+
all deprecations (only available in Node.js 0.8 or higher).
|
| 156 |
+
|
| 157 |
+
**NOTE** This will not trace the deperecations silenced by `NO_DEPRECATION`.
|
| 158 |
+
|
| 159 |
+
## Display
|
| 160 |
+
|
| 161 |
+

|
| 162 |
+
|
| 163 |
+
When a user calls a function in your library that you mark deprecated, they
|
| 164 |
+
will see the following written to STDERR (in the given colors, similar colors
|
| 165 |
+
and layout to the `debug` module):
|
| 166 |
+
|
| 167 |
+
```
|
| 168 |
+
bright cyan bright yellow
|
| 169 |
+
| | reset cyan
|
| 170 |
+
| | | |
|
| 171 |
+
▼ ▼ ▼ ▼
|
| 172 |
+
my-cool-module deprecated oldfunction [eval]-wrapper:6:22
|
| 173 |
+
▲ ▲ ▲ ▲
|
| 174 |
+
| | | |
|
| 175 |
+
namespace | | location of mycoolmod.oldfunction() call
|
| 176 |
+
| deprecation message
|
| 177 |
+
the word "deprecated"
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
If the user redirects their STDERR to a file or somewhere that does not support
|
| 181 |
+
colors, they see (similar layout to the `debug` module):
|
| 182 |
+
|
| 183 |
+
```
|
| 184 |
+
Sun, 15 Jun 2014 05:21:37 GMT my-cool-module deprecated oldfunction at [eval]-wrapper:6:22
|
| 185 |
+
▲ ▲ ▲ ▲ ▲
|
| 186 |
+
| | | | |
|
| 187 |
+
timestamp of message namespace | | location of mycoolmod.oldfunction() call
|
| 188 |
+
| deprecation message
|
| 189 |
+
the word "deprecated"
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
## Examples
|
| 193 |
+
|
| 194 |
+
### Deprecating all calls to a function
|
| 195 |
+
|
| 196 |
+
This will display a deprecated message about "oldfunction" being deprecated
|
| 197 |
+
from "my-module" on STDERR.
|
| 198 |
+
|
| 199 |
+
```js
|
| 200 |
+
var deprecate = require('depd')('my-cool-module')
|
| 201 |
+
|
| 202 |
+
// message automatically derived from function name
|
| 203 |
+
// Object.oldfunction
|
| 204 |
+
exports.oldfunction = deprecate.function(function oldfunction () {
|
| 205 |
+
// all calls to function are deprecated
|
| 206 |
+
})
|
| 207 |
+
|
| 208 |
+
// specific message
|
| 209 |
+
exports.oldfunction = deprecate.function(function () {
|
| 210 |
+
// all calls to function are deprecated
|
| 211 |
+
}, 'oldfunction')
|
| 212 |
+
```
|
| 213 |
+
|
| 214 |
+
### Conditionally deprecating a function call
|
| 215 |
+
|
| 216 |
+
This will display a deprecated message about "weirdfunction" being deprecated
|
| 217 |
+
from "my-module" on STDERR when called with less than 2 arguments.
|
| 218 |
+
|
| 219 |
+
```js
|
| 220 |
+
var deprecate = require('depd')('my-cool-module')
|
| 221 |
+
|
| 222 |
+
exports.weirdfunction = function () {
|
| 223 |
+
if (arguments.length < 2) {
|
| 224 |
+
// calls with 0 or 1 args are deprecated
|
| 225 |
+
deprecate('weirdfunction args < 2')
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
When calling `deprecate` as a function, the warning is counted per call site
|
| 231 |
+
within your own module, so you can display different deprecations depending
|
| 232 |
+
on different situations and the users will still get all the warnings:
|
| 233 |
+
|
| 234 |
+
```js
|
| 235 |
+
var deprecate = require('depd')('my-cool-module')
|
| 236 |
+
|
| 237 |
+
exports.weirdfunction = function () {
|
| 238 |
+
if (arguments.length < 2) {
|
| 239 |
+
// calls with 0 or 1 args are deprecated
|
| 240 |
+
deprecate('weirdfunction args < 2')
|
| 241 |
+
} else if (typeof arguments[0] !== 'string') {
|
| 242 |
+
// calls with non-string first argument are deprecated
|
| 243 |
+
deprecate('weirdfunction non-string first arg')
|
| 244 |
+
}
|
| 245 |
+
}
|
| 246 |
+
```
|
| 247 |
+
|
| 248 |
+
### Deprecating property access
|
| 249 |
+
|
| 250 |
+
This will display a deprecated message about "oldprop" being deprecated
|
| 251 |
+
from "my-module" on STDERR when accessed. A deprecation will be displayed
|
| 252 |
+
when setting the value and when getting the value.
|
| 253 |
+
|
| 254 |
+
```js
|
| 255 |
+
var deprecate = require('depd')('my-cool-module')
|
| 256 |
+
|
| 257 |
+
exports.oldprop = 'something'
|
| 258 |
+
|
| 259 |
+
// message automatically derives from property name
|
| 260 |
+
deprecate.property(exports, 'oldprop')
|
| 261 |
+
|
| 262 |
+
// explicit message
|
| 263 |
+
deprecate.property(exports, 'oldprop', 'oldprop >= 0.10')
|
| 264 |
+
```
|
| 265 |
+
|
| 266 |
+
## License
|
| 267 |
+
|
| 268 |
+
[MIT](LICENSE)
|
| 269 |
+
|
| 270 |
+
[appveyor-image]: https://badgen.net/appveyor/ci/dougwilson/nodejs-depd/master?label=windows
|
| 271 |
+
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/nodejs-depd
|
| 272 |
+
[coveralls-image]: https://badgen.net/coveralls/c/github/dougwilson/nodejs-depd/master
|
| 273 |
+
[coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master
|
| 274 |
+
[node-image]: https://badgen.net/npm/node/depd
|
| 275 |
+
[node-url]: https://nodejs.org/en/download/
|
| 276 |
+
[npm-downloads-image]: https://badgen.net/npm/dm/depd
|
| 277 |
+
[npm-url]: https://npmjs.org/package/depd
|
| 278 |
+
[npm-version-image]: https://badgen.net/npm/v/depd
|
| 279 |
+
[travis-image]: https://badgen.net/travis/dougwilson/nodejs-depd/master?label=linux
|
| 280 |
+
[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd
|
node_modules/depd/index.js
ADDED
|
@@ -0,0 +1,538 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*!
|
| 2 |
+
* depd
|
| 3 |
+
* Copyright(c) 2014-2018 Douglas Christopher Wilson
|
| 4 |
+
* MIT Licensed
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Module dependencies.
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
var relative = require('path').relative
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Module exports.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
module.exports = depd
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Get the path to base files on.
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
var basePath = process.cwd()
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Determine if namespace is contained in the string.
|
| 27 |
+
*/
|
| 28 |
+
|
| 29 |
+
function containsNamespace (str, namespace) {
|
| 30 |
+
var vals = str.split(/[ ,]+/)
|
| 31 |
+
var ns = String(namespace).toLowerCase()
|
| 32 |
+
|
| 33 |
+
for (var i = 0; i < vals.length; i++) {
|
| 34 |
+
var val = vals[i]
|
| 35 |
+
|
| 36 |
+
// namespace contained
|
| 37 |
+
if (val && (val === '*' || val.toLowerCase() === ns)) {
|
| 38 |
+
return true
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
return false
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Convert a data descriptor to accessor descriptor.
|
| 47 |
+
*/
|
| 48 |
+
|
| 49 |
+
function convertDataDescriptorToAccessor (obj, prop, message) {
|
| 50 |
+
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
| 51 |
+
var value = descriptor.value
|
| 52 |
+
|
| 53 |
+
descriptor.get = function getter () { return value }
|
| 54 |
+
|
| 55 |
+
if (descriptor.writable) {
|
| 56 |
+
descriptor.set = function setter (val) { return (value = val) }
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
delete descriptor.value
|
| 60 |
+
delete descriptor.writable
|
| 61 |
+
|
| 62 |
+
Object.defineProperty(obj, prop, descriptor)
|
| 63 |
+
|
| 64 |
+
return descriptor
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* Create arguments string to keep arity.
|
| 69 |
+
*/
|
| 70 |
+
|
| 71 |
+
function createArgumentsString (arity) {
|
| 72 |
+
var str = ''
|
| 73 |
+
|
| 74 |
+
for (var i = 0; i < arity; i++) {
|
| 75 |
+
str += ', arg' + i
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
return str.substr(2)
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Create stack string from stack.
|
| 83 |
+
*/
|
| 84 |
+
|
| 85 |
+
function createStackString (stack) {
|
| 86 |
+
var str = this.name + ': ' + this.namespace
|
| 87 |
+
|
| 88 |
+
if (this.message) {
|
| 89 |
+
str += ' deprecated ' + this.message
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
for (var i = 0; i < stack.length; i++) {
|
| 93 |
+
str += '\n at ' + stack[i].toString()
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
return str
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* Create deprecate for namespace in caller.
|
| 101 |
+
*/
|
| 102 |
+
|
| 103 |
+
function depd (namespace) {
|
| 104 |
+
if (!namespace) {
|
| 105 |
+
throw new TypeError('argument namespace is required')
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
var stack = getStack()
|
| 109 |
+
var site = callSiteLocation(stack[1])
|
| 110 |
+
var file = site[0]
|
| 111 |
+
|
| 112 |
+
function deprecate (message) {
|
| 113 |
+
// call to self as log
|
| 114 |
+
log.call(deprecate, message)
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
deprecate._file = file
|
| 118 |
+
deprecate._ignored = isignored(namespace)
|
| 119 |
+
deprecate._namespace = namespace
|
| 120 |
+
deprecate._traced = istraced(namespace)
|
| 121 |
+
deprecate._warned = Object.create(null)
|
| 122 |
+
|
| 123 |
+
deprecate.function = wrapfunction
|
| 124 |
+
deprecate.property = wrapproperty
|
| 125 |
+
|
| 126 |
+
return deprecate
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/**
|
| 130 |
+
* Determine if event emitter has listeners of a given type.
|
| 131 |
+
*
|
| 132 |
+
* The way to do this check is done three different ways in Node.js >= 0.8
|
| 133 |
+
* so this consolidates them into a minimal set using instance methods.
|
| 134 |
+
*
|
| 135 |
+
* @param {EventEmitter} emitter
|
| 136 |
+
* @param {string} type
|
| 137 |
+
* @returns {boolean}
|
| 138 |
+
* @private
|
| 139 |
+
*/
|
| 140 |
+
|
| 141 |
+
function eehaslisteners (emitter, type) {
|
| 142 |
+
var count = typeof emitter.listenerCount !== 'function'
|
| 143 |
+
? emitter.listeners(type).length
|
| 144 |
+
: emitter.listenerCount(type)
|
| 145 |
+
|
| 146 |
+
return count > 0
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
/**
|
| 150 |
+
* Determine if namespace is ignored.
|
| 151 |
+
*/
|
| 152 |
+
|
| 153 |
+
function isignored (namespace) {
|
| 154 |
+
if (process.noDeprecation) {
|
| 155 |
+
// --no-deprecation support
|
| 156 |
+
return true
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
var str = process.env.NO_DEPRECATION || ''
|
| 160 |
+
|
| 161 |
+
// namespace ignored
|
| 162 |
+
return containsNamespace(str, namespace)
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* Determine if namespace is traced.
|
| 167 |
+
*/
|
| 168 |
+
|
| 169 |
+
function istraced (namespace) {
|
| 170 |
+
if (process.traceDeprecation) {
|
| 171 |
+
// --trace-deprecation support
|
| 172 |
+
return true
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
var str = process.env.TRACE_DEPRECATION || ''
|
| 176 |
+
|
| 177 |
+
// namespace traced
|
| 178 |
+
return containsNamespace(str, namespace)
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* Display deprecation message.
|
| 183 |
+
*/
|
| 184 |
+
|
| 185 |
+
function log (message, site) {
|
| 186 |
+
var haslisteners = eehaslisteners(process, 'deprecation')
|
| 187 |
+
|
| 188 |
+
// abort early if no destination
|
| 189 |
+
if (!haslisteners && this._ignored) {
|
| 190 |
+
return
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
var caller
|
| 194 |
+
var callFile
|
| 195 |
+
var callSite
|
| 196 |
+
var depSite
|
| 197 |
+
var i = 0
|
| 198 |
+
var seen = false
|
| 199 |
+
var stack = getStack()
|
| 200 |
+
var file = this._file
|
| 201 |
+
|
| 202 |
+
if (site) {
|
| 203 |
+
// provided site
|
| 204 |
+
depSite = site
|
| 205 |
+
callSite = callSiteLocation(stack[1])
|
| 206 |
+
callSite.name = depSite.name
|
| 207 |
+
file = callSite[0]
|
| 208 |
+
} else {
|
| 209 |
+
// get call site
|
| 210 |
+
i = 2
|
| 211 |
+
depSite = callSiteLocation(stack[i])
|
| 212 |
+
callSite = depSite
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
// get caller of deprecated thing in relation to file
|
| 216 |
+
for (; i < stack.length; i++) {
|
| 217 |
+
caller = callSiteLocation(stack[i])
|
| 218 |
+
callFile = caller[0]
|
| 219 |
+
|
| 220 |
+
if (callFile === file) {
|
| 221 |
+
seen = true
|
| 222 |
+
} else if (callFile === this._file) {
|
| 223 |
+
file = this._file
|
| 224 |
+
} else if (seen) {
|
| 225 |
+
break
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
var key = caller
|
| 230 |
+
? depSite.join(':') + '__' + caller.join(':')
|
| 231 |
+
: undefined
|
| 232 |
+
|
| 233 |
+
if (key !== undefined && key in this._warned) {
|
| 234 |
+
// already warned
|
| 235 |
+
return
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
this._warned[key] = true
|
| 239 |
+
|
| 240 |
+
// generate automatic message from call site
|
| 241 |
+
var msg = message
|
| 242 |
+
if (!msg) {
|
| 243 |
+
msg = callSite === depSite || !callSite.name
|
| 244 |
+
? defaultMessage(depSite)
|
| 245 |
+
: defaultMessage(callSite)
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
// emit deprecation if listeners exist
|
| 249 |
+
if (haslisteners) {
|
| 250 |
+
var err = DeprecationError(this._namespace, msg, stack.slice(i))
|
| 251 |
+
process.emit('deprecation', err)
|
| 252 |
+
return
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
// format and write message
|
| 256 |
+
var format = process.stderr.isTTY
|
| 257 |
+
? formatColor
|
| 258 |
+
: formatPlain
|
| 259 |
+
var output = format.call(this, msg, caller, stack.slice(i))
|
| 260 |
+
process.stderr.write(output + '\n', 'utf8')
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
/**
|
| 264 |
+
* Get call site location as array.
|
| 265 |
+
*/
|
| 266 |
+
|
| 267 |
+
function callSiteLocation (callSite) {
|
| 268 |
+
var file = callSite.getFileName() || '<anonymous>'
|
| 269 |
+
var line = callSite.getLineNumber()
|
| 270 |
+
var colm = callSite.getColumnNumber()
|
| 271 |
+
|
| 272 |
+
if (callSite.isEval()) {
|
| 273 |
+
file = callSite.getEvalOrigin() + ', ' + file
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
var site = [file, line, colm]
|
| 277 |
+
|
| 278 |
+
site.callSite = callSite
|
| 279 |
+
site.name = callSite.getFunctionName()
|
| 280 |
+
|
| 281 |
+
return site
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
/**
|
| 285 |
+
* Generate a default message from the site.
|
| 286 |
+
*/
|
| 287 |
+
|
| 288 |
+
function defaultMessage (site) {
|
| 289 |
+
var callSite = site.callSite
|
| 290 |
+
var funcName = site.name
|
| 291 |
+
|
| 292 |
+
// make useful anonymous name
|
| 293 |
+
if (!funcName) {
|
| 294 |
+
funcName = '<anonymous@' + formatLocation(site) + '>'
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
var context = callSite.getThis()
|
| 298 |
+
var typeName = context && callSite.getTypeName()
|
| 299 |
+
|
| 300 |
+
// ignore useless type name
|
| 301 |
+
if (typeName === 'Object') {
|
| 302 |
+
typeName = undefined
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
// make useful type name
|
| 306 |
+
if (typeName === 'Function') {
|
| 307 |
+
typeName = context.name || typeName
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
return typeName && callSite.getMethodName()
|
| 311 |
+
? typeName + '.' + funcName
|
| 312 |
+
: funcName
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
/**
|
| 316 |
+
* Format deprecation message without color.
|
| 317 |
+
*/
|
| 318 |
+
|
| 319 |
+
function formatPlain (msg, caller, stack) {
|
| 320 |
+
var timestamp = new Date().toUTCString()
|
| 321 |
+
|
| 322 |
+
var formatted = timestamp +
|
| 323 |
+
' ' + this._namespace +
|
| 324 |
+
' deprecated ' + msg
|
| 325 |
+
|
| 326 |
+
// add stack trace
|
| 327 |
+
if (this._traced) {
|
| 328 |
+
for (var i = 0; i < stack.length; i++) {
|
| 329 |
+
formatted += '\n at ' + stack[i].toString()
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
return formatted
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
if (caller) {
|
| 336 |
+
formatted += ' at ' + formatLocation(caller)
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
return formatted
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
/**
|
| 343 |
+
* Format deprecation message with color.
|
| 344 |
+
*/
|
| 345 |
+
|
| 346 |
+
function formatColor (msg, caller, stack) {
|
| 347 |
+
var formatted = '\x1b[36;1m' + this._namespace + '\x1b[22;39m' + // bold cyan
|
| 348 |
+
' \x1b[33;1mdeprecated\x1b[22;39m' + // bold yellow
|
| 349 |
+
' \x1b[0m' + msg + '\x1b[39m' // reset
|
| 350 |
+
|
| 351 |
+
// add stack trace
|
| 352 |
+
if (this._traced) {
|
| 353 |
+
for (var i = 0; i < stack.length; i++) {
|
| 354 |
+
formatted += '\n \x1b[36mat ' + stack[i].toString() + '\x1b[39m' // cyan
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
return formatted
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
if (caller) {
|
| 361 |
+
formatted += ' \x1b[36m' + formatLocation(caller) + '\x1b[39m' // cyan
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
return formatted
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
/**
|
| 368 |
+
* Format call site location.
|
| 369 |
+
*/
|
| 370 |
+
|
| 371 |
+
function formatLocation (callSite) {
|
| 372 |
+
return relative(basePath, callSite[0]) +
|
| 373 |
+
':' + callSite[1] +
|
| 374 |
+
':' + callSite[2]
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
/**
|
| 378 |
+
* Get the stack as array of call sites.
|
| 379 |
+
*/
|
| 380 |
+
|
| 381 |
+
function getStack () {
|
| 382 |
+
var limit = Error.stackTraceLimit
|
| 383 |
+
var obj = {}
|
| 384 |
+
var prep = Error.prepareStackTrace
|
| 385 |
+
|
| 386 |
+
Error.prepareStackTrace = prepareObjectStackTrace
|
| 387 |
+
Error.stackTraceLimit = Math.max(10, limit)
|
| 388 |
+
|
| 389 |
+
// capture the stack
|
| 390 |
+
Error.captureStackTrace(obj)
|
| 391 |
+
|
| 392 |
+
// slice this function off the top
|
| 393 |
+
var stack = obj.stack.slice(1)
|
| 394 |
+
|
| 395 |
+
Error.prepareStackTrace = prep
|
| 396 |
+
Error.stackTraceLimit = limit
|
| 397 |
+
|
| 398 |
+
return stack
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
/**
|
| 402 |
+
* Capture call site stack from v8.
|
| 403 |
+
*/
|
| 404 |
+
|
| 405 |
+
function prepareObjectStackTrace (obj, stack) {
|
| 406 |
+
return stack
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
/**
|
| 410 |
+
* Return a wrapped function in a deprecation message.
|
| 411 |
+
*/
|
| 412 |
+
|
| 413 |
+
function wrapfunction (fn, message) {
|
| 414 |
+
if (typeof fn !== 'function') {
|
| 415 |
+
throw new TypeError('argument fn must be a function')
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
var args = createArgumentsString(fn.length)
|
| 419 |
+
var stack = getStack()
|
| 420 |
+
var site = callSiteLocation(stack[1])
|
| 421 |
+
|
| 422 |
+
site.name = fn.name
|
| 423 |
+
|
| 424 |
+
// eslint-disable-next-line no-new-func
|
| 425 |
+
var deprecatedfn = new Function('fn', 'log', 'deprecate', 'message', 'site',
|
| 426 |
+
'"use strict"\n' +
|
| 427 |
+
'return function (' + args + ') {' +
|
| 428 |
+
'log.call(deprecate, message, site)\n' +
|
| 429 |
+
'return fn.apply(this, arguments)\n' +
|
| 430 |
+
'}')(fn, log, this, message, site)
|
| 431 |
+
|
| 432 |
+
return deprecatedfn
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
/**
|
| 436 |
+
* Wrap property in a deprecation message.
|
| 437 |
+
*/
|
| 438 |
+
|
| 439 |
+
function wrapproperty (obj, prop, message) {
|
| 440 |
+
if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
| 441 |
+
throw new TypeError('argument obj must be object')
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
| 445 |
+
|
| 446 |
+
if (!descriptor) {
|
| 447 |
+
throw new TypeError('must call property on owner object')
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
if (!descriptor.configurable) {
|
| 451 |
+
throw new TypeError('property must be configurable')
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
var deprecate = this
|
| 455 |
+
var stack = getStack()
|
| 456 |
+
var site = callSiteLocation(stack[1])
|
| 457 |
+
|
| 458 |
+
// set site name
|
| 459 |
+
site.name = prop
|
| 460 |
+
|
| 461 |
+
// convert data descriptor
|
| 462 |
+
if ('value' in descriptor) {
|
| 463 |
+
descriptor = convertDataDescriptorToAccessor(obj, prop, message)
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
var get = descriptor.get
|
| 467 |
+
var set = descriptor.set
|
| 468 |
+
|
| 469 |
+
// wrap getter
|
| 470 |
+
if (typeof get === 'function') {
|
| 471 |
+
descriptor.get = function getter () {
|
| 472 |
+
log.call(deprecate, message, site)
|
| 473 |
+
return get.apply(this, arguments)
|
| 474 |
+
}
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
// wrap setter
|
| 478 |
+
if (typeof set === 'function') {
|
| 479 |
+
descriptor.set = function setter () {
|
| 480 |
+
log.call(deprecate, message, site)
|
| 481 |
+
return set.apply(this, arguments)
|
| 482 |
+
}
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
Object.defineProperty(obj, prop, descriptor)
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
/**
|
| 489 |
+
* Create DeprecationError for deprecation
|
| 490 |
+
*/
|
| 491 |
+
|
| 492 |
+
function DeprecationError (namespace, message, stack) {
|
| 493 |
+
var error = new Error()
|
| 494 |
+
var stackString
|
| 495 |
+
|
| 496 |
+
Object.defineProperty(error, 'constructor', {
|
| 497 |
+
value: DeprecationError
|
| 498 |
+
})
|
| 499 |
+
|
| 500 |
+
Object.defineProperty(error, 'message', {
|
| 501 |
+
configurable: true,
|
| 502 |
+
enumerable: false,
|
| 503 |
+
value: message,
|
| 504 |
+
writable: true
|
| 505 |
+
})
|
| 506 |
+
|
| 507 |
+
Object.defineProperty(error, 'name', {
|
| 508 |
+
enumerable: false,
|
| 509 |
+
configurable: true,
|
| 510 |
+
value: 'DeprecationError',
|
| 511 |
+
writable: true
|
| 512 |
+
})
|
| 513 |
+
|
| 514 |
+
Object.defineProperty(error, 'namespace', {
|
| 515 |
+
configurable: true,
|
| 516 |
+
enumerable: false,
|
| 517 |
+
value: namespace,
|
| 518 |
+
writable: true
|
| 519 |
+
})
|
| 520 |
+
|
| 521 |
+
Object.defineProperty(error, 'stack', {
|
| 522 |
+
configurable: true,
|
| 523 |
+
enumerable: false,
|
| 524 |
+
get: function () {
|
| 525 |
+
if (stackString !== undefined) {
|
| 526 |
+
return stackString
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
// prepare stack trace
|
| 530 |
+
return (stackString = createStackString.call(this, stack))
|
| 531 |
+
},
|
| 532 |
+
set: function setter (val) {
|
| 533 |
+
stackString = val
|
| 534 |
+
}
|
| 535 |
+
})
|
| 536 |
+
|
| 537 |
+
return error
|
| 538 |
+
}
|
node_modules/depd/lib/browser/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*!
|
| 2 |
+
* depd
|
| 3 |
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
| 4 |
+
* MIT Licensed
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
'use strict'
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* Module exports.
|
| 11 |
+
* @public
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
module.exports = depd
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Create deprecate for namespace in caller.
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
function depd (namespace) {
|
| 21 |
+
if (!namespace) {
|
| 22 |
+
throw new TypeError('argument namespace is required')
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
function deprecate (message) {
|
| 26 |
+
// no-op in browser
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
deprecate._file = undefined
|
| 30 |
+
deprecate._ignored = true
|
| 31 |
+
deprecate._namespace = namespace
|
| 32 |
+
deprecate._traced = false
|
| 33 |
+
deprecate._warned = Object.create(null)
|
| 34 |
+
|
| 35 |
+
deprecate.function = wrapfunction
|
| 36 |
+
deprecate.property = wrapproperty
|
| 37 |
+
|
| 38 |
+
return deprecate
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Return a wrapped function in a deprecation message.
|
| 43 |
+
*
|
| 44 |
+
* This is a no-op version of the wrapper, which does nothing but call
|
| 45 |
+
* validation.
|
| 46 |
+
*/
|
| 47 |
+
|
| 48 |
+
function wrapfunction (fn, message) {
|
| 49 |
+
if (typeof fn !== 'function') {
|
| 50 |
+
throw new TypeError('argument fn must be a function')
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
return fn
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* Wrap property in a deprecation message.
|
| 58 |
+
*
|
| 59 |
+
* This is a no-op version of the wrapper, which does nothing but call
|
| 60 |
+
* validation.
|
| 61 |
+
*/
|
| 62 |
+
|
| 63 |
+
function wrapproperty (obj, prop, message) {
|
| 64 |
+
if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
| 65 |
+
throw new TypeError('argument obj must be object')
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
| 69 |
+
|
| 70 |
+
if (!descriptor) {
|
| 71 |
+
throw new TypeError('must call property on owner object')
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
if (!descriptor.configurable) {
|
| 75 |
+
throw new TypeError('property must be configurable')
|
| 76 |
+
}
|
| 77 |
+
}
|
node_modules/depd/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "depd",
|
| 3 |
+
"description": "Deprecate all the things",
|
| 4 |
+
"version": "2.0.0",
|
| 5 |
+
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
|
| 6 |
+
"license": "MIT",
|
| 7 |
+
"keywords": [
|
| 8 |
+
"deprecate",
|
| 9 |
+
"deprecated"
|
| 10 |
+
],
|
| 11 |
+
"repository": "dougwilson/nodejs-depd",
|
| 12 |
+
"browser": "lib/browser/index.js",
|
| 13 |
+
"devDependencies": {
|
| 14 |
+
"benchmark": "2.1.4",
|
| 15 |
+
"beautify-benchmark": "0.2.4",
|
| 16 |
+
"eslint": "5.7.0",
|
| 17 |
+
"eslint-config-standard": "12.0.0",
|
| 18 |
+
"eslint-plugin-import": "2.14.0",
|
| 19 |
+
"eslint-plugin-markdown": "1.0.0-beta.7",
|
| 20 |
+
"eslint-plugin-node": "7.0.1",
|
| 21 |
+
"eslint-plugin-promise": "4.0.1",
|
| 22 |
+
"eslint-plugin-standard": "4.0.0",
|
| 23 |
+
"istanbul": "0.4.5",
|
| 24 |
+
"mocha": "5.2.0",
|
| 25 |
+
"safe-buffer": "5.1.2",
|
| 26 |
+
"uid-safe": "2.1.5"
|
| 27 |
+
},
|
| 28 |
+
"files": [
|
| 29 |
+
"lib/",
|
| 30 |
+
"History.md",
|
| 31 |
+
"LICENSE",
|
| 32 |
+
"index.js",
|
| 33 |
+
"Readme.md"
|
| 34 |
+
],
|
| 35 |
+
"engines": {
|
| 36 |
+
"node": ">= 0.8"
|
| 37 |
+
},
|
| 38 |
+
"scripts": {
|
| 39 |
+
"bench": "node benchmark/index.js",
|
| 40 |
+
"lint": "eslint --plugin markdown --ext js,md .",
|
| 41 |
+
"test": "mocha --reporter spec --bail test/",
|
| 42 |
+
"test-ci": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter spec test/ && istanbul report lcovonly text-summary",
|
| 43 |
+
"test-cov": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter dot test/ && istanbul report lcov text-summary"
|
| 44 |
+
}
|
| 45 |
+
}
|
node_modules/destroy/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
The MIT License (MIT)
|
| 3 |
+
|
| 4 |
+
Copyright (c) 2014 Jonathan Ong me@jongleberry.com
|
| 5 |
+
Copyright (c) 2015-2022 Douglas Christopher Wilson doug@somethingdoug.com
|
| 6 |
+
|
| 7 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 8 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 9 |
+
in the Software without restriction, including without limitation the rights
|
| 10 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 12 |
+
furnished to do so, subject to the following conditions:
|
| 13 |
+
|
| 14 |
+
The above copyright notice and this permission notice shall be included in
|
| 15 |
+
all copies or substantial portions of the Software.
|
| 16 |
+
|
| 17 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 18 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 19 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 20 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 21 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 22 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 23 |
+
THE SOFTWARE.
|
node_modules/destroy/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# destroy
|
| 2 |
+
|
| 3 |
+
[![NPM version][npm-image]][npm-url]
|
| 4 |
+
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
|
| 5 |
+
[![Test coverage][coveralls-image]][coveralls-url]
|
| 6 |
+
[![License][license-image]][license-url]
|
| 7 |
+
[![Downloads][downloads-image]][downloads-url]
|
| 8 |
+
|
| 9 |
+
Destroy a stream.
|
| 10 |
+
|
| 11 |
+
This module is meant to ensure a stream gets destroyed, handling different APIs
|
| 12 |
+
and Node.js bugs.
|
| 13 |
+
|
| 14 |
+
## API
|
| 15 |
+
|
| 16 |
+
```js
|
| 17 |
+
var destroy = require('destroy')
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
### destroy(stream [, suppress])
|
| 21 |
+
|
| 22 |
+
Destroy the given stream, and optionally suppress any future `error` events.
|
| 23 |
+
|
| 24 |
+
In most cases, this is identical to a simple `stream.destroy()` call. The rules
|
| 25 |
+
are as follows for a given stream:
|
| 26 |
+
|
| 27 |
+
1. If the `stream` is an instance of `ReadStream`, then call `stream.destroy()`
|
| 28 |
+
and add a listener to the `open` event to call `stream.close()` if it is
|
| 29 |
+
fired. This is for a Node.js bug that will leak a file descriptor if
|
| 30 |
+
`.destroy()` is called before `open`.
|
| 31 |
+
2. If the `stream` is an instance of a zlib stream, then call `stream.destroy()`
|
| 32 |
+
and close the underlying zlib handle if open, otherwise call `stream.close()`.
|
| 33 |
+
This is for consistency across Node.js versions and a Node.js bug that will
|
| 34 |
+
leak a native zlib handle.
|
| 35 |
+
3. If the `stream` is not an instance of `Stream`, then nothing happens.
|
| 36 |
+
4. If the `stream` has a `.destroy()` method, then call it.
|
| 37 |
+
|
| 38 |
+
The function returns the `stream` passed in as the argument.
|
| 39 |
+
|
| 40 |
+
## Example
|
| 41 |
+
|
| 42 |
+
```js
|
| 43 |
+
var destroy = require('destroy')
|
| 44 |
+
|
| 45 |
+
var fs = require('fs')
|
| 46 |
+
var stream = fs.createReadStream('package.json')
|
| 47 |
+
|
| 48 |
+
// ... and later
|
| 49 |
+
destroy(stream)
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
[npm-image]: https://img.shields.io/npm/v/destroy.svg?style=flat-square
|
| 53 |
+
[npm-url]: https://npmjs.org/package/destroy
|
| 54 |
+
[github-tag]: http://img.shields.io/github/tag/stream-utils/destroy.svg?style=flat-square
|
| 55 |
+
[github-url]: https://github.com/stream-utils/destroy/tags
|
| 56 |
+
[coveralls-image]: https://img.shields.io/coveralls/stream-utils/destroy.svg?style=flat-square
|
| 57 |
+
[coveralls-url]: https://coveralls.io/r/stream-utils/destroy?branch=master
|
| 58 |
+
[license-image]: http://img.shields.io/npm/l/destroy.svg?style=flat-square
|
| 59 |
+
[license-url]: LICENSE.md
|
| 60 |
+
[downloads-image]: http://img.shields.io/npm/dm/destroy.svg?style=flat-square
|
| 61 |
+
[downloads-url]: https://npmjs.org/package/destroy
|
| 62 |
+
[github-actions-ci-image]: https://img.shields.io/github/workflow/status/stream-utils/destroy/ci/master?label=ci&style=flat-square
|
| 63 |
+
[github-actions-ci-url]: https://github.com/stream-utils/destroy/actions/workflows/ci.yml
|
node_modules/destroy/index.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*!
|
| 2 |
+
* destroy
|
| 3 |
+
* Copyright(c) 2014 Jonathan Ong
|
| 4 |
+
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
| 5 |
+
* MIT Licensed
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
'use strict'
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Module dependencies.
|
| 12 |
+
* @private
|
| 13 |
+
*/
|
| 14 |
+
|
| 15 |
+
var EventEmitter = require('events').EventEmitter
|
| 16 |
+
var ReadStream = require('fs').ReadStream
|
| 17 |
+
var Stream = require('stream')
|
| 18 |
+
var Zlib = require('zlib')
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Module exports.
|
| 22 |
+
* @public
|
| 23 |
+
*/
|
| 24 |
+
|
| 25 |
+
module.exports = destroy
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Destroy the given stream, and optionally suppress any future `error` events.
|
| 29 |
+
*
|
| 30 |
+
* @param {object} stream
|
| 31 |
+
* @param {boolean} suppress
|
| 32 |
+
* @public
|
| 33 |
+
*/
|
| 34 |
+
|
| 35 |
+
function destroy (stream, suppress) {
|
| 36 |
+
if (isFsReadStream(stream)) {
|
| 37 |
+
destroyReadStream(stream)
|
| 38 |
+
} else if (isZlibStream(stream)) {
|
| 39 |
+
destroyZlibStream(stream)
|
| 40 |
+
} else if (hasDestroy(stream)) {
|
| 41 |
+
stream.destroy()
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
if (isEventEmitter(stream) && suppress) {
|
| 45 |
+
stream.removeAllListeners('error')
|
| 46 |
+
stream.addListener('error', noop)
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
return stream
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* Destroy a ReadStream.
|
| 54 |
+
*
|
| 55 |
+
* @param {object} stream
|
| 56 |
+
* @private
|
| 57 |
+
*/
|
| 58 |
+
|
| 59 |
+
function destroyReadStream (stream) {
|
| 60 |
+
stream.destroy()
|
| 61 |
+
|
| 62 |
+
if (typeof stream.close === 'function') {
|
| 63 |
+
// node.js core bug work-around
|
| 64 |
+
stream.on('open', onOpenClose)
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Close a Zlib stream.
|
| 70 |
+
*
|
| 71 |
+
* Zlib streams below Node.js 4.5.5 have a buggy implementation
|
| 72 |
+
* of .close() when zlib encountered an error.
|
| 73 |
+
*
|
| 74 |
+
* @param {object} stream
|
| 75 |
+
* @private
|
| 76 |
+
*/
|
| 77 |
+
|
| 78 |
+
function closeZlibStream (stream) {
|
| 79 |
+
if (stream._hadError === true) {
|
| 80 |
+
var prop = stream._binding === null
|
| 81 |
+
? '_binding'
|
| 82 |
+
: '_handle'
|
| 83 |
+
|
| 84 |
+
stream[prop] = {
|
| 85 |
+
close: function () { this[prop] = null }
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
stream.close()
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* Destroy a Zlib stream.
|
| 94 |
+
*
|
| 95 |
+
* Zlib streams don't have a destroy function in Node.js 6. On top of that
|
| 96 |
+
* simply calling destroy on a zlib stream in Node.js 8+ will result in a
|
| 97 |
+
* memory leak. So until that is fixed, we need to call both close AND destroy.
|
| 98 |
+
*
|
| 99 |
+
* PR to fix memory leak: https://github.com/nodejs/node/pull/23734
|
| 100 |
+
*
|
| 101 |
+
* In Node.js 6+8, it's important that destroy is called before close as the
|
| 102 |
+
* stream would otherwise emit the error 'zlib binding closed'.
|
| 103 |
+
*
|
| 104 |
+
* @param {object} stream
|
| 105 |
+
* @private
|
| 106 |
+
*/
|
| 107 |
+
|
| 108 |
+
function destroyZlibStream (stream) {
|
| 109 |
+
if (typeof stream.destroy === 'function') {
|
| 110 |
+
// node.js core bug work-around
|
| 111 |
+
// istanbul ignore if: node.js 0.8
|
| 112 |
+
if (stream._binding) {
|
| 113 |
+
// node.js < 0.10.0
|
| 114 |
+
stream.destroy()
|
| 115 |
+
if (stream._processing) {
|
| 116 |
+
stream._needDrain = true
|
| 117 |
+
stream.once('drain', onDrainClearBinding)
|
| 118 |
+
} else {
|
| 119 |
+
stream._binding.clear()
|
| 120 |
+
}
|
| 121 |
+
} else if (stream._destroy && stream._destroy !== Stream.Transform.prototype._destroy) {
|
| 122 |
+
// node.js >= 12, ^11.1.0, ^10.15.1
|
| 123 |
+
stream.destroy()
|
| 124 |
+
} else if (stream._destroy && typeof stream.close === 'function') {
|
| 125 |
+
// node.js 7, 8
|
| 126 |
+
stream.destroyed = true
|
| 127 |
+
stream.close()
|
| 128 |
+
} else {
|
| 129 |
+
// fallback
|
| 130 |
+
// istanbul ignore next
|
| 131 |
+
stream.destroy()
|
| 132 |
+
}
|
| 133 |
+
} else if (typeof stream.close === 'function') {
|
| 134 |
+
// node.js < 8 fallback
|
| 135 |
+
closeZlibStream(stream)
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* Determine if stream has destroy.
|
| 141 |
+
* @private
|
| 142 |
+
*/
|
| 143 |
+
|
| 144 |
+
function hasDestroy (stream) {
|
| 145 |
+
return stream instanceof Stream &&
|
| 146 |
+
typeof stream.destroy === 'function'
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
/**
|
| 150 |
+
* Determine if val is EventEmitter.
|
| 151 |
+
* @private
|
| 152 |
+
*/
|
| 153 |
+
|
| 154 |
+
function isEventEmitter (val) {
|
| 155 |
+
return val instanceof EventEmitter
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
* Determine if stream is fs.ReadStream stream.
|
| 160 |
+
* @private
|
| 161 |
+
*/
|
| 162 |
+
|
| 163 |
+
function isFsReadStream (stream) {
|
| 164 |
+
return stream instanceof ReadStream
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* Determine if stream is Zlib stream.
|
| 169 |
+
* @private
|
| 170 |
+
*/
|
| 171 |
+
|
| 172 |
+
function isZlibStream (stream) {
|
| 173 |
+
return stream instanceof Zlib.Gzip ||
|
| 174 |
+
stream instanceof Zlib.Gunzip ||
|
| 175 |
+
stream instanceof Zlib.Deflate ||
|
| 176 |
+
stream instanceof Zlib.DeflateRaw ||
|
| 177 |
+
stream instanceof Zlib.Inflate ||
|
| 178 |
+
stream instanceof Zlib.InflateRaw ||
|
| 179 |
+
stream instanceof Zlib.Unzip
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* No-op function.
|
| 184 |
+
* @private
|
| 185 |
+
*/
|
| 186 |
+
|
| 187 |
+
function noop () {}
|
| 188 |
+
|
| 189 |
+
/**
|
| 190 |
+
* On drain handler to clear binding.
|
| 191 |
+
* @private
|
| 192 |
+
*/
|
| 193 |
+
|
| 194 |
+
// istanbul ignore next: node.js 0.8
|
| 195 |
+
function onDrainClearBinding () {
|
| 196 |
+
this._binding.clear()
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
/**
|
| 200 |
+
* On open handler to close stream.
|
| 201 |
+
* @private
|
| 202 |
+
*/
|
| 203 |
+
|
| 204 |
+
function onOpenClose () {
|
| 205 |
+
if (typeof this.fd === 'number') {
|
| 206 |
+
// actually close down the fd
|
| 207 |
+
this.close()
|
| 208 |
+
}
|
| 209 |
+
}
|
node_modules/destroy/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "destroy",
|
| 3 |
+
"description": "destroy a stream if possible",
|
| 4 |
+
"version": "1.2.0",
|
| 5 |
+
"author": {
|
| 6 |
+
"name": "Jonathan Ong",
|
| 7 |
+
"email": "me@jongleberry.com",
|
| 8 |
+
"url": "http://jongleberry.com",
|
| 9 |
+
"twitter": "https://twitter.com/jongleberry"
|
| 10 |
+
},
|
| 11 |
+
"contributors": [
|
| 12 |
+
"Douglas Christopher Wilson <doug@somethingdoug.com>"
|
| 13 |
+
],
|
| 14 |
+
"license": "MIT",
|
| 15 |
+
"repository": "stream-utils/destroy",
|
| 16 |
+
"devDependencies": {
|
| 17 |
+
"eslint": "7.32.0",
|
| 18 |
+
"eslint-config-standard": "14.1.1",
|
| 19 |
+
"eslint-plugin-import": "2.25.4",
|
| 20 |
+
"eslint-plugin-node": "11.1.0",
|
| 21 |
+
"eslint-plugin-promise": "5.2.0",
|
| 22 |
+
"eslint-plugin-standard": "4.1.0",
|
| 23 |
+
"mocha": "9.2.2",
|
| 24 |
+
"nyc": "15.1.0"
|
| 25 |
+
},
|
| 26 |
+
"engines": {
|
| 27 |
+
"node": ">= 0.8",
|
| 28 |
+
"npm": "1.2.8000 || >= 1.4.16"
|
| 29 |
+
},
|
| 30 |
+
"scripts": {
|
| 31 |
+
"lint": "eslint .",
|
| 32 |
+
"test": "mocha --reporter spec",
|
| 33 |
+
"test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
|
| 34 |
+
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
| 35 |
+
},
|
| 36 |
+
"files": [
|
| 37 |
+
"index.js",
|
| 38 |
+
"LICENSE"
|
| 39 |
+
],
|
| 40 |
+
"keywords": [
|
| 41 |
+
"stream",
|
| 42 |
+
"streams",
|
| 43 |
+
"destroy",
|
| 44 |
+
"cleanup",
|
| 45 |
+
"leak",
|
| 46 |
+
"fd"
|
| 47 |
+
]
|
| 48 |
+
}
|
node_modules/detect-libc/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright {yyyy} {name of copyright owner}
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
node_modules/detect-libc/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# detect-libc
|
| 2 |
+
|
| 3 |
+
Node.js module to detect details of the C standard library (libc)
|
| 4 |
+
implementation provided by a given Linux system.
|
| 5 |
+
|
| 6 |
+
Currently supports detection of GNU glibc and MUSL libc.
|
| 7 |
+
|
| 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 |
+
The version numbers of libc implementations
|
| 12 |
+
are not guaranteed to be semver-compliant.
|
| 13 |
+
|
| 14 |
+
For previous v1.x releases, please see the
|
| 15 |
+
[v1](https://github.com/lovell/detect-libc/tree/v1) branch.
|
| 16 |
+
|
| 17 |
+
## Install
|
| 18 |
+
|
| 19 |
+
```sh
|
| 20 |
+
npm install detect-libc
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
## API
|
| 24 |
+
|
| 25 |
+
### GLIBC
|
| 26 |
+
|
| 27 |
+
```ts
|
| 28 |
+
const GLIBC: string = 'glibc';
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
A String constant containing the value `glibc`.
|
| 32 |
+
|
| 33 |
+
### MUSL
|
| 34 |
+
|
| 35 |
+
```ts
|
| 36 |
+
const MUSL: string = 'musl';
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
A String constant containing the value `musl`.
|
| 40 |
+
|
| 41 |
+
### family
|
| 42 |
+
|
| 43 |
+
```ts
|
| 44 |
+
function family(): Promise<string | null>;
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
Resolves asychronously with:
|
| 48 |
+
|
| 49 |
+
* `glibc` or `musl` when the libc family can be determined
|
| 50 |
+
* `null` when the libc family cannot be determined
|
| 51 |
+
* `null` when run on a non-Linux platform
|
| 52 |
+
|
| 53 |
+
```js
|
| 54 |
+
const { family, GLIBC, MUSL } = require('detect-libc');
|
| 55 |
+
|
| 56 |
+
switch (await family()) {
|
| 57 |
+
case GLIBC: ...
|
| 58 |
+
case MUSL: ...
|
| 59 |
+
case null: ...
|
| 60 |
+
}
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
### familySync
|
| 64 |
+
|
| 65 |
+
```ts
|
| 66 |
+
function familySync(): string | null;
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
Synchronous version of `family()`.
|
| 70 |
+
|
| 71 |
+
```js
|
| 72 |
+
const { familySync, GLIBC, MUSL } = require('detect-libc');
|
| 73 |
+
|
| 74 |
+
switch (familySync()) {
|
| 75 |
+
case GLIBC: ...
|
| 76 |
+
case MUSL: ...
|
| 77 |
+
case null: ...
|
| 78 |
+
}
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### version
|
| 82 |
+
|
| 83 |
+
```ts
|
| 84 |
+
function version(): Promise<string | null>;
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
Resolves asychronously with:
|
| 88 |
+
|
| 89 |
+
* The version when it can be determined
|
| 90 |
+
* `null` when the libc family cannot be determined
|
| 91 |
+
* `null` when run on a non-Linux platform
|
| 92 |
+
|
| 93 |
+
```js
|
| 94 |
+
const { version } = require('detect-libc');
|
| 95 |
+
|
| 96 |
+
const v = await version();
|
| 97 |
+
if (v) {
|
| 98 |
+
const [major, minor, patch] = v.split('.');
|
| 99 |
+
}
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
### versionSync
|
| 103 |
+
|
| 104 |
+
```ts
|
| 105 |
+
function versionSync(): string | null;
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
Synchronous version of `version()`.
|
| 109 |
+
|
| 110 |
+
```js
|
| 111 |
+
const { versionSync } = require('detect-libc');
|
| 112 |
+
|
| 113 |
+
const v = versionSync();
|
| 114 |
+
if (v) {
|
| 115 |
+
const [major, minor, patch] = v.split('.');
|
| 116 |
+
}
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
### isNonGlibcLinux
|
| 120 |
+
|
| 121 |
+
```ts
|
| 122 |
+
function isNonGlibcLinux(): Promise<boolean>;
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
Resolves asychronously with:
|
| 126 |
+
|
| 127 |
+
* `false` when the libc family is `glibc`
|
| 128 |
+
* `true` when the libc family is not `glibc`
|
| 129 |
+
* `false` when run on a non-Linux platform
|
| 130 |
+
|
| 131 |
+
```js
|
| 132 |
+
const { isNonGlibcLinux } = require('detect-libc');
|
| 133 |
+
|
| 134 |
+
if (await isNonGlibcLinux()) { ... }
|
| 135 |
+
```
|
| 136 |
+
|
| 137 |
+
### isNonGlibcLinuxSync
|
| 138 |
+
|
| 139 |
+
```ts
|
| 140 |
+
function isNonGlibcLinuxSync(): boolean;
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
Synchronous version of `isNonGlibcLinux()`.
|
| 144 |
+
|
| 145 |
+
```js
|
| 146 |
+
const { isNonGlibcLinuxSync } = require('detect-libc');
|
| 147 |
+
|
| 148 |
+
if (isNonGlibcLinuxSync()) { ... }
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
## Licensing
|
| 152 |
+
|
| 153 |
+
Copyright 2017 Lovell Fuller and others.
|
| 154 |
+
|
| 155 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 156 |
+
you may not use this file except in compliance with the License.
|
| 157 |
+
You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
|
| 158 |
+
|
| 159 |
+
Unless required by applicable law or agreed to in writing, software
|
| 160 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 161 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 162 |
+
See the License for the specific language governing permissions and
|
| 163 |
+
limitations under the License.
|
node_modules/detect-libc/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2017 Lovell Fuller and others.
|
| 2 |
+
// SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
|
| 4 |
+
export const GLIBC: 'glibc';
|
| 5 |
+
export const MUSL: 'musl';
|
| 6 |
+
|
| 7 |
+
export function family(): Promise<string | null>;
|
| 8 |
+
export function familySync(): string | null;
|
| 9 |
+
|
| 10 |
+
export function isNonGlibcLinux(): Promise<boolean>;
|
| 11 |
+
export function isNonGlibcLinuxSync(): boolean;
|
| 12 |
+
|
| 13 |
+
export function version(): Promise<string | null>;
|
| 14 |
+
export function versionSync(): string | null;
|
node_modules/detect-libc/lib/detect-libc.js
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2017 Lovell Fuller and others.
|
| 2 |
+
// SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
|
| 4 |
+
'use strict';
|
| 5 |
+
|
| 6 |
+
const childProcess = require('child_process');
|
| 7 |
+
const { isLinux, getReport } = require('./process');
|
| 8 |
+
const { LDD_PATH, SELF_PATH, readFile, readFileSync } = require('./filesystem');
|
| 9 |
+
const { interpreterPath } = require('./elf');
|
| 10 |
+
|
| 11 |
+
let cachedFamilyInterpreter;
|
| 12 |
+
let cachedFamilyFilesystem;
|
| 13 |
+
let cachedVersionFilesystem;
|
| 14 |
+
|
| 15 |
+
const command = 'getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true';
|
| 16 |
+
let commandOut = '';
|
| 17 |
+
|
| 18 |
+
const safeCommand = () => {
|
| 19 |
+
if (!commandOut) {
|
| 20 |
+
return new Promise((resolve) => {
|
| 21 |
+
childProcess.exec(command, (err, out) => {
|
| 22 |
+
commandOut = err ? ' ' : out;
|
| 23 |
+
resolve(commandOut);
|
| 24 |
+
});
|
| 25 |
+
});
|
| 26 |
+
}
|
| 27 |
+
return commandOut;
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
const safeCommandSync = () => {
|
| 31 |
+
if (!commandOut) {
|
| 32 |
+
try {
|
| 33 |
+
commandOut = childProcess.execSync(command, { encoding: 'utf8' });
|
| 34 |
+
} catch (_err) {
|
| 35 |
+
commandOut = ' ';
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
return commandOut;
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* A String constant containing the value `glibc`.
|
| 43 |
+
* @type {string}
|
| 44 |
+
* @public
|
| 45 |
+
*/
|
| 46 |
+
const GLIBC = 'glibc';
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* A Regexp constant to get the GLIBC Version.
|
| 50 |
+
* @type {string}
|
| 51 |
+
*/
|
| 52 |
+
const RE_GLIBC_VERSION = /LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i;
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* A String constant containing the value `musl`.
|
| 56 |
+
* @type {string}
|
| 57 |
+
* @public
|
| 58 |
+
*/
|
| 59 |
+
const MUSL = 'musl';
|
| 60 |
+
|
| 61 |
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-');
|
| 62 |
+
|
| 63 |
+
const familyFromReport = () => {
|
| 64 |
+
const report = getReport();
|
| 65 |
+
if (report.header && report.header.glibcVersionRuntime) {
|
| 66 |
+
return GLIBC;
|
| 67 |
+
}
|
| 68 |
+
if (Array.isArray(report.sharedObjects)) {
|
| 69 |
+
if (report.sharedObjects.some(isFileMusl)) {
|
| 70 |
+
return MUSL;
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
return null;
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
const familyFromCommand = (out) => {
|
| 77 |
+
const [getconf, ldd1] = out.split(/[\r\n]+/);
|
| 78 |
+
if (getconf && getconf.includes(GLIBC)) {
|
| 79 |
+
return GLIBC;
|
| 80 |
+
}
|
| 81 |
+
if (ldd1 && ldd1.includes(MUSL)) {
|
| 82 |
+
return MUSL;
|
| 83 |
+
}
|
| 84 |
+
return null;
|
| 85 |
+
};
|
| 86 |
+
|
| 87 |
+
const familyFromInterpreterPath = (path) => {
|
| 88 |
+
if (path) {
|
| 89 |
+
if (path.includes('/ld-musl-')) {
|
| 90 |
+
return MUSL;
|
| 91 |
+
} else if (path.includes('/ld-linux-')) {
|
| 92 |
+
return GLIBC;
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
return null;
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
const getFamilyFromLddContent = (content) => {
|
| 99 |
+
content = content.toString();
|
| 100 |
+
if (content.includes('musl')) {
|
| 101 |
+
return MUSL;
|
| 102 |
+
}
|
| 103 |
+
if (content.includes('GNU C Library')) {
|
| 104 |
+
return GLIBC;
|
| 105 |
+
}
|
| 106 |
+
return null;
|
| 107 |
+
};
|
| 108 |
+
|
| 109 |
+
const familyFromFilesystem = async () => {
|
| 110 |
+
if (cachedFamilyFilesystem !== undefined) {
|
| 111 |
+
return cachedFamilyFilesystem;
|
| 112 |
+
}
|
| 113 |
+
cachedFamilyFilesystem = null;
|
| 114 |
+
try {
|
| 115 |
+
const lddContent = await readFile(LDD_PATH);
|
| 116 |
+
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
| 117 |
+
} catch (e) {}
|
| 118 |
+
return cachedFamilyFilesystem;
|
| 119 |
+
};
|
| 120 |
+
|
| 121 |
+
const familyFromFilesystemSync = () => {
|
| 122 |
+
if (cachedFamilyFilesystem !== undefined) {
|
| 123 |
+
return cachedFamilyFilesystem;
|
| 124 |
+
}
|
| 125 |
+
cachedFamilyFilesystem = null;
|
| 126 |
+
try {
|
| 127 |
+
const lddContent = readFileSync(LDD_PATH);
|
| 128 |
+
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
| 129 |
+
} catch (e) {}
|
| 130 |
+
return cachedFamilyFilesystem;
|
| 131 |
+
};
|
| 132 |
+
|
| 133 |
+
const familyFromInterpreter = async () => {
|
| 134 |
+
if (cachedFamilyInterpreter !== undefined) {
|
| 135 |
+
return cachedFamilyInterpreter;
|
| 136 |
+
}
|
| 137 |
+
cachedFamilyInterpreter = null;
|
| 138 |
+
try {
|
| 139 |
+
const selfContent = await readFile(SELF_PATH);
|
| 140 |
+
const path = interpreterPath(selfContent);
|
| 141 |
+
cachedFamilyInterpreter = familyFromInterpreterPath(path);
|
| 142 |
+
} catch (e) {}
|
| 143 |
+
return cachedFamilyInterpreter;
|
| 144 |
+
};
|
| 145 |
+
|
| 146 |
+
const familyFromInterpreterSync = () => {
|
| 147 |
+
if (cachedFamilyInterpreter !== undefined) {
|
| 148 |
+
return cachedFamilyInterpreter;
|
| 149 |
+
}
|
| 150 |
+
cachedFamilyInterpreter = null;
|
| 151 |
+
try {
|
| 152 |
+
const selfContent = readFileSync(SELF_PATH);
|
| 153 |
+
const path = interpreterPath(selfContent);
|
| 154 |
+
cachedFamilyInterpreter = familyFromInterpreterPath(path);
|
| 155 |
+
} catch (e) {}
|
| 156 |
+
return cachedFamilyInterpreter;
|
| 157 |
+
};
|
| 158 |
+
|
| 159 |
+
/**
|
| 160 |
+
* Resolves with the libc family when it can be determined, `null` otherwise.
|
| 161 |
+
* @returns {Promise<?string>}
|
| 162 |
+
*/
|
| 163 |
+
const family = async () => {
|
| 164 |
+
let family = null;
|
| 165 |
+
if (isLinux()) {
|
| 166 |
+
family = await familyFromInterpreter();
|
| 167 |
+
if (!family) {
|
| 168 |
+
family = await familyFromFilesystem();
|
| 169 |
+
if (!family) {
|
| 170 |
+
family = familyFromReport();
|
| 171 |
+
}
|
| 172 |
+
if (!family) {
|
| 173 |
+
const out = await safeCommand();
|
| 174 |
+
family = familyFromCommand(out);
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
}
|
| 178 |
+
return family;
|
| 179 |
+
};
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* Returns the libc family when it can be determined, `null` otherwise.
|
| 183 |
+
* @returns {?string}
|
| 184 |
+
*/
|
| 185 |
+
const familySync = () => {
|
| 186 |
+
let family = null;
|
| 187 |
+
if (isLinux()) {
|
| 188 |
+
family = familyFromInterpreterSync();
|
| 189 |
+
if (!family) {
|
| 190 |
+
family = familyFromFilesystemSync();
|
| 191 |
+
if (!family) {
|
| 192 |
+
family = familyFromReport();
|
| 193 |
+
}
|
| 194 |
+
if (!family) {
|
| 195 |
+
const out = safeCommandSync();
|
| 196 |
+
family = familyFromCommand(out);
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
return family;
|
| 201 |
+
};
|
| 202 |
+
|
| 203 |
+
/**
|
| 204 |
+
* Resolves `true` only when the platform is Linux and the libc family is not `glibc`.
|
| 205 |
+
* @returns {Promise<boolean>}
|
| 206 |
+
*/
|
| 207 |
+
const isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC;
|
| 208 |
+
|
| 209 |
+
/**
|
| 210 |
+
* Returns `true` only when the platform is Linux and the libc family is not `glibc`.
|
| 211 |
+
* @returns {boolean}
|
| 212 |
+
*/
|
| 213 |
+
const isNonGlibcLinuxSync = () => isLinux() && familySync() !== GLIBC;
|
| 214 |
+
|
| 215 |
+
const versionFromFilesystem = async () => {
|
| 216 |
+
if (cachedVersionFilesystem !== undefined) {
|
| 217 |
+
return cachedVersionFilesystem;
|
| 218 |
+
}
|
| 219 |
+
cachedVersionFilesystem = null;
|
| 220 |
+
try {
|
| 221 |
+
const lddContent = await readFile(LDD_PATH);
|
| 222 |
+
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
| 223 |
+
if (versionMatch) {
|
| 224 |
+
cachedVersionFilesystem = versionMatch[1];
|
| 225 |
+
}
|
| 226 |
+
} catch (e) {}
|
| 227 |
+
return cachedVersionFilesystem;
|
| 228 |
+
};
|
| 229 |
+
|
| 230 |
+
const versionFromFilesystemSync = () => {
|
| 231 |
+
if (cachedVersionFilesystem !== undefined) {
|
| 232 |
+
return cachedVersionFilesystem;
|
| 233 |
+
}
|
| 234 |
+
cachedVersionFilesystem = null;
|
| 235 |
+
try {
|
| 236 |
+
const lddContent = readFileSync(LDD_PATH);
|
| 237 |
+
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
| 238 |
+
if (versionMatch) {
|
| 239 |
+
cachedVersionFilesystem = versionMatch[1];
|
| 240 |
+
}
|
| 241 |
+
} catch (e) {}
|
| 242 |
+
return cachedVersionFilesystem;
|
| 243 |
+
};
|
| 244 |
+
|
| 245 |
+
const versionFromReport = () => {
|
| 246 |
+
const report = getReport();
|
| 247 |
+
if (report.header && report.header.glibcVersionRuntime) {
|
| 248 |
+
return report.header.glibcVersionRuntime;
|
| 249 |
+
}
|
| 250 |
+
return null;
|
| 251 |
+
};
|
| 252 |
+
|
| 253 |
+
const versionSuffix = (s) => s.trim().split(/\s+/)[1];
|
| 254 |
+
|
| 255 |
+
const versionFromCommand = (out) => {
|
| 256 |
+
const [getconf, ldd1, ldd2] = out.split(/[\r\n]+/);
|
| 257 |
+
if (getconf && getconf.includes(GLIBC)) {
|
| 258 |
+
return versionSuffix(getconf);
|
| 259 |
+
}
|
| 260 |
+
if (ldd1 && ldd2 && ldd1.includes(MUSL)) {
|
| 261 |
+
return versionSuffix(ldd2);
|
| 262 |
+
}
|
| 263 |
+
return null;
|
| 264 |
+
};
|
| 265 |
+
|
| 266 |
+
/**
|
| 267 |
+
* Resolves with the libc version when it can be determined, `null` otherwise.
|
| 268 |
+
* @returns {Promise<?string>}
|
| 269 |
+
*/
|
| 270 |
+
const version = async () => {
|
| 271 |
+
let version = null;
|
| 272 |
+
if (isLinux()) {
|
| 273 |
+
version = await versionFromFilesystem();
|
| 274 |
+
if (!version) {
|
| 275 |
+
version = versionFromReport();
|
| 276 |
+
}
|
| 277 |
+
if (!version) {
|
| 278 |
+
const out = await safeCommand();
|
| 279 |
+
version = versionFromCommand(out);
|
| 280 |
+
}
|
| 281 |
+
}
|
| 282 |
+
return version;
|
| 283 |
+
};
|
| 284 |
+
|
| 285 |
+
/**
|
| 286 |
+
* Returns the libc version when it can be determined, `null` otherwise.
|
| 287 |
+
* @returns {?string}
|
| 288 |
+
*/
|
| 289 |
+
const versionSync = () => {
|
| 290 |
+
let version = null;
|
| 291 |
+
if (isLinux()) {
|
| 292 |
+
version = versionFromFilesystemSync();
|
| 293 |
+
if (!version) {
|
| 294 |
+
version = versionFromReport();
|
| 295 |
+
}
|
| 296 |
+
if (!version) {
|
| 297 |
+
const out = safeCommandSync();
|
| 298 |
+
version = versionFromCommand(out);
|
| 299 |
+
}
|
| 300 |
+
}
|
| 301 |
+
return version;
|
| 302 |
+
};
|
| 303 |
+
|
| 304 |
+
module.exports = {
|
| 305 |
+
GLIBC,
|
| 306 |
+
MUSL,
|
| 307 |
+
family,
|
| 308 |
+
familySync,
|
| 309 |
+
isNonGlibcLinux,
|
| 310 |
+
isNonGlibcLinuxSync,
|
| 311 |
+
version,
|
| 312 |
+
versionSync
|
| 313 |
+
};
|
node_modules/detect-libc/lib/elf.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2017 Lovell Fuller and others.
|
| 2 |
+
// SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
|
| 4 |
+
'use strict';
|
| 5 |
+
|
| 6 |
+
const interpreterPath = (elf) => {
|
| 7 |
+
if (elf.length < 64) {
|
| 8 |
+
return null;
|
| 9 |
+
}
|
| 10 |
+
if (elf.readUInt32BE(0) !== 0x7F454C46) {
|
| 11 |
+
// Unexpected magic bytes
|
| 12 |
+
return null;
|
| 13 |
+
}
|
| 14 |
+
if (elf.readUInt8(4) !== 2) {
|
| 15 |
+
// Not a 64-bit ELF
|
| 16 |
+
return null;
|
| 17 |
+
}
|
| 18 |
+
if (elf.readUInt8(5) !== 1) {
|
| 19 |
+
// Not little-endian
|
| 20 |
+
return null;
|
| 21 |
+
}
|
| 22 |
+
const offset = elf.readUInt32LE(32);
|
| 23 |
+
const size = elf.readUInt16LE(54);
|
| 24 |
+
const count = elf.readUInt16LE(56);
|
| 25 |
+
for (let i = 0; i < count; i++) {
|
| 26 |
+
const headerOffset = offset + (i * size);
|
| 27 |
+
const type = elf.readUInt32LE(headerOffset);
|
| 28 |
+
if (type === 3) {
|
| 29 |
+
const fileOffset = elf.readUInt32LE(headerOffset + 8);
|
| 30 |
+
const fileSize = elf.readUInt32LE(headerOffset + 32);
|
| 31 |
+
return elf.subarray(fileOffset, fileOffset + fileSize).toString().replace(/\0.*$/g, '');
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
return null;
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
module.exports = {
|
| 38 |
+
interpreterPath
|
| 39 |
+
};
|
node_modules/detect-libc/lib/filesystem.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2017 Lovell Fuller and others.
|
| 2 |
+
// SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
|
| 4 |
+
'use strict';
|
| 5 |
+
|
| 6 |
+
const fs = require('fs');
|
| 7 |
+
|
| 8 |
+
const LDD_PATH = '/usr/bin/ldd';
|
| 9 |
+
const SELF_PATH = '/proc/self/exe';
|
| 10 |
+
const MAX_LENGTH = 2048;
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Read the content of a file synchronous
|
| 14 |
+
*
|
| 15 |
+
* @param {string} path
|
| 16 |
+
* @returns {Buffer}
|
| 17 |
+
*/
|
| 18 |
+
const readFileSync = (path) => {
|
| 19 |
+
const fd = fs.openSync(path, 'r');
|
| 20 |
+
const buffer = Buffer.alloc(MAX_LENGTH);
|
| 21 |
+
const bytesRead = fs.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
| 22 |
+
fs.close(fd, () => {});
|
| 23 |
+
return buffer.subarray(0, bytesRead);
|
| 24 |
+
};
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* Read the content of a file
|
| 28 |
+
*
|
| 29 |
+
* @param {string} path
|
| 30 |
+
* @returns {Promise<Buffer>}
|
| 31 |
+
*/
|
| 32 |
+
const readFile = (path) => new Promise((resolve, reject) => {
|
| 33 |
+
fs.open(path, 'r', (err, fd) => {
|
| 34 |
+
if (err) {
|
| 35 |
+
reject(err);
|
| 36 |
+
} else {
|
| 37 |
+
const buffer = Buffer.alloc(MAX_LENGTH);
|
| 38 |
+
fs.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
| 39 |
+
resolve(buffer.subarray(0, bytesRead));
|
| 40 |
+
fs.close(fd, () => {});
|
| 41 |
+
});
|
| 42 |
+
}
|
| 43 |
+
});
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
module.exports = {
|
| 47 |
+
LDD_PATH,
|
| 48 |
+
SELF_PATH,
|
| 49 |
+
readFileSync,
|
| 50 |
+
readFile
|
| 51 |
+
};
|
node_modules/detect-libc/lib/process.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2017 Lovell Fuller and others.
|
| 2 |
+
// SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
|
| 4 |
+
'use strict';
|
| 5 |
+
|
| 6 |
+
const isLinux = () => process.platform === 'linux';
|
| 7 |
+
|
| 8 |
+
let report = null;
|
| 9 |
+
const getReport = () => {
|
| 10 |
+
if (!report) {
|
| 11 |
+
/* istanbul ignore next */
|
| 12 |
+
if (isLinux() && process.report) {
|
| 13 |
+
const orig = process.report.excludeNetwork;
|
| 14 |
+
process.report.excludeNetwork = true;
|
| 15 |
+
report = process.report.getReport();
|
| 16 |
+
process.report.excludeNetwork = orig;
|
| 17 |
+
} else {
|
| 18 |
+
report = {};
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
return report;
|
| 22 |
+
};
|
| 23 |
+
|
| 24 |
+
module.exports = { isLinux, getReport };
|