@h3ravel/shared 0.26.0 → 0.26.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/index.cjs CHANGED
@@ -22,7 +22,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
 
23
23
  //#endregion
24
24
  let fs_promises = require("fs/promises");
25
- fs_promises = __toESM(fs_promises);
26
25
  let escalade_sync = require("escalade/sync");
27
26
  escalade_sync = __toESM(escalade_sync);
28
27
  let path = require("path");
@@ -32,7 +31,6 @@ chalk = __toESM(chalk);
32
31
  let inquirer_autocomplete_standalone = require("inquirer-autocomplete-standalone");
33
32
  inquirer_autocomplete_standalone = __toESM(inquirer_autocomplete_standalone);
34
33
  let __inquirer_prompts = require("@inquirer/prompts");
35
- __inquirer_prompts = __toESM(__inquirer_prompts);
36
34
  let crypto = require("crypto");
37
35
  crypto = __toESM(crypto);
38
36
  let preferred_pm = require("preferred-pm");
@@ -428,6 +426,16 @@ var Resolver = class {
428
426
  static hashObjectOrFunction(provider) {
429
427
  return crypto.default.createHash("sha1").update(provider.toString()).digest("hex");
430
428
  }
429
+ /**
430
+ * Checks if a function is asyncronous
431
+ *
432
+ * @param func
433
+ * @returns
434
+ */
435
+ static isAsyncFunction(func) {
436
+ if (typeof func !== "function") return false;
437
+ return Object.prototype.toString.call(func) === "[object AsyncFunction]";
438
+ }
431
439
  };
432
440
 
433
441
  //#endregion
package/dist/index.d.ts CHANGED
@@ -1,32 +1,32 @@
1
1
  /// <reference path="./app.globals.d.ts" />
2
- import { ChalkInstance } from "chalk";
3
- import { ChoiceOrSeparatorArray, ChoiceOrSeparatorArray as ChoiceOrSeparatorArray$1 } from "inquirer-autocomplete-standalone";
4
- import { Separator } from "@inquirer/prompts";
5
2
  import { H3, H3Event, HTTPResponse, Middleware, MiddlewareOptions, serve } from "h3";
6
3
  import { Edge } from "edge.js";
7
4
  import { DotNestedKeys as DotNestedKeys$1, DotNestedValue as DotNestedValue$1 } from "@h3ravel/shared";
5
+ import { Separator } from "@inquirer/prompts";
6
+ import { ChoiceOrSeparatorArray, ChoiceOrSeparatorArray as ChoiceOrSeparatorArray$1 } from "inquirer-autocomplete-standalone";
7
+ import { ChalkInstance } from "chalk";
8
8
 
9
9
  //#region src/Contracts/ObjContract.d.ts
10
10
  /**
11
11
  * Adds a dot prefix to nested keys
12
12
  */
13
- type DotPrefix<T$1 extends string, U extends string> = T$1 extends '' ? U : `${T$1}.${U}`;
13
+ type DotPrefix<T extends string, U extends string> = T extends '' ? U : `${T}.${U}`;
14
14
  /**
15
15
  * Converts a union of objects into a single merged object
16
16
  */
17
- type MergeUnion<T$1> = (T$1 extends any ? (k: T$1) => void : never) extends ((k: infer I) => void) ? { [K in keyof I]: I[K] } : never;
17
+ type MergeUnion<T> = (T extends any ? (k: T) => void : never) extends ((k: infer I) => void) ? { [K in keyof I]: I[K] } : never;
18
18
  /**
19
19
  * Flattens nested objects into dotted keys
20
20
  */
21
- type DotFlatten<T$1, Prefix extends string = ''> = MergeUnion<{ [K in keyof T$1 & string]: T$1[K] extends Record<string, any> ? DotFlatten<T$1[K], DotPrefix<Prefix, K>> : { [P in DotPrefix<Prefix, K>]: T$1[K] } }[keyof T$1 & string]>;
21
+ type DotFlatten<T, Prefix extends string = ''> = MergeUnion<{ [K in keyof T & string]: T[K] extends Record<string, any> ? DotFlatten<T[K], DotPrefix<Prefix, K>> : { [P in DotPrefix<Prefix, K>]: T[K] } }[keyof T & string]>;
22
22
  /**
23
23
  * Builds "nested.key" paths for autocompletion
24
24
  */
25
- type DotNestedKeys<T$1> = { [K in keyof T$1 & string]: T$1[K] extends object ? `${K}` | `${K}.${DotNestedKeys<T$1[K]>}` : `${K}` }[keyof T$1 & string];
25
+ type DotNestedKeys<T> = { [K in keyof T & string]: T[K] extends object ? `${K}` | `${K}.${DotNestedKeys<T[K]>}` : `${K}` }[keyof T & string];
26
26
  /**
27
27
  * Retrieves type at a given dot-path
28
28
  */
29
- type DotNestedValue<T$1, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T$1 ? DotNestedValue<T$1[Key], Rest> : never : Path extends keyof T$1 ? T$1[Path] : never;
29
+ type DotNestedValue<T, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? DotNestedValue<T[Key], Rest> : never : Path extends keyof T ? T[Path] : never;
30
30
  /**
31
31
  * A generic object type that supports nullable string values
32
32
  */
@@ -151,67 +151,347 @@ interface IApplication extends IContainer {
151
151
  getVersion(key: string): string | undefined;
152
152
  }
153
153
  //#endregion
154
+ //#region src/Contracts/IHttpResponse.d.ts
155
+ /**
156
+ * Interface for the Response contract, defining methods for handling HTTP responses.
157
+ */
158
+ interface IHttpResponse {
159
+ /**
160
+ * Set HTTP status code.
161
+ */
162
+ setStatusCode(code: number, text?: string): this;
163
+ /**
164
+ * Retrieves the status code for the current web response.
165
+ */
166
+ getStatusCode(): number;
167
+ /**
168
+ * Sets the response charset.
169
+ */
170
+ setCharset(charset: string): this;
171
+ /**
172
+ * Retrieves the response charset.
173
+ */
174
+ getCharset(): string | undefined;
175
+ /**
176
+ * Returns true if the response may safely be kept in a shared (surrogate) cache.
177
+ *
178
+ * Responses marked "private" with an explicit Cache-Control directive are
179
+ * considered uncacheable.
180
+ *
181
+ * Responses with neither a freshness lifetime (Expires, max-age) nor cache
182
+ * validator (Last-Modified, ETag) are considered uncacheable because there is
183
+ * no way to tell when or how to remove them from the cache.
184
+ *
185
+ * Note that RFC 7231 and RFC 7234 possibly allow for a more permissive implementation,
186
+ * for example "status codes that are defined as cacheable by default [...]
187
+ * can be reused by a cache with heuristic expiration unless otherwise indicated"
188
+ * (https://tools.ietf.org/html/rfc7231#section-6.1)
189
+ *
190
+ * @final
191
+ */
192
+ isCacheable(): boolean;
193
+ /**
194
+ * Returns true if the response is "fresh".
195
+ *
196
+ * Fresh responses may be served from cache without any interaction with the
197
+ * origin. A response is considered fresh when it includes a Cache-Control/max-age
198
+ * indicator or Expires header and the calculated age is less than the freshness lifetime.
199
+ */
200
+ isFresh(): boolean;
201
+ /**
202
+ * Returns true if the response includes headers that can be used to validate
203
+ * the response with the origin server using a conditional GET request.
204
+ */
205
+ isValidateable(): boolean;
206
+ /**
207
+ * Sets the response content.
208
+ */
209
+ setContent(content?: any): this;
210
+ /**
211
+ * Gets the current response content.
212
+ */
213
+ getContent(): any;
214
+ /**
215
+ * Set a header.
216
+ */
217
+ setHeader(name: string, value: string): this;
218
+ /**
219
+ * Sets the HTTP protocol version (1.0 or 1.1).
220
+ */
221
+ setProtocolVersion(version: string): this;
222
+ /**
223
+ * Gets the HTTP protocol version.
224
+ */
225
+ getProtocolVersion(): string;
226
+ /**
227
+ * Marks the response as "private".
228
+ *
229
+ * It makes the response ineligible for serving other clients.
230
+ */
231
+ setPrivate(): this;
232
+ /**
233
+ * Marks the response as "public".
234
+ *
235
+ * It makes the response eligible for serving other clients.
236
+ */
237
+ setPublic(): this;
238
+ /**
239
+ * Returns the Date header as a DateTime instance.
240
+ * @throws {RuntimeException} When the header is not parseable
241
+ */
242
+ getDate(): any;
243
+ /**
244
+ * Returns the age of the response in seconds.
245
+ *
246
+ * @final
247
+ */
248
+ getAge(): number;
249
+ /**
250
+ * Marks the response stale by setting the Age header to be equal to the maximum age of the response.
251
+ */
252
+ expire(): this;
253
+ /**
254
+ * Returns the value of the Expires header as a DateTime instance.
255
+ *
256
+ * @final
257
+ */
258
+ getExpires(): any;
259
+ /**
260
+ * Returns the number of seconds after the time specified in the response's Date
261
+ * header when the response should no longer be considered fresh.
262
+ *
263
+ * First, it checks for a s-maxage directive, then a max-age directive, and then it falls
264
+ * back on an expires header. It returns null when no maximum age can be established.
265
+ */
266
+ getMaxAge(): number | undefined;
267
+ /**
268
+ * Sets the number of seconds after which the response should no longer be considered fresh.
269
+ *
270
+ * This method sets the Cache-Control max-age directive.
271
+ */
272
+ setMaxAge(value: number): this;
273
+ /**
274
+ * Sets the number of seconds after which the response should no longer be returned by shared caches when backend is down.
275
+ *
276
+ * This method sets the Cache-Control stale-if-error directive.
277
+ */
278
+ setStaleIfError(value: number): this;
279
+ /**
280
+ * Sets the number of seconds after which the response should no longer return stale content by shared caches.
281
+ *
282
+ * This method sets the Cache-Control stale-while-revalidate directive.
283
+ */
284
+ setStaleWhileRevalidate(value: number): this;
285
+ /**
286
+ * Returns the response's time-to-live in seconds.
287
+ *
288
+ * It returns null when no freshness information is present in the response.
289
+ *
290
+ * When the response's TTL is 0, the response may not be served from cache without first
291
+ * revalidating with the origin.
292
+ *
293
+ * @final
294
+ */
295
+ getTtl(): number | undefined;
296
+ /**
297
+ * Sets the response's time-to-live for shared caches in seconds.
298
+ *
299
+ * This method adjusts the Cache-Control/s-maxage directive.
300
+ */
301
+ setTtl(seconds: number): this;
302
+ /**
303
+ * Sets the response's time-to-live for private/client caches in seconds.
304
+ *
305
+ * This method adjusts the Cache-Control/max-age directive.
306
+ */
307
+ setClientTtl(seconds: number): this;
308
+ /**
309
+ * Sets the number of seconds after which the response should no longer be considered fresh by shared caches.
310
+ *
311
+ * This method sets the Cache-Control s-maxage directive.
312
+ */
313
+ setSharedMaxAge(value: number): this;
314
+ /**
315
+ * Returns the Last-Modified HTTP header as a DateTime instance.
316
+ *
317
+ * @throws \RuntimeException When the HTTP header is not parseable
318
+ *
319
+ * @final
320
+ */
321
+ getLastModified(): any;
322
+ /**
323
+ * Sets the Last-Modified HTTP header with a DateTime instance.
324
+ *
325
+ * Passing null as value will remove the header.
326
+ *
327
+ * @return $this
328
+ *
329
+ * @final
330
+ */
331
+ setLastModified(date?: any): this;
332
+ /**
333
+ * Returns the literal value of the ETag HTTP header.
334
+ */
335
+ getEtag(): string | null;
336
+ /**
337
+ * Sets the ETag value.
338
+ *
339
+ * @param etag The ETag unique identifier or null to remove the header
340
+ * @param weak Whether you want a weak ETag or not
341
+ */
342
+ setEtag(etag?: string, weak?: boolean): this;
343
+ /**
344
+ * Sets the response's cache headers (validation and/or expiration).
345
+ *
346
+ * Available options are: must_revalidate, no_cache, no_store, no_transform, public, private, proxy_revalidate, max_age, s_maxage, immutable, last_modified and etag.
347
+ *
348
+ * @throws {InvalidArgumentException}
349
+ */
350
+ setCache(options: any): this;
351
+ /**
352
+ * Modifies the response so that it conforms to the rules defined for a 304 status code.
353
+ *
354
+ * This sets the status, removes the body, and discards any headers
355
+ * that MUST NOT be included in 304 responses.
356
+ * @see https://tools.ietf.org/html/rfc2616#section-10.3.5
357
+ */
358
+ setNotModified(): this;
359
+ /**
360
+ * Add an array of headers to the response.
361
+ *
362
+ */
363
+ withHeaders(headers: any): this;
364
+ /**
365
+ * Set the exception to attach to the response.
366
+ */
367
+ withException(e: Error): this;
368
+ /**
369
+ * Throws the response in a HttpResponseException instance.
370
+ *
371
+ * @throws {HttpResponseException}
372
+ */
373
+ throwResponse(): void;
374
+ /**
375
+ * Is response invalid?
376
+ *
377
+ * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
378
+ */
379
+ isInvalid(): boolean;
380
+ /**
381
+ * Is response informative?
382
+ */
383
+ isInformational(): boolean;
384
+ /**
385
+ * Is response successful?
386
+ */
387
+ isSuccessful(): boolean;
388
+ /**
389
+ * Is the response a redirect?
390
+ */
391
+ isRedirection(): boolean;
392
+ /**
393
+ * Is there a client error?
394
+ */
395
+ isClientError(): boolean;
396
+ /**
397
+ * Was there a server side error?
398
+ */
399
+ isServerError(): boolean;
400
+ /**
401
+ * Is the response OK?
402
+ */
403
+ isOk(): boolean;
404
+ /**
405
+ * Is the response forbidden?
406
+ */
407
+ isForbidden(): boolean;
408
+ /**
409
+ * Is the response a not found error?
410
+ */
411
+ isNotFound(): boolean;
412
+ /**
413
+ * Is the response a redirect of some form?
414
+ */
415
+ isRedirect(location?: string | null): boolean;
416
+ /**
417
+ * Is the response empty?
418
+ */
419
+ isEmpty(): boolean;
420
+ /**
421
+ * Apply headers before sending response.
422
+ */
423
+ sendHeaders(statusCode?: number): this;
424
+ /**
425
+ * Prepares the Response before it is sent to the client.
426
+ *
427
+ * This method tweaks the Response to ensure that it is
428
+ * compliant with RFC 2616. Most of the changes are based on
429
+ * the Request that is "associated" with this Response.
430
+ **/
431
+ prepare(request: IRequest): this;
432
+ }
433
+ //#endregion
154
434
  //#region src/Contracts/IResponse.d.ts
155
435
  /**
156
436
  * Interface for the Response contract, defining methods for handling HTTP responses.
157
437
  */
158
- interface IResponse {
438
+ interface IResponse extends IHttpResponse {
159
439
  /**
160
440
  * The current app instance
161
441
  */
162
442
  app: IApplication;
163
443
  /**
164
- * Sets the HTTP status code for the response.
165
- * @param code - The HTTP status code.
166
- * @returns The instance for method chaining.
444
+ * Sends content for the current web response.
167
445
  */
168
- setStatusCode(code: number): this;
446
+ sendContent(type?: 'html' | 'json' | 'text' | 'xml', parse?: boolean): unknown;
169
447
  /**
170
- * Sets a response header.
171
- * @param name - The header name.
172
- * @param value - The header value.
173
- * @returns The instance for method chaining.
448
+ * Sends content for the current web response.
174
449
  */
175
- setHeader(name: string, value: string): this;
450
+ send(type?: 'html' | 'json' | 'text' | 'xml'): unknown;
176
451
  /**
177
- * Sends an HTML response.
178
- * @param content - The HTML content to send.
179
- * @returns The HTML content.
452
+ *
453
+ * @param content The content to serve
454
+ * @param send if set to true, the content will be returned, instead of the Response instance
455
+ * @returns
180
456
  */
181
- html(content: string): HTTPResponse;
457
+ html(content?: string): this;
458
+ html(content: string, parse: boolean): HTTPResponse;
182
459
  /**
183
- * Sends a JSON response.
184
- * @param data - The data to send as JSON.
185
- * @returns The input data.
460
+ * Send a JSON response.
186
461
  */
187
- json<T = unknown>(data: T): T;
462
+ json<T = unknown>(data?: T): this;
463
+ json<T = unknown>(data: T, parse: boolean): T;
188
464
  /**
189
- * Sends a plain text response.
190
- * @param data - The text content to send.
191
- * @returns The text content.
465
+ * Send plain text.
192
466
  */
193
- text(data: string): string;
467
+ text(content?: string): this;
468
+ text(content: string, parse: boolean): HTTPResponse;
194
469
  /**
195
- * Redirects to another URL.
196
- * @param url - The URL to redirect to.
197
- * @param status - The HTTP status code for the redirect (default: 302).
198
- * @returns The redirect URL.
470
+ * Send plain xml.
199
471
  */
200
- redirect(url: string, status?: number): HTTPResponse;
472
+ xml(data?: string): this;
473
+ xml(data: string, parse: boolean): HTTPResponse;
201
474
  /**
202
- * Gets the underlying event object or a specific property of it.
203
- * @param key - Optional key to access a nested property of the event.
204
- * @returns The entire event object or the value of the specified property.
475
+ * Redirect to another URL.
476
+ */
477
+ redirect(location: string, status?: number, statusText?: string | undefined): HTTPResponse;
478
+ /**
479
+ * Dump the response.
480
+ */
481
+ dump(): this;
482
+ /**
483
+ * Get the base event
205
484
  */
206
485
  getEvent(): H3Event;
207
- getEvent<K extends DotNestedKeys$1<H3Event>>(key: K): DotNestedValue$1<H3Event, K>;
486
+ getEvent<K$1 extends DotNestedKeys$1<H3Event>>(key: K$1): DotNestedValue$1<H3Event, K$1>;
208
487
  }
209
488
  //#endregion
210
489
  //#region src/Contracts/IHttp.d.ts
211
490
  type RouterEnd = 'get' | 'delete' | 'put' | 'post' | 'patch' | 'apiResource' | 'group' | 'route';
212
491
  type RequestMethod = 'HEAD' | 'GET' | 'PUT' | 'DELETE' | 'TRACE' | 'OPTIONS' | 'PURGE' | 'POST' | 'CONNECT' | 'PATCH';
213
492
  type RequestObject = Record<string, any>;
214
- type ExtractControllerMethods<T$1> = { [K in keyof T$1]: T$1[K] extends ((...args: any[]) => any) ? K : never }[keyof T$1];
493
+ type ResponseObject = Record<string, any>;
494
+ type ExtractControllerMethods<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? K : never }[keyof T];
215
495
  /**
216
496
  * Interface for the Router contract, defining methods for HTTP routing.
217
497
  */
@@ -538,7 +818,7 @@ declare class IRequest {
538
818
  * @param defaultValue
539
819
  * @returns
540
820
  */
541
- input<K extends string | undefined>(key?: K, defaultValue?: any): K extends undefined ? RequestObject$1 : any;
821
+ input<K$1 extends string | undefined>(key?: K$1, defaultValue?: any): K$1 extends undefined ? RequestObject$1 : any;
542
822
  /**
543
823
  * Retrieve a file from the request.
544
824
  *
@@ -552,7 +832,7 @@ declare class IRequest {
552
832
  * @param expectArray set to true to return an `UploadedFile[]` array.
553
833
  * @returns
554
834
  */
555
- file<K extends string | undefined = undefined, E extends boolean | undefined = undefined>(key?: K, defaultValue?: any, expectArray?: E): K extends undefined ? Record<string, E extends true ? IUploadedFile[] : IUploadedFile> : E extends true ? IUploadedFile[] : IUploadedFile;
835
+ file<K$1 extends string | undefined = undefined, E extends boolean | undefined = undefined>(key?: K$1, defaultValue?: any, expectArray?: E): K$1 extends undefined ? Record<string, E extends true ? IUploadedFile[] : IUploadedFile> : E extends true ? IUploadedFile[] : IUploadedFile;
556
836
  /**
557
837
  * Determine if the uploaded data contains a file.
558
838
  *
@@ -723,7 +1003,7 @@ declare class IRequest {
723
1003
  * @param defaultValue
724
1004
  * @return {InputBag}
725
1005
  */
726
- json<K extends string | undefined = undefined>(key?: string, defaultValue?: any): K extends undefined ? IParamBag : any;
1006
+ json<K$1 extends string | undefined = undefined>(key?: string, defaultValue?: any): K$1 extends undefined ? IParamBag : any;
727
1007
  /**
728
1008
  * Returns the request body content.
729
1009
  *
@@ -770,7 +1050,7 @@ declare class IRequest {
770
1050
  * Get the base event
771
1051
  */
772
1052
  getEvent(): H3Event;
773
- getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
1053
+ getEvent<K$1 extends DotNestedKeys<H3Event>>(key: K$1): DotNestedValue<H3Event, K$1>;
774
1054
  }
775
1055
  //#endregion
776
1056
  //#region src/Utils/PathLoader.d.ts
@@ -796,7 +1076,7 @@ declare class PathLoader {
796
1076
  }
797
1077
  //#endregion
798
1078
  //#region src/Contracts/BindingsContract.d.ts
799
- type RemoveIndexSignature<T$1> = { [K in keyof T$1 as string extends K ? never : number extends K ? never : K]: T$1[K] };
1079
+ type RemoveIndexSignature<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K] };
800
1080
  type Bindings = {
801
1081
  [key: string]: any;
802
1082
  [key: `app.${string}`]: any;
@@ -1109,6 +1389,13 @@ declare class Resolver {
1109
1389
  * @returns
1110
1390
  */
1111
1391
  static hashObjectOrFunction(provider: object | ((..._: any[]) => any)): string;
1392
+ /**
1393
+ * Checks if a function is asyncronous
1394
+ *
1395
+ * @param func
1396
+ * @returns
1397
+ */
1398
+ static isAsyncFunction(func: any): boolean;
1112
1399
  }
1113
1400
  //#endregion
1114
1401
  //#region src/Utils/scripts.d.ts
@@ -1158,4 +1445,4 @@ declare class TaskManager {
1158
1445
  static advancedTaskRunner<R = any>(info: [[string, string], [string, string]] | [[string, string]], task: (() => Promise<R>) | (() => R)): Promise<R | undefined>;
1159
1446
  }
1160
1447
  //#endregion
1161
- export { Bindings, Choice, type ChoiceOrSeparatorArray, Choices, DotFlatten, DotNestedKeys, DotNestedValue, EnvParser, EventHandler, ExtractControllerMethods, FileSystem, GenericWithNullableStringValues, HttpContext, IApplication, IContainer, IController, IMiddleware, IParamBag, IPathName, IRequest, IResponse, IRouter, ISeparator, IServiceProvider, IUploadedFile, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, PathLoader, Prompts, RequestMethod, RequestObject, Resolver, RouteDefinition, RouteEventHandler, RouteMethod, RouterEnd, TaskManager, UseKey, baseTsconfig, mainTsconfig, packageJsonScript };
1448
+ export { Bindings, Choice, type ChoiceOrSeparatorArray, Choices, DotFlatten, DotNestedKeys, DotNestedValue, EnvParser, EventHandler, ExtractControllerMethods, FileSystem, GenericWithNullableStringValues, HttpContext, IApplication, IContainer, IController, IHttpResponse, IMiddleware, IParamBag, IPathName, IRequest, IResponse, IRouter, ISeparator, IServiceProvider, IUploadedFile, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, PathLoader, Prompts, RequestMethod, RequestObject, Resolver, ResponseObject, RouteDefinition, RouteEventHandler, RouteMethod, RouterEnd, TaskManager, UseKey, baseTsconfig, mainTsconfig, packageJsonScript };
package/dist/index.js CHANGED
@@ -397,6 +397,16 @@ var Resolver = class {
397
397
  static hashObjectOrFunction(provider) {
398
398
  return crypto.createHash("sha1").update(provider.toString()).digest("hex");
399
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
+ }
400
410
  };
401
411
 
402
412
  //#endregion
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@h3ravel/shared",
3
- "version": "0.26.0",
3
+ "version": "0.26.1",
4
4
  "description": "Shared Utilities.",
5
5
  "type": "module",
6
- "main": "./dist/index.js",
6
+ "main": "./dist/index.cjs",
7
7
  "types": "./dist/index.d.ts",
8
8
  "module": "./dist/index.js",
9
9
  "exports": {
@@ -11,7 +11,7 @@
11
11
  "import": "./dist/index.js",
12
12
  "require": "./dist/index.cjs"
13
13
  },
14
- "./tsconfig.json": "./tsconfig.json"
14
+ "./*": "./*"
15
15
  },
16
16
  "typesVersions": {
17
17
  "*": {