@h3ravel/shared 0.25.0 → 0.27.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/dist/index.js CHANGED
@@ -7,44 +7,6 @@ import { confirm, input, password, select } from "@inquirer/prompts";
7
7
  import crypto from "crypto";
8
8
  import preferredPM from "preferred-pm";
9
9
 
10
- //#region src/Contracts/IHttp.ts
11
- /**
12
- * Represents the HTTP context for a single request lifecycle.
13
- * Encapsulates the application instance, request, and response objects.
14
- */
15
- var HttpContext = class HttpContext {
16
- static contexts = /* @__PURE__ */ new WeakMap();
17
- constructor(app, request, response) {
18
- this.app = app;
19
- this.request = request;
20
- this.response = response;
21
- }
22
- /**
23
- * Factory method to create a new HttpContext instance from a context object.
24
- * @param ctx - Object containing app, request, and response
25
- * @returns A new HttpContext instance
26
- */
27
- static init(ctx, event) {
28
- if (event && HttpContext.contexts.has(event)) return HttpContext.contexts.get(event);
29
- const instance = new HttpContext(ctx.app, ctx.request, ctx.response);
30
- if (event) HttpContext.contexts.set(event, instance);
31
- return instance;
32
- }
33
- /**
34
- * Retrieve an existing HttpContext instance for an event, if any.
35
- */
36
- static get(event) {
37
- return HttpContext.contexts.get(event);
38
- }
39
- /**
40
- * Delete the cached context for a given event (optional cleanup).
41
- */
42
- static forget(event) {
43
- HttpContext.contexts.delete(event);
44
- }
45
- };
46
-
47
- //#endregion
48
10
  //#region src/Utils/EnvParser.ts
49
11
  var EnvParser = class {
50
12
  static parse(initial) {
@@ -435,6 +397,16 @@ var Resolver = class {
435
397
  static hashObjectOrFunction(provider) {
436
398
  return crypto.createHash("sha1").update(provider.toString()).digest("hex");
437
399
  }
400
+ /**
401
+ * Checks if a function is asyncronous
402
+ *
403
+ * @param func
404
+ * @returns
405
+ */
406
+ static isAsyncFunction(func) {
407
+ if (typeof func !== "function") return false;
408
+ return Object.prototype.toString.call(func) === "[object AsyncFunction]";
409
+ }
438
410
  };
439
411
 
440
412
  //#endregion
@@ -524,4 +496,4 @@ var TaskManager = class {
524
496
  };
525
497
 
526
498
  //#endregion
527
- export { EnvParser, FileSystem, HttpContext, Logger, PathLoader, Prompts, Resolver, TaskManager, baseTsconfig, mainTsconfig, packageJsonScript };
499
+ export { EnvParser, FileSystem, Logger, PathLoader, Prompts, Resolver, TaskManager, baseTsconfig, mainTsconfig, packageJsonScript };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h3ravel/shared",
3
- "version": "0.25.0",
3
+ "version": "0.27.0",
4
4
  "description": "Shared Utilities.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",