@axman/res 0.0.6 → 0.0.7

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/all.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { Res } from './res';
2
+ export declare function all<T extends readonly Res<unknown>[] | []>(results: T): Res<{
3
+ [K in keyof T]: T[K] extends Res<infer U> ? U : never;
4
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ export * from './all';
1
2
  export * from './match';
2
3
  export * from './res';
3
4
  export * from './unwrap';
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(n,r){const[t,c]=n;return c!==null?r.err(c):r.ok(t)}function o(n){return[n,null]}function e(n){return[null,n]}function i(n){return u(n,{ok:r=>r,err:r=>{throw r}})}function l(n){try{const r=n();return r instanceof Promise?r.then(t=>o(t)).catch(t=>t instanceof Error?e(t):e(new Error(String(t)))):o(r)}catch(r){return r instanceof Error?e(r):e(new Error(String(r)))}}const a=Object.freeze(Object.defineProperty({__proto__:null,err:e,match:u,ok:o,unwrap:i,wrap:l},Symbol.toStringTag,{value:"Module"}));exports.err=e;exports.match=u;exports.ok=o;exports.res=a;exports.unwrap=i;exports.wrap=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(n){return[n,null]}function e(n){return[null,n]}function i(n){const r=[];for(const t of n){const[u,c]=t;if(c!==null)return[null,c];r.push(u)}return o(r)}function l(n,r){const[t,u]=n;return u!==null?r.err(u):r.ok(t)}function a(n){return l(n,{ok:r=>r,err:r=>{throw r}})}function f(n){try{const r=n();return r instanceof Promise?r.then(t=>o(t)).catch(t=>t instanceof Error?e(t):e(new Error(String(t)))):o(r)}catch(r){return r instanceof Error?e(r):e(new Error(String(r)))}}const s=Object.freeze(Object.defineProperty({__proto__:null,all:i,err:e,match:l,ok:o,unwrap:a,wrap:f},Symbol.toStringTag,{value:"Module"}));exports.all=i;exports.err=e;exports.match=l;exports.ok=o;exports.res=s;exports.unwrap=a;exports.wrap=f;
package/dist/index.es.js CHANGED
@@ -1,42 +1,54 @@
1
- function c(n, r) {
2
- const [t, u] = n;
3
- return u !== null ? r.err(u) : r.ok(t);
4
- }
5
- function o(n) {
1
+ function u(n) {
6
2
  return [n, null];
7
3
  }
8
4
  function e(n) {
9
5
  return [null, n];
10
6
  }
11
7
  function i(n) {
12
- return c(n, {
8
+ const r = [];
9
+ for (const t of n) {
10
+ const [o, c] = t;
11
+ if (c !== null)
12
+ return [null, c];
13
+ r.push(o);
14
+ }
15
+ return u(r);
16
+ }
17
+ function l(n, r) {
18
+ const [t, o] = n;
19
+ return o !== null ? r.err(o) : r.ok(t);
20
+ }
21
+ function f(n) {
22
+ return l(n, {
13
23
  ok: (r) => r,
14
24
  err: (r) => {
15
25
  throw r;
16
26
  }
17
27
  });
18
28
  }
19
- function f(n) {
29
+ function s(n) {
20
30
  try {
21
31
  const r = n();
22
- return r instanceof Promise ? r.then((t) => o(t)).catch((t) => t instanceof Error ? e(t) : e(new Error(String(t)))) : o(r);
32
+ return r instanceof Promise ? r.then((t) => u(t)).catch((t) => t instanceof Error ? e(t) : e(new Error(String(t)))) : u(r);
23
33
  } catch (r) {
24
34
  return r instanceof Error ? e(r) : e(new Error(String(r)));
25
35
  }
26
36
  }
27
- const l = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
37
+ const a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
28
38
  __proto__: null,
39
+ all: i,
29
40
  err: e,
30
- match: c,
31
- ok: o,
32
- unwrap: i,
33
- wrap: f
41
+ match: l,
42
+ ok: u,
43
+ unwrap: f,
44
+ wrap: s
34
45
  }, Symbol.toStringTag, { value: "Module" }));
35
46
  export {
47
+ i as all,
36
48
  e as err,
37
- c as match,
38
- o as ok,
39
- l as res,
40
- i as unwrap,
41
- f as wrap
49
+ l as match,
50
+ u as ok,
51
+ a as res,
52
+ f as unwrap,
53
+ s as wrap
42
54
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@axman/res",
3
3
  "author": "akhmanov",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "description": "Go style Result for TypeScript",
6
6
  "license": "MIT",
7
7
  "private": false,