@cripty2001/utils 0.0.53 → 0.0.54

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.d.ts CHANGED
@@ -85,3 +85,4 @@ export declare function randBetween(min: number, max: number): number;
85
85
  export declare function getEnv(key: string, defaultValue?: string): string;
86
86
  export declare const CURRENT_TS_MS: Whispr<number>;
87
87
  export declare function timediff2HumanReadable(diffMs: number): string;
88
+ export declare function fn2promise<T>(fn: () => T | Promise<T>): Promise<T>;
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ exports.parseQuery = parseQuery;
16
16
  exports.randBetween = randBetween;
17
17
  exports.getEnv = getEnv;
18
18
  exports.timediff2HumanReadable = timediff2HumanReadable;
19
+ exports.fn2promise = fn2promise;
19
20
  const whispr_1 = require("@cripty2001/whispr");
20
21
  const lodash_1 = require("lodash");
21
22
  /**
@@ -233,3 +234,9 @@ function timediff2HumanReadable(diffMs) {
233
234
  const rtf = new Intl.RelativeTimeFormat();
234
235
  return rtf.format(Math.round(diff), unit);
235
236
  }
237
+ function fn2promise(fn) {
238
+ const result = fn();
239
+ return result instanceof Promise ?
240
+ result :
241
+ Promise.resolve(result);
242
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.53",
3
+ "version": "0.0.54",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {