@stryke/http 0.9.0 → 0.10.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.
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getFreePort = void 0;
7
+ var _nodeHttp = require("node:http");
8
+ const getFreePort = async () => new Promise((s, o) => {
9
+ const r = (0, _nodeHttp.createServer)(() => {});
10
+ r.listen(0, () => {
11
+ const e = r.address();
12
+ r.close(), e && typeof e == "object" ? s(e.port) : o(new Error(`invalid address from server: ${e?.toString()}`));
13
+ });
14
+ });
15
+ exports.getFreePort = getFreePort;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Finds and returns a free port on the local machine by creating a temporary server that listens on port 0. The operating system assigns an available port, which is then retrieved and returned.
3
+ *
4
+ * @returns A promise that resolves to a free port number.
5
+ */
6
+ export declare const getFreePort: () => Promise<number>;
@@ -0,0 +1 @@
1
+ import{createServer as t}from"node:http";export const getFreePort=async()=>new Promise((s,o)=>{const r=t(()=>{});r.listen(0,()=>{const e=r.address();r.close(),e&&typeof e=="object"?s(e.port):o(new Error(`invalid address from server: ${e?.toString()}`))})});
package/dist/index.cjs CHANGED
@@ -36,6 +36,17 @@ Object.keys(_formatDataUri).forEach(function (key) {
36
36
  }
37
37
  });
38
38
  });
39
+ var _getFreePort = require("./get-free-port.cjs");
40
+ Object.keys(_getFreePort).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _getFreePort[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _getFreePort[key];
47
+ }
48
+ });
49
+ });
39
50
  var _httpProxy = require("./http-proxy.cjs");
40
51
  Object.keys(_httpProxy).forEach(function (key) {
41
52
  if (key === "default" || key === "__esModule") return;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./agent";
2
2
  export * from "./fetch";
3
3
  export * from "./format-data-uri";
4
+ export * from "./get-free-port";
4
5
  export * from "./http-proxy";
5
6
  export * from "./https-proxy";
6
7
  export * from "./parse-response";
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export*from"./agent";export*from"./fetch";export*from"./format-data-uri";export*from"./http-proxy";export*from"./https-proxy";export*from"./parse-response";export*from"./proxy-agent";
1
+ export*from"./agent";export*from"./fetch";export*from"./format-data-uri";export*from"./get-free-port";export*from"./http-proxy";export*from"./https-proxy";export*from"./parse-response";export*from"./proxy-agent";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/http",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "description": "A package containing HTTP communication utilities used by Storm Software.",
6
6
  "repository": {
@@ -11,7 +11,7 @@
11
11
  "private": false,
12
12
  "devDependencies": { "@types/node": "^22.14.0" },
13
13
  "publishConfig": { "access": "public" },
14
- "dependencies": { "@stryke/type-checks": "^0.3.9" },
14
+ "dependencies": { "@stryke/type-checks": "^0.3.10" },
15
15
  "sideEffects": false,
16
16
  "files": ["dist/**/*"],
17
17
  "homepage": "https://stormsoftware.com",
@@ -119,6 +119,20 @@
119
119
  "default": "./dist/http-proxy.mjs"
120
120
  }
121
121
  },
122
+ "./get-free-port": {
123
+ "import": {
124
+ "types": "./dist/get-free-port.d.ts",
125
+ "default": "./dist/get-free-port.mjs"
126
+ },
127
+ "require": {
128
+ "types": "./dist/get-free-port.d.ts",
129
+ "default": "./dist/get-free-port.cjs"
130
+ },
131
+ "default": {
132
+ "types": "./dist/get-free-port.d.ts",
133
+ "default": "./dist/get-free-port.mjs"
134
+ }
135
+ },
122
136
  "./format-data-uri": {
123
137
  "import": {
124
138
  "types": "./dist/format-data-uri.d.ts",
@@ -162,5 +176,5 @@
162
176
  "main": "./dist/index.cjs",
163
177
  "module": "./dist/index.mjs",
164
178
  "types": "./dist/index.d.ts",
165
- "gitHead": "e16a03d7f9db49ef07f8b9368c56182fa84e2bf6"
179
+ "gitHead": "4074c4a56f6e2c42ca4c39c30df5309c19024c7b"
166
180
  }