@stryke/http 0.11.0 → 0.11.1
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/dist/agent.cjs +12 -12
- package/dist/agent.mjs +1 -1
- package/package.json +3 -3
package/dist/agent.cjs
CHANGED
|
@@ -26,7 +26,7 @@ class Agent extends u.Agent {
|
|
|
26
26
|
stack: e
|
|
27
27
|
} = new Error(" ");
|
|
28
28
|
return (0, _typeChecks.isString)(e) ? e.split(`
|
|
29
|
-
`).some(
|
|
29
|
+
`).some(r => r.includes("(https.js:") || r.includes("node:https:")) : !1;
|
|
30
30
|
}
|
|
31
31
|
incrementSockets(t) {
|
|
32
32
|
if (this.maxSockets === 1 / 0 && this.maxTotalSockets === 1 / 0) return null;
|
|
@@ -38,29 +38,29 @@ class Agent extends u.Agent {
|
|
|
38
38
|
}
|
|
39
39
|
decrementSockets(t, e) {
|
|
40
40
|
if (!this.sockets[t] || e === null) return;
|
|
41
|
-
const
|
|
42
|
-
o =
|
|
43
|
-
o !== -1 && (
|
|
41
|
+
const r = this.sockets[t],
|
|
42
|
+
o = r.indexOf(e);
|
|
43
|
+
o !== -1 && (r.splice(o, 1), this.totalSocketCount--, r.length === 0 && delete this.sockets[t]);
|
|
44
44
|
}
|
|
45
45
|
getName(t) {
|
|
46
46
|
return this.isSecureEndpoint(t) ? HttpsAgent.prototype.getName.call(this, t) : super.getName(t);
|
|
47
47
|
}
|
|
48
|
-
createSocket(t, e,
|
|
48
|
+
createSocket(t, e, r) {
|
|
49
49
|
const o = {
|
|
50
50
|
...e,
|
|
51
51
|
secureEndpoint: this.isSecureEndpoint(e)
|
|
52
52
|
},
|
|
53
53
|
c = this.getName(o),
|
|
54
54
|
i = this.incrementSockets(c);
|
|
55
|
-
Promise.resolve().then(async () => this.connect(t, o)).then(
|
|
56
|
-
if (this.decrementSockets(c, i),
|
|
57
|
-
return
|
|
55
|
+
Promise.resolve().then(async () => this.connect(t, o)).then(s => {
|
|
56
|
+
if (this.decrementSockets(c, i), s instanceof u.Agent) try {
|
|
57
|
+
return s.addRequest(t, o);
|
|
58
58
|
} catch (l) {
|
|
59
|
-
return
|
|
59
|
+
return r(l);
|
|
60
60
|
}
|
|
61
|
-
this[n].currentSocket =
|
|
62
|
-
},
|
|
63
|
-
this.decrementSockets(c, i), s
|
|
61
|
+
this[n].currentSocket = s, super.createSocket(t, e, r);
|
|
62
|
+
}, s => {
|
|
63
|
+
this.decrementSockets(c, i), r(s);
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
createConnection() {
|
package/dist/agent.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{isBoolean as a,isString as p}from"@stryke/type-checks";import*as u from"node:http";import*as h from"node:net";const n=Symbol("AgentBaseInternalState");export class Agent extends u.Agent{[n];options;keepAlive;constructor(t){super(t),this[n]={}}isSecureEndpoint(t){if(t){if(a(t.secureEndpoint))return t.secureEndpoint;if(p(t.protocol))return t.protocol==="https:"}const{stack:e}=new Error(" ");return p(e)?e.split(`
|
|
2
|
-
`).some(
|
|
2
|
+
`).some(r=>r.includes("(https.js:")||r.includes("node:https:")):!1}incrementSockets(t){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;this.sockets[t]??=[];const e=new h.Socket({writable:!1});return this.sockets[t].push(e),this.totalSocketCount++,e}decrementSockets(t,e){if(!this.sockets[t]||e===null)return;const r=this.sockets[t],o=r.indexOf(e);o!==-1&&(r.splice(o,1),this.totalSocketCount--,r.length===0&&delete this.sockets[t])}getName(t){return this.isSecureEndpoint(t)?HttpsAgent.prototype.getName.call(this,t):super.getName(t)}createSocket(t,e,r){const o={...e,secureEndpoint:this.isSecureEndpoint(e)},c=this.getName(o),i=this.incrementSockets(c);Promise.resolve().then(async()=>this.connect(t,o)).then(s=>{if(this.decrementSockets(c,i),s instanceof u.Agent)try{return s.addRequest(t,o)}catch(l){return r(l)}this[n].currentSocket=s,super.createSocket(t,e,r)},s=>{this.decrementSockets(c,i),r(s)})}createConnection(){const t=this[n].currentSocket;if(this[n].currentSocket=void 0,!t)throw new Error("No socket was returned in the `connect()` function");return t}get defaultPort(){return this[n].defaultPort??(this.protocol==="https:"?443:80)}set defaultPort(t){this[n]&&(this[n].defaultPort=t)}get protocol(){return this[n].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(t){this[n]&&(this[n].protocol=t)}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/http",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing HTTP communication utilities used by Storm Software.",
|
|
6
6
|
"repository": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"private": false,
|
|
12
12
|
"dependencies": { "defu": "^6.1.4", "@stryke/type-checks": "^0.3.10" },
|
|
13
|
-
"devDependencies": { "@types/node": "^22.
|
|
13
|
+
"devDependencies": { "@types/node": "^22.18.13" },
|
|
14
14
|
"publishConfig": { "access": "public" },
|
|
15
15
|
"sideEffects": false,
|
|
16
16
|
"files": ["dist/**/*"],
|
|
@@ -176,5 +176,5 @@
|
|
|
176
176
|
"main": "./dist/index.cjs",
|
|
177
177
|
"module": "./dist/index.mjs",
|
|
178
178
|
"types": "./dist/index.d.ts",
|
|
179
|
-
"gitHead": "
|
|
179
|
+
"gitHead": "1764a8373c1db0b1c11bed7439292236edfd9e4e"
|
|
180
180
|
}
|