@aliexme/js-utils 0.3.1 → 0.4.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 @@
1
+ export declare const asyncResult: <R>(fn: () => R) => Promise<R>;
@@ -0,0 +1,6 @@
1
+ import { asyncify } from './asyncify';
2
+ export const asyncResult = (fn) => {
3
+ const asyncFn = asyncify(fn);
4
+ return asyncFn();
5
+ };
6
+ //# sourceMappingURL=asyncResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncResult.js","sourceRoot":"","sources":["../src/async/asyncResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAI,EAAW,EAAc,EAAE;IACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC5B,OAAO,OAAO,EAAE,CAAA;AAClB,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const asyncify: <A extends unknown[], R>(fn: (...args: A) => R) => (...args: A) => Promise<R>;
@@ -0,0 +1,8 @@
1
+ export const asyncify = (fn) => {
2
+ return (...args) => {
3
+ return new Promise((resolve) => {
4
+ setTimeout(() => resolve(fn(...args)), 0);
5
+ });
6
+ };
7
+ };
8
+ //# sourceMappingURL=asyncify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncify.js","sourceRoot":"","sources":["../src/async/asyncify.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAyB,EAAqB,EAA8B,EAAE;IACpG,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE;QACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAC3C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './asyncify';
2
+ export * from './asyncResult';
package/async/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './asyncify';
2
+ export * from './asyncResult';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/async/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA"}
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './array';
2
2
  export * from './object';
3
3
  export * from './function';
4
+ export * from './async';
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './array';
2
2
  export * from './object';
3
3
  export * from './function';
4
+ export * from './async';
4
5
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliexme/js-utils",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Common JavaScript utilities",
5
5
  "private": false,
6
6
  "author": "Alexander Smirnov <al.smirnov996@gmail.com>",