klubok 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/dist/index.js +7 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mut = exports.eff = exports.pure = void 0;
4
4
  exports.klubok = klubok;
5
+ const node_util_1 = require("node:util");
5
6
  const pure = (key, fn) => Object.assign(fn, { key, mutable: false });
6
7
  exports.pure = pure;
7
8
  const eff = (key, fn) => Object.assign(fn, { key, mutable: false });
@@ -17,10 +18,10 @@ function klubok(...fns) {
17
18
  return await Promise.resolve(fn(ctx)).then(resp => ({ ...ctx, [fn.key]: resp }));
18
19
  }
19
20
  catch (error) {
20
- throw {
21
+ throw (0, node_util_1.inspect)({
21
22
  error: error.stack ?? error.message ?? error,
22
- ctx
23
- };
23
+ ctx,
24
+ }, { depth: 3 });
24
25
  }
25
26
  })())
26
27
  : (acc, fn) => acc.then(ctx => !fn.mutable && Reflect.has(ctx, fn.key) && !Reflect.has(mock ?? {}, fn.key)
@@ -35,10 +36,10 @@ function klubok(...fns) {
35
36
  : fn(ctx)).then(resp => ({ ...ctx, [fn.key]: resp }));
36
37
  }
37
38
  catch (error) {
38
- throw {
39
+ throw (0, node_util_1.inspect)({
39
40
  error: error.stack ?? error.message ?? error,
40
- ctx
41
- };
41
+ ctx,
42
+ }, { depth: 3 });
42
43
  }
43
44
  })()), Promise.resolve({ ...rootCtx, ...mock }));
44
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "klubok",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Do notation pipes for Promise-based or pure functions which easy to mock",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",