node-red-contrib-web-worldmap 5.0.5 → 5.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/README.md +3 -1
- package/examples/Custom Tooltip.json +83 -0
- package/node_modules/accepts/node_modules/negotiator/HISTORY.md +108 -0
- package/node_modules/{body-parser/node_modules/bytes → accepts/node_modules/negotiator}/LICENSE +3 -2
- package/node_modules/accepts/node_modules/negotiator/README.md +203 -0
- package/node_modules/accepts/node_modules/negotiator/index.js +82 -0
- package/node_modules/accepts/node_modules/negotiator/lib/charset.js +169 -0
- package/node_modules/accepts/node_modules/negotiator/lib/encoding.js +184 -0
- package/node_modules/accepts/node_modules/negotiator/lib/language.js +179 -0
- package/node_modules/accepts/node_modules/negotiator/lib/mediaType.js +294 -0
- package/node_modules/accepts/node_modules/negotiator/package.json +42 -0
- package/node_modules/bytes/History.md +15 -0
- package/node_modules/bytes/Readme.md +45 -18
- package/node_modules/bytes/index.js +15 -4
- package/node_modules/bytes/package.json +7 -4
- package/node_modules/compression/HISTORY.md +15 -0
- package/node_modules/compression/README.md +4 -6
- package/node_modules/compression/index.js +3 -8
- package/node_modules/compression/package.json +19 -19
- package/node_modules/negotiator/HISTORY.md +5 -0
- package/node_modules/negotiator/README.md +9 -0
- package/node_modules/negotiator/index.js +4 -4
- package/node_modules/negotiator/lib/encoding.js +26 -5
- package/node_modules/negotiator/lib/mediaType.js +3 -3
- package/node_modules/negotiator/package.json +1 -1
- package/node_modules/object-inspect/CHANGELOG.md +12 -0
- package/node_modules/object-inspect/index.js +17 -3
- package/node_modules/object-inspect/package.json +6 -6
- package/node_modules/object-inspect/test/quoteStyle.js +9 -0
- package/node_modules/safe-buffer/index.js +3 -0
- package/node_modules/safe-buffer/package.json +18 -4
- package/node_modules/tslib/modules/index.d.ts +1 -0
- package/node_modules/tslib/modules/index.js +2 -0
- package/node_modules/tslib/package.json +1 -1
- package/node_modules/tslib/tslib.d.ts +7 -0
- package/node_modules/tslib/tslib.es6.js +24 -1
- package/node_modules/tslib/tslib.es6.mjs +24 -1
- package/node_modules/tslib/tslib.js +56 -1
- package/package.json +1 -1
- package/worldmap/worldmap.js +7 -4
- package/worldmap.js +2 -2
- package/node_modules/body-parser/node_modules/bytes/History.md +0 -97
- package/node_modules/body-parser/node_modules/bytes/Readme.md +0 -152
- package/node_modules/body-parser/node_modules/bytes/index.js +0 -170
- package/node_modules/body-parser/node_modules/bytes/package.json +0 -42
- package/node_modules/content-disposition/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/content-disposition/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/content-disposition/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/content-disposition/node_modules/safe-buffer/index.js +0 -65
- package/node_modules/content-disposition/node_modules/safe-buffer/package.json +0 -51
- package/node_modules/express/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/express/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/express/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/express/node_modules/safe-buffer/index.js +0 -65
- package/node_modules/express/node_modules/safe-buffer/package.json +0 -51
- package/node_modules/raw-body/node_modules/bytes/History.md +0 -97
- package/node_modules/raw-body/node_modules/bytes/LICENSE +0 -23
- package/node_modules/raw-body/node_modules/bytes/Readme.md +0 -152
- package/node_modules/raw-body/node_modules/bytes/index.js +0 -170
- package/node_modules/raw-body/node_modules/bytes/package.json +0 -42
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[![NPM Version][npm-image]][npm-url]
|
|
4
4
|
[![NPM Downloads][downloads-image]][downloads-url]
|
|
5
|
-
[![Build Status][
|
|
5
|
+
[![Build Status][ci-image]][ci-url]
|
|
6
6
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
7
7
|
|
|
8
8
|
Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa.
|
|
@@ -23,6 +23,33 @@ $ npm install bytes
|
|
|
23
23
|
var bytes = require('bytes');
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
#### bytes(number|string value, [options]): number|string|null
|
|
27
|
+
|
|
28
|
+
Default export function. Delegates to either `bytes.format` or `bytes.parse` based on the type of `value`.
|
|
29
|
+
|
|
30
|
+
**Arguments**
|
|
31
|
+
|
|
32
|
+
| Name | Type | Description |
|
|
33
|
+
|---------|----------|--------------------|
|
|
34
|
+
| value | `number`|`string` | Number value to format or string value to parse |
|
|
35
|
+
| options | `Object` | Conversion options for `format` |
|
|
36
|
+
|
|
37
|
+
**Returns**
|
|
38
|
+
|
|
39
|
+
| Name | Type | Description |
|
|
40
|
+
|---------|------------------|-------------------------------------------------|
|
|
41
|
+
| results | `string`|`number`|`null` | Return null upon error. Numeric value in bytes, or string value otherwise. |
|
|
42
|
+
|
|
43
|
+
**Example**
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
bytes(1024);
|
|
47
|
+
// output: '1KB'
|
|
48
|
+
|
|
49
|
+
bytes('1KB');
|
|
50
|
+
// output: 1024
|
|
51
|
+
```
|
|
52
|
+
|
|
26
53
|
#### bytes.format(number value, [options]): string|null
|
|
27
54
|
|
|
28
55
|
Format the given value in bytes into a string. If the value is negative, it is kept as such. If it is a float, it is
|
|
@@ -41,7 +68,7 @@ Format the given value in bytes into a string. If the value is negative, it is k
|
|
|
41
68
|
|-------------------|--------|-----------------------------------------------------------------------------------------|
|
|
42
69
|
| decimalPlaces | `number`|`null` | Maximum number of decimal places to include in output. Default value to `2`. |
|
|
43
70
|
| fixedDecimals | `boolean`|`null` | Whether to always display the maximum number of decimal places. Default value to `false` |
|
|
44
|
-
| thousandsSeparator | `string`|`null` | Example of values: `' '`, `','` and
|
|
71
|
+
| thousandsSeparator | `string`|`null` | Example of values: `' '`, `','` and `'.'`... Default value to `''`. |
|
|
45
72
|
| unit | `string`|`null` | The unit in which the result will be returned (B/KB/MB/GB/TB). Default value to `''` (which means auto detect). |
|
|
46
73
|
| unitSeparator | `string`|`null` | Separator to use between number and unit. Default value to `''`. |
|
|
47
74
|
|
|
@@ -54,21 +81,20 @@ Format the given value in bytes into a string. If the value is negative, it is k
|
|
|
54
81
|
**Example**
|
|
55
82
|
|
|
56
83
|
```js
|
|
57
|
-
bytes(1024);
|
|
84
|
+
bytes.format(1024);
|
|
58
85
|
// output: '1KB'
|
|
59
86
|
|
|
60
|
-
bytes(1000);
|
|
87
|
+
bytes.format(1000);
|
|
61
88
|
// output: '1000B'
|
|
62
89
|
|
|
63
|
-
bytes(1000, {thousandsSeparator: ' '});
|
|
90
|
+
bytes.format(1000, {thousandsSeparator: ' '});
|
|
64
91
|
// output: '1 000B'
|
|
65
92
|
|
|
66
|
-
bytes(1024 * 1.7, {decimalPlaces: 0});
|
|
93
|
+
bytes.format(1024 * 1.7, {decimalPlaces: 0});
|
|
67
94
|
// output: '2KB'
|
|
68
95
|
|
|
69
|
-
bytes(1024, {unitSeparator: ' '});
|
|
96
|
+
bytes.format(1024, {unitSeparator: ' '});
|
|
70
97
|
// output: '1 KB'
|
|
71
|
-
|
|
72
98
|
```
|
|
73
99
|
|
|
74
100
|
#### bytes.parse(string|number value): number|null
|
|
@@ -83,6 +109,7 @@ Supported units and abbreviations are as follows and are case-insensitive:
|
|
|
83
109
|
* `mb` for megabytes
|
|
84
110
|
* `gb` for gigabytes
|
|
85
111
|
* `tb` for terabytes
|
|
112
|
+
* `pb` for petabytes
|
|
86
113
|
|
|
87
114
|
The units are in powers of two, not ten. This means 1kb = 1024b according to this parser.
|
|
88
115
|
|
|
@@ -101,25 +128,25 @@ The units are in powers of two, not ten. This means 1kb = 1024b according to thi
|
|
|
101
128
|
**Example**
|
|
102
129
|
|
|
103
130
|
```js
|
|
104
|
-
bytes('1KB');
|
|
131
|
+
bytes.parse('1KB');
|
|
105
132
|
// output: 1024
|
|
106
133
|
|
|
107
|
-
bytes('1024');
|
|
134
|
+
bytes.parse('1024');
|
|
108
135
|
// output: 1024
|
|
109
136
|
|
|
110
|
-
bytes(1024);
|
|
137
|
+
bytes.parse(1024);
|
|
111
138
|
// output: 1024
|
|
112
139
|
```
|
|
113
140
|
|
|
114
|
-
## License
|
|
141
|
+
## License
|
|
115
142
|
|
|
116
143
|
[MIT](LICENSE)
|
|
117
144
|
|
|
118
|
-
[
|
|
145
|
+
[ci-image]: https://badgen.net/github/checks/visionmedia/bytes.js/master?label=ci
|
|
146
|
+
[ci-url]: https://github.com/visionmedia/bytes.js/actions?query=workflow%3Aci
|
|
147
|
+
[coveralls-image]: https://badgen.net/coveralls/c/github/visionmedia/bytes.js/master
|
|
148
|
+
[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master
|
|
149
|
+
[downloads-image]: https://badgen.net/npm/dm/bytes
|
|
119
150
|
[downloads-url]: https://npmjs.org/package/bytes
|
|
120
|
-
[npm-image]: https://
|
|
151
|
+
[npm-image]: https://badgen.net/npm/v/bytes
|
|
121
152
|
[npm-url]: https://npmjs.org/package/bytes
|
|
122
|
-
[travis-image]: https://img.shields.io/travis/visionmedia/bytes.js/master.svg
|
|
123
|
-
[travis-url]: https://travis-ci.org/visionmedia/bytes.js
|
|
124
|
-
[coveralls-image]: https://img.shields.io/coveralls/visionmedia/bytes.js/master.svg
|
|
125
|
-
[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master
|
|
@@ -30,10 +30,11 @@ var map = {
|
|
|
30
30
|
kb: 1 << 10,
|
|
31
31
|
mb: 1 << 20,
|
|
32
32
|
gb: 1 << 30,
|
|
33
|
-
tb: (
|
|
33
|
+
tb: Math.pow(1024, 4),
|
|
34
|
+
pb: Math.pow(1024, 5),
|
|
34
35
|
};
|
|
35
36
|
|
|
36
|
-
var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb)$/i;
|
|
37
|
+
var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Convert the given value in bytes into a string or parse to string to an integer in bytes.
|
|
@@ -93,7 +94,9 @@ function format(value, options) {
|
|
|
93
94
|
var unit = (options && options.unit) || '';
|
|
94
95
|
|
|
95
96
|
if (!unit || !map[unit.toLowerCase()]) {
|
|
96
|
-
if (mag >= map.
|
|
97
|
+
if (mag >= map.pb) {
|
|
98
|
+
unit = 'PB';
|
|
99
|
+
} else if (mag >= map.tb) {
|
|
97
100
|
unit = 'TB';
|
|
98
101
|
} else if (mag >= map.gb) {
|
|
99
102
|
unit = 'GB';
|
|
@@ -114,7 +117,11 @@ function format(value, options) {
|
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
if (thousandsSeparator) {
|
|
117
|
-
str = str.
|
|
120
|
+
str = str.split('.').map(function (s, i) {
|
|
121
|
+
return i === 0
|
|
122
|
+
? s.replace(formatThousandsRegExp, thousandsSeparator)
|
|
123
|
+
: s
|
|
124
|
+
}).join('.');
|
|
118
125
|
}
|
|
119
126
|
|
|
120
127
|
return str + unitSeparator + unit;
|
|
@@ -155,5 +162,9 @@ function parse(val) {
|
|
|
155
162
|
unit = results[4].toLowerCase();
|
|
156
163
|
}
|
|
157
164
|
|
|
165
|
+
if (isNaN(floatValue)) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
|
|
158
169
|
return Math.floor(map[unit] * floatValue);
|
|
159
170
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bytes",
|
|
3
3
|
"description": "Utility to parse a string bytes to bytes and vice-versa",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.1.2",
|
|
5
5
|
"author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Jed Watson <jed.watson@me.com>",
|
|
@@ -19,8 +19,10 @@
|
|
|
19
19
|
],
|
|
20
20
|
"repository": "visionmedia/bytes.js",
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
22
|
+
"eslint": "7.32.0",
|
|
23
|
+
"eslint-plugin-markdown": "2.2.1",
|
|
24
|
+
"mocha": "9.2.0",
|
|
25
|
+
"nyc": "15.1.0"
|
|
24
26
|
},
|
|
25
27
|
"files": [
|
|
26
28
|
"History.md",
|
|
@@ -32,8 +34,9 @@
|
|
|
32
34
|
"node": ">= 0.8"
|
|
33
35
|
},
|
|
34
36
|
"scripts": {
|
|
37
|
+
"lint": "eslint .",
|
|
35
38
|
"test": "mocha --check-leaks --reporter spec",
|
|
36
|
-
"test-ci": "nyc --reporter=text npm test",
|
|
39
|
+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
|
37
40
|
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
|
38
41
|
}
|
|
39
42
|
}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
1.7.5 / 2024-10-31
|
|
2
|
+
==========
|
|
3
|
+
|
|
4
|
+
* deps: Replace accepts with negotiator@~0.6.4
|
|
5
|
+
- Add preference option
|
|
6
|
+
* deps: bytes@3.1.2
|
|
7
|
+
- Add petabyte (`pb`) support
|
|
8
|
+
- Fix "thousandsSeparator" incorrecting formatting fractional part
|
|
9
|
+
- Fix return value for un-parsable strings
|
|
10
|
+
* deps: compressible@~2.0.18
|
|
11
|
+
- Mark `font/ttf` as compressible
|
|
12
|
+
- Remove compressible from `multipart/mixed`
|
|
13
|
+
- deps: mime-db@'>= 1.43.0 < 2'
|
|
14
|
+
* deps: safe-buffer@5.2.1
|
|
15
|
+
|
|
1
16
|
1.7.4 / 2019-03-18
|
|
2
17
|
==================
|
|
3
18
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[![NPM Version][npm-image]][npm-url]
|
|
4
4
|
[![NPM Downloads][downloads-image]][downloads-url]
|
|
5
|
-
[![Build Status][
|
|
5
|
+
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
|
|
6
6
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
7
7
|
|
|
8
8
|
Node.js compression middleware.
|
|
@@ -24,8 +24,6 @@ $ npm install compression
|
|
|
24
24
|
|
|
25
25
|
## API
|
|
26
26
|
|
|
27
|
-
<!-- eslint-disable no-unused-vars -->
|
|
28
|
-
|
|
29
27
|
```js
|
|
30
28
|
var compression = require('compression')
|
|
31
29
|
```
|
|
@@ -33,7 +31,7 @@ var compression = require('compression')
|
|
|
33
31
|
### compression([options])
|
|
34
32
|
|
|
35
33
|
Returns the compression middleware using the given `options`. The middleware
|
|
36
|
-
will attempt to compress response bodies for all
|
|
34
|
+
will attempt to compress response bodies for all requests that traverse through
|
|
37
35
|
the middleware, based on the given `options`.
|
|
38
36
|
|
|
39
37
|
This middleware will never compress responses that include a `Cache-Control`
|
|
@@ -232,9 +230,9 @@ app.get('/events', function (req, res) {
|
|
|
232
230
|
|
|
233
231
|
[npm-image]: https://img.shields.io/npm/v/compression.svg
|
|
234
232
|
[npm-url]: https://npmjs.org/package/compression
|
|
235
|
-
[travis-image]: https://img.shields.io/travis/expressjs/compression/master.svg
|
|
236
|
-
[travis-url]: https://travis-ci.org/expressjs/compression
|
|
237
233
|
[coveralls-image]: https://img.shields.io/coveralls/expressjs/compression/master.svg
|
|
238
234
|
[coveralls-url]: https://coveralls.io/r/expressjs/compression?branch=master
|
|
239
235
|
[downloads-image]: https://img.shields.io/npm/dm/compression.svg
|
|
240
236
|
[downloads-url]: https://npmjs.org/package/compression
|
|
237
|
+
[github-actions-ci-image]: https://badgen.net/github/checks/expressjs/compression/master?label=ci
|
|
238
|
+
[github-actions-ci-url]: https://github.com/expressjs/compression/actions?query=workflow%3Aci
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* @private
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var Negotiator = require('negotiator')
|
|
18
18
|
var Buffer = require('safe-buffer').Buffer
|
|
19
19
|
var bytes = require('bytes')
|
|
20
20
|
var compressible = require('compressible')
|
|
@@ -174,13 +174,8 @@ function compression (options) {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
// compression method
|
|
177
|
-
var
|
|
178
|
-
var method =
|
|
179
|
-
|
|
180
|
-
// we really don't prefer deflate
|
|
181
|
-
if (method === 'deflate' && accept.encoding(['gzip'])) {
|
|
182
|
-
method = accept.encoding(['gzip', 'identity'])
|
|
183
|
-
}
|
|
177
|
+
var negotiator = new Negotiator(req)
|
|
178
|
+
var method = negotiator.encoding(['gzip', 'deflate', 'identity'], ['gzip'])
|
|
184
179
|
|
|
185
180
|
// negotiation failed
|
|
186
181
|
if (!method || method === 'identity') {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compression",
|
|
3
3
|
"description": "Node.js compression middleware",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.5",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
|
7
7
|
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
|
@@ -9,26 +9,26 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": "expressjs/compression",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"compressible": "~2.0.16",
|
|
12
|
+
"bytes": "3.1.2",
|
|
13
|
+
"compressible": "~2.0.18",
|
|
15
14
|
"debug": "2.6.9",
|
|
15
|
+
"negotiator": "~0.6.4",
|
|
16
16
|
"on-headers": "~1.0.2",
|
|
17
|
-
"safe-buffer": "5.1
|
|
17
|
+
"safe-buffer": "5.2.1",
|
|
18
18
|
"vary": "~1.1.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"after": "0.8.2",
|
|
22
|
-
"eslint": "
|
|
23
|
-
"eslint-config-standard": "
|
|
24
|
-
"eslint-plugin-import": "2.
|
|
25
|
-
"eslint-plugin-markdown": "
|
|
26
|
-
"eslint-plugin-node": "
|
|
27
|
-
"eslint-plugin-promise": "
|
|
28
|
-
"eslint-plugin-standard": "4.
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"supertest": "
|
|
22
|
+
"eslint": "7.32.0",
|
|
23
|
+
"eslint-config-standard": "14.1.1",
|
|
24
|
+
"eslint-plugin-import": "2.26.0",
|
|
25
|
+
"eslint-plugin-markdown": "2.2.1",
|
|
26
|
+
"eslint-plugin-node": "11.1.0",
|
|
27
|
+
"eslint-plugin-promise": "5.2.0",
|
|
28
|
+
"eslint-plugin-standard": "4.1.0",
|
|
29
|
+
"mocha": "9.2.2",
|
|
30
|
+
"nyc": "15.1.0",
|
|
31
|
+
"supertest": "6.2.3"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
34
|
"LICENSE",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"node": ">= 0.8.0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
|
-
"lint": "eslint
|
|
43
|
-
"test": "mocha --check-leaks --reporter spec
|
|
44
|
-
"test-
|
|
45
|
-
"test-
|
|
42
|
+
"lint": "eslint .",
|
|
43
|
+
"test": "mocha --check-leaks --reporter spec",
|
|
44
|
+
"test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
|
|
45
|
+
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -172,6 +172,10 @@ Returns the most preferred encoding from the client.
|
|
|
172
172
|
|
|
173
173
|
Returns the most preferred encoding from a list of available encodings.
|
|
174
174
|
|
|
175
|
+
##### encoding(availableEncodings, preferred)
|
|
176
|
+
|
|
177
|
+
Returns the most preferred encoding from a list of available encodings, while prioritizing based on `preferred` array between same-quality encodings.
|
|
178
|
+
|
|
175
179
|
##### encodings()
|
|
176
180
|
|
|
177
181
|
Returns an array of preferred encodings ordered by the client preference.
|
|
@@ -181,6 +185,11 @@ Returns an array of preferred encodings ordered by the client preference.
|
|
|
181
185
|
Returns an array of preferred encodings ordered by priority from a list of
|
|
182
186
|
available encodings.
|
|
183
187
|
|
|
188
|
+
##### encodings(availableEncodings, preferred)
|
|
189
|
+
|
|
190
|
+
Returns an array of preferred encodings ordered by priority from a list of
|
|
191
|
+
available encodings, while prioritizing based on `preferred` array between same-quality encodings.
|
|
192
|
+
|
|
184
193
|
## See Also
|
|
185
194
|
|
|
186
195
|
The [accepts](https://npmjs.org/package/accepts#readme) module builds on
|
|
@@ -44,13 +44,13 @@ Negotiator.prototype.charsets = function charsets(available) {
|
|
|
44
44
|
return preferredCharsets(this.request.headers['accept-charset'], available);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
Negotiator.prototype.encoding = function encoding(available) {
|
|
48
|
-
var set = this.encodings(available);
|
|
47
|
+
Negotiator.prototype.encoding = function encoding(available, preferred) {
|
|
48
|
+
var set = this.encodings(available, preferred);
|
|
49
49
|
return set && set[0];
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
Negotiator.prototype.encodings = function encodings(available) {
|
|
53
|
-
return preferredEncodings(this.request.headers['accept-encoding'], available);
|
|
52
|
+
Negotiator.prototype.encodings = function encodings(available, preferred) {
|
|
53
|
+
return preferredEncodings(this.request.headers['accept-encoding'], available, preferred);
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
Negotiator.prototype.language = function language(available) {
|
|
@@ -96,7 +96,7 @@ function parseEncoding(str, i) {
|
|
|
96
96
|
*/
|
|
97
97
|
|
|
98
98
|
function getEncodingPriority(encoding, accepted, index) {
|
|
99
|
-
var priority = {o: -1, q: 0, s: 0};
|
|
99
|
+
var priority = {encoding: encoding, o: -1, q: 0, s: 0};
|
|
100
100
|
|
|
101
101
|
for (var i = 0; i < accepted.length; i++) {
|
|
102
102
|
var spec = specify(encoding, accepted[i], index);
|
|
@@ -123,6 +123,7 @@ function specify(encoding, spec, index) {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
return {
|
|
126
|
+
encoding: encoding,
|
|
126
127
|
i: index,
|
|
127
128
|
o: spec.i,
|
|
128
129
|
q: spec.q,
|
|
@@ -135,14 +136,34 @@ function specify(encoding, spec, index) {
|
|
|
135
136
|
* @public
|
|
136
137
|
*/
|
|
137
138
|
|
|
138
|
-
function preferredEncodings(accept, provided) {
|
|
139
|
+
function preferredEncodings(accept, provided, preferred) {
|
|
139
140
|
var accepts = parseAcceptEncoding(accept || '');
|
|
140
141
|
|
|
142
|
+
var comparator = preferred ? function comparator (a, b) {
|
|
143
|
+
if (a.q !== b.q) {
|
|
144
|
+
return b.q - a.q // higher quality first
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
var aPreferred = preferred.indexOf(a.encoding)
|
|
148
|
+
var bPreferred = preferred.indexOf(b.encoding)
|
|
149
|
+
|
|
150
|
+
if (aPreferred === -1 && bPreferred === -1) {
|
|
151
|
+
// consider the original specifity/order
|
|
152
|
+
return (b.s - a.s) || (a.o - b.o) || (a.i - b.i)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (aPreferred !== -1 && bPreferred !== -1) {
|
|
156
|
+
return aPreferred - bPreferred // consider the preferred order
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return aPreferred === -1 ? 1 : -1 // preferred first
|
|
160
|
+
} : compareSpecs;
|
|
161
|
+
|
|
141
162
|
if (!provided) {
|
|
142
163
|
// sorted list of all encodings
|
|
143
164
|
return accepts
|
|
144
165
|
.filter(isQuality)
|
|
145
|
-
.sort(
|
|
166
|
+
.sort(comparator)
|
|
146
167
|
.map(getFullEncoding);
|
|
147
168
|
}
|
|
148
169
|
|
|
@@ -151,7 +172,7 @@ function preferredEncodings(accept, provided) {
|
|
|
151
172
|
});
|
|
152
173
|
|
|
153
174
|
// sorted list of accepted encodings
|
|
154
|
-
return priorities.filter(isQuality).sort(
|
|
175
|
+
return priorities.filter(isQuality).sort(comparator).map(function getEncoding(priority) {
|
|
155
176
|
return provided[priorities.indexOf(priority)];
|
|
156
177
|
});
|
|
157
178
|
}
|
|
@@ -162,7 +183,7 @@ function preferredEncodings(accept, provided) {
|
|
|
162
183
|
*/
|
|
163
184
|
|
|
164
185
|
function compareSpecs(a, b) {
|
|
165
|
-
return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i)
|
|
186
|
+
return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i);
|
|
166
187
|
}
|
|
167
188
|
|
|
168
189
|
/**
|
|
@@ -69,7 +69,7 @@ function parseMediaType(str, i) {
|
|
|
69
69
|
|
|
70
70
|
// get the value, unwrapping quotes
|
|
71
71
|
var value = val && val[0] === '"' && val[val.length - 1] === '"'
|
|
72
|
-
? val.
|
|
72
|
+
? val.slice(1, -1)
|
|
73
73
|
: val;
|
|
74
74
|
|
|
75
75
|
if (key === 'q') {
|
|
@@ -238,8 +238,8 @@ function splitKeyValuePair(str) {
|
|
|
238
238
|
if (index === -1) {
|
|
239
239
|
key = str;
|
|
240
240
|
} else {
|
|
241
|
-
key = str.
|
|
242
|
-
val = str.
|
|
241
|
+
key = str.slice(0, index);
|
|
242
|
+
val = str.slice(index + 1);
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
return [key, val];
|
|
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [v1.13.3](https://github.com/inspect-js/object-inspect/compare/v1.13.2...v1.13.3) - 2024-11-09
|
|
9
|
+
|
|
10
|
+
### Commits
|
|
11
|
+
|
|
12
|
+
- [actions] split out node 10-20, and 20+ [`44395a8`](https://github.com/inspect-js/object-inspect/commit/44395a8fc1deda6718a5e125e86b9ffcaa1c7580)
|
|
13
|
+
- [Fix] `quoteStyle`: properly escape only the containing quotes [`5137f8f`](https://github.com/inspect-js/object-inspect/commit/5137f8f7bea69a7fc671bb683fd35f244f38fc52)
|
|
14
|
+
- [Refactor] clean up `quoteStyle` code [`450680c`](https://github.com/inspect-js/object-inspect/commit/450680cd50de4e689ee3b8e1d6db3a1bcf3fc18c)
|
|
15
|
+
- [Tests] add `quoteStyle` escaping tests [`e997c59`](https://github.com/inspect-js/object-inspect/commit/e997c595aeaea84fd98ca35d7e1c3b5ab3ae26e0)
|
|
16
|
+
- [Dev Deps] update `auto-changelog`, `es-value-fixtures`, `tape` [`d5a469c`](https://github.com/inspect-js/object-inspect/commit/d5a469c99ec07ccaeafc36ac4b36a93285086d48)
|
|
17
|
+
- [Tests] replace `aud` with `npm audit` [`fb7815f`](https://github.com/inspect-js/object-inspect/commit/fb7815f9b72cae277a04f65bbb0543f85b88be62)
|
|
18
|
+
- [Dev Deps] update `mock-property` [`11c817b`](https://github.com/inspect-js/object-inspect/commit/11c817bf10392aa017755962ba6bc89d731359ee)
|
|
19
|
+
|
|
8
20
|
## [v1.13.2](https://github.com/inspect-js/object-inspect/compare/v1.13.1...v1.13.2) - 2024-06-21
|
|
9
21
|
|
|
10
22
|
### Commits
|
|
@@ -69,10 +69,21 @@ var utilInspect = require('./util.inspect');
|
|
|
69
69
|
var inspectCustom = utilInspect.custom;
|
|
70
70
|
var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
|
|
71
71
|
|
|
72
|
+
var quotes = {
|
|
73
|
+
__proto__: null,
|
|
74
|
+
'double': '"',
|
|
75
|
+
single: "'"
|
|
76
|
+
};
|
|
77
|
+
var quoteREs = {
|
|
78
|
+
__proto__: null,
|
|
79
|
+
'double': /(["\\])/g,
|
|
80
|
+
single: /(['\\])/g
|
|
81
|
+
};
|
|
82
|
+
|
|
72
83
|
module.exports = function inspect_(obj, options, depth, seen) {
|
|
73
84
|
var opts = options || {};
|
|
74
85
|
|
|
75
|
-
if (has(opts, 'quoteStyle') && (
|
|
86
|
+
if (has(opts, 'quoteStyle') && !has(quotes, opts.quoteStyle)) {
|
|
76
87
|
throw new TypeError('option "quoteStyle" must be "single" or "double"');
|
|
77
88
|
}
|
|
78
89
|
if (
|
|
@@ -267,7 +278,8 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
267
278
|
};
|
|
268
279
|
|
|
269
280
|
function wrapQuotes(s, defaultStyle, opts) {
|
|
270
|
-
var
|
|
281
|
+
var style = opts.quoteStyle || defaultStyle;
|
|
282
|
+
var quoteChar = quotes[style];
|
|
271
283
|
return quoteChar + s + quoteChar;
|
|
272
284
|
}
|
|
273
285
|
|
|
@@ -425,8 +437,10 @@ function inspectString(str, opts) {
|
|
|
425
437
|
var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
|
|
426
438
|
return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
|
|
427
439
|
}
|
|
440
|
+
var quoteRE = quoteREs[opts.quoteStyle || 'single'];
|
|
441
|
+
quoteRE.lastIndex = 0;
|
|
428
442
|
// eslint-disable-next-line no-control-regex
|
|
429
|
-
var s = $replace.call($replace.call(str,
|
|
443
|
+
var s = $replace.call($replace.call(str, quoteRE, '\\$1'), /[\x00-\x1f]/g, lowbyte);
|
|
430
444
|
return wrapQuotes(s, 'single', opts);
|
|
431
445
|
}
|
|
432
446
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "object-inspect",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.3",
|
|
4
4
|
"description": "string representations of objects in node and the browser",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@ljharb/eslint-config": "^21.1.1",
|
|
9
9
|
"@pkgjs/support": "^0.0.6",
|
|
10
|
-
"auto-changelog": "^2.
|
|
10
|
+
"auto-changelog": "^2.5.0",
|
|
11
11
|
"core-js": "^2.6.12",
|
|
12
12
|
"error-cause": "^1.0.8",
|
|
13
|
-
"es-value-fixtures": "^1.
|
|
13
|
+
"es-value-fixtures": "^1.5.0",
|
|
14
14
|
"eslint": "=8.8.0",
|
|
15
15
|
"for-each": "^0.3.3",
|
|
16
16
|
"functions-have-names": "^1.2.3",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"in-publish": "^2.0.1",
|
|
22
22
|
"jackspeak": "=2.1.1",
|
|
23
23
|
"make-arrow-function": "^1.2.0",
|
|
24
|
-
"mock-property": "^1.0
|
|
24
|
+
"mock-property": "^1.1.0",
|
|
25
25
|
"npmignore": "^0.3.1",
|
|
26
26
|
"nyc": "^10.3.2",
|
|
27
27
|
"safe-publish-latest": "^2.0.0",
|
|
28
28
|
"safer-buffer": "^2.1.2",
|
|
29
29
|
"string.prototype.repeat": "^1.0.0",
|
|
30
|
-
"tape": "^5.
|
|
30
|
+
"tape": "^5.9.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"prepack": "npmignore --auto --commentLines=autogenerated",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test": "npm run tests-only && npm run test:corejs",
|
|
40
40
|
"tests-only": "nyc tape 'test/*.js'",
|
|
41
41
|
"test:corejs": "nyc tape test-core-js.js 'test/*.js'",
|
|
42
|
-
"posttest": "npx
|
|
42
|
+
"posttest": "npx npm@'>=10.2' audit --production",
|
|
43
43
|
"version": "auto-changelog && git add CHANGELOG.md",
|
|
44
44
|
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
|
45
45
|
},
|
|
@@ -13,5 +13,14 @@ test('quoteStyle option', function (t) {
|
|
|
13
13
|
t['throws'](function () { inspect(null, { quoteStyle: NaN }); }, 'NaN is not a valid value');
|
|
14
14
|
t['throws'](function () { inspect(null, { quoteStyle: function () {} }); }, 'a function is not a valid value');
|
|
15
15
|
|
|
16
|
+
t.equal(inspect('"', { quoteStyle: 'single' }), '\'"\'', 'double quote, quoteStyle: "single"');
|
|
17
|
+
t.equal(inspect('"', { quoteStyle: 'double' }), '"\\""', 'double quote, quoteStyle: "double"');
|
|
18
|
+
|
|
19
|
+
t.equal(inspect('\'', { quoteStyle: 'single' }), '\'\\\'\'', 'single quote, quoteStyle: "single"');
|
|
20
|
+
t.equal(inspect('\'', { quoteStyle: 'double' }), '"\'"', 'single quote, quoteStyle: "double"');
|
|
21
|
+
|
|
22
|
+
t.equal(inspect('`', { quoteStyle: 'single' }), '\'`\'', 'backtick, quoteStyle: "single"');
|
|
23
|
+
t.equal(inspect('`', { quoteStyle: 'double' }), '"`"', 'backtick, quoteStyle: "double"');
|
|
24
|
+
|
|
16
25
|
t.end();
|
|
17
26
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
1
2
|
/* eslint-disable node/no-deprecated-api */
|
|
2
3
|
var buffer = require('buffer')
|
|
3
4
|
var Buffer = buffer.Buffer
|
|
@@ -20,6 +21,8 @@ function SafeBuffer (arg, encodingOrOffset, length) {
|
|
|
20
21
|
return Buffer(arg, encodingOrOffset, length)
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
SafeBuffer.prototype = Object.create(Buffer.prototype)
|
|
25
|
+
|
|
23
26
|
// Copy static methods from Buffer
|
|
24
27
|
copyProps(Buffer, SafeBuffer)
|
|
25
28
|
|