rekwest 2.3.5 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -8,14 +8,14 @@
8
8
  "url": "https://github.com/bricss/rekwest/issues"
9
9
  },
10
10
  "devDependencies": {
11
- "@babel/cli": "^7.16.8",
12
- "@babel/core": "^7.16.12",
13
- "@babel/eslint-parser": "^7.16.5",
11
+ "@babel/cli": "^7.17.6",
12
+ "@babel/core": "^7.17.5",
13
+ "@babel/eslint-parser": "^7.17.0",
14
14
  "@babel/preset-env": "^7.16.11",
15
15
  "c8": "^7.11.0",
16
- "eslint": "^8.7.0",
17
- "eslint-config-ultra-refined": "^2.3.0",
18
- "mocha": "^9.2.0"
16
+ "eslint": "^8.10.0",
17
+ "eslint-config-ultra-refined": "^2.4.1",
18
+ "mocha": "^9.2.1"
19
19
  },
20
20
  "description": "The robust request library that humanity deserves 🌐",
21
21
  "engines": {
@@ -56,8 +56,9 @@
56
56
  "lint": "eslint . --ext .cjs,.js,.mjs",
57
57
  "prepack": "npm run build && sh pony.sh",
58
58
  "pretest": "rm -rf coverage && npm run cert:gen",
59
- "test": "mocha --exit --recursive",
59
+ "test": "mocha",
60
+ "test:bail": "mocha --bail",
60
61
  "test:cover": "c8 --include=src --reporter=lcov --reporter=text npm test"
61
62
  },
62
- "version": "2.3.5"
63
+ "version": "3.0.0"
63
64
  }
package/src/ackn.mjs CHANGED
@@ -1,33 +1,33 @@
1
- import { connect } from 'tls';
2
-
3
- export const ackn = (options) => new Promise((resolve, reject) => {
4
- const { url } = options;
5
- const socket = connect({
6
- ...options,
7
- ALPNProtocols: [
8
- 'h2',
9
- 'http/1.1',
10
- ],
11
- host: url.hostname,
12
- port: parseInt(url.port) || 443,
13
- servername: url.hostname,
14
- }, () => {
15
- socket.off('error', reject);
16
- socket.off('timeout', reject);
17
-
18
- const { alpnProtocol } = socket;
19
-
20
- resolve({
21
- ...options,
22
- alpnProtocol,
23
- createConnection() {
24
- return socket;
25
- },
26
- h2: /h2c?/.test(alpnProtocol),
27
- protocol: url.protocol,
28
- });
29
- });
30
-
31
- socket.on('error', reject);
32
- socket.on('timeout', reject);
33
- });
1
+ import { connect } from 'tls';
2
+
3
+ export const ackn = (options) => new Promise((resolve, reject) => {
4
+ const { url } = options;
5
+ const socket = connect({
6
+ ...options,
7
+ ALPNProtocols: [
8
+ 'h2',
9
+ 'http/1.1',
10
+ ],
11
+ host: url.hostname,
12
+ port: parseInt(url.port) || 443,
13
+ servername: url.hostname,
14
+ }, () => {
15
+ socket.off('error', reject);
16
+ socket.off('timeout', reject);
17
+
18
+ const { alpnProtocol } = socket;
19
+
20
+ resolve({
21
+ ...options,
22
+ alpnProtocol,
23
+ createConnection() {
24
+ return socket;
25
+ },
26
+ h2: /h2c?/.test(alpnProtocol),
27
+ protocol: url.protocol,
28
+ });
29
+ });
30
+
31
+ socket.on('error', reject);
32
+ socket.on('timeout', reject);
33
+ });
package/src/cookies.mjs CHANGED
@@ -1,24 +1,24 @@
1
- export class Cookies extends URLSearchParams {
2
-
3
- static jar = new Map();
4
-
5
- get [Symbol.toStringTag]() {
6
- return this.constructor.name;
7
- }
8
-
9
- constructor(input) {
10
- if (Array.isArray(input) && input.every((it) => !Array.isArray(it))) {
11
- input = input.join(';').split(';')
12
- .filter((it) => !/\b(Domain|Expires|HttpOnly|Max-Age|Path|SameParty|SameSite|Secure)\b/i.test(it))
13
- .map((it) => it.trim())
14
- .join('&');
15
- }
16
-
17
- super(input);
18
- }
19
-
20
- toString() {
21
- return super.toString().split('&').join('; ').trim();
22
- }
23
-
24
- }
1
+ export class Cookies extends URLSearchParams {
2
+
3
+ static jar = new Map();
4
+
5
+ get [Symbol.toStringTag]() {
6
+ return this.constructor.name;
7
+ }
8
+
9
+ constructor(input) {
10
+ if (Array.isArray(input) && input.every((it) => !Array.isArray(it))) {
11
+ input = input.join(';').split(';')
12
+ .filter((it) => !/\b(Domain|Expires|HttpOnly|Max-Age|Path|SameParty|SameSite|Secure)\b/i.test(it))
13
+ .map((it) => it.trim())
14
+ .join('&');
15
+ }
16
+
17
+ super(input);
18
+ }
19
+
20
+ toString() {
21
+ return super.toString().split('&').join('; ').trim();
22
+ }
23
+
24
+ }
package/src/errors.mjs CHANGED
@@ -8,9 +8,11 @@ export class RequestError extends Error {
8
8
  return this[Symbol.toStringTag];
9
9
  }
10
10
 
11
- constructor(message) {
12
- super(message);
11
+ constructor(...args) {
12
+ super(...args);
13
13
  Error.captureStackTrace(this, this.constructor);
14
14
  }
15
15
 
16
16
  }
17
+
18
+ export class TimeoutError extends RequestError {}
package/src/file.mjs CHANGED
@@ -1,40 +1,40 @@
1
- import { Blob } from 'buffer';
2
-
3
- export { Blob } from 'buffer';
4
-
5
- export class File extends Blob {
6
-
7
- static alike(instance) {
8
- return [
9
- Blob.name,
10
- File.name,
11
- ].includes(instance?.constructor.name);
12
- }
13
-
14
- #lastModified;
15
- #name;
16
-
17
- get [Symbol.toStringTag]() {
18
- return this.constructor.name;
19
- }
20
-
21
- get lastModified() {
22
- return this.#lastModified;
23
- }
24
-
25
- get name() {
26
- return this.#name;
27
- }
28
-
29
- constructor(bits, name = 'blob', options = {}) {
30
- const {
31
- name: filename,
32
- lastModified = Date.now(),
33
- } = options;
34
-
35
- super(bits, options);
36
- this.#lastModified = lastModified;
37
- this.#name = filename || name;
38
- }
39
-
40
- }
1
+ import { Blob } from 'buffer';
2
+
3
+ export { Blob } from 'buffer';
4
+
5
+ export class File extends Blob {
6
+
7
+ static alike(instance) {
8
+ return [
9
+ Blob.name,
10
+ File.name,
11
+ ].includes(instance?.constructor.name);
12
+ }
13
+
14
+ #lastModified;
15
+ #name;
16
+
17
+ get [Symbol.toStringTag]() {
18
+ return this.constructor.name;
19
+ }
20
+
21
+ get lastModified() {
22
+ return this.#lastModified;
23
+ }
24
+
25
+ get name() {
26
+ return this.#name;
27
+ }
28
+
29
+ constructor(bits, name = 'blob', options = {}) {
30
+ const {
31
+ name: filename,
32
+ lastModified = Date.now(),
33
+ } = options;
34
+
35
+ super(bits, options);
36
+ this.#lastModified = lastModified;
37
+ this.#name = filename || name;
38
+ }
39
+
40
+ }