@adviser/cement 0.4.0 → 0.4.2

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 (79) hide show
  1. package/cf/index.cjs.map +1 -1
  2. package/cf/index.js +2 -2
  3. package/{chunk-YVACAIUX.js → chunk-C5L2FW7O.js} +5 -4
  4. package/chunk-C5L2FW7O.js.map +1 -0
  5. package/{chunk-YKGCONBX.js → chunk-MBLJQD6G.js} +9 -2
  6. package/chunk-MBLJQD6G.js.map +1 -0
  7. package/{chunk-6F3ACVHD.js → chunk-S5OZRDIH.js} +6 -5
  8. package/chunk-S5OZRDIH.js.map +1 -0
  9. package/{chunk-X3IV2RYT.js → chunk-XJ3SFZPE.js} +2 -2
  10. package/deno/index.cjs.map +1 -1
  11. package/deno/index.js +2 -2
  12. package/index.cjs +100 -51
  13. package/index.cjs.map +1 -1
  14. package/index.d.cts +10 -1
  15. package/index.d.ts +10 -1
  16. package/index.js +44 -5
  17. package/index.js.map +1 -1
  18. package/metafile-cjs.json +1 -1
  19. package/metafile-esm.json +1 -1
  20. package/node/index.cjs.map +1 -1
  21. package/node/index.js +2 -2
  22. package/package.json +2 -2
  23. package/src/coerce-binary.ts +39 -0
  24. package/src/index.ts +2 -0
  25. package/src/is-promise.ts +15 -0
  26. package/src/jsr.json +1 -1
  27. package/src/logger-impl.ts +1 -1
  28. package/src/logger.ts +2 -1
  29. package/src/result.ts +3 -1
  30. package/src/tracer.ts +2 -1
  31. package/src/utils/stream-map.ts +3 -1
  32. package/test/index.cjs +55 -49
  33. package/test/index.cjs.map +1 -1
  34. package/test/index.js +3 -3
  35. package/ts/src/coerce-binary.d.ts +6 -0
  36. package/ts/src/coerce-binary.d.ts.map +1 -0
  37. package/ts/src/coerce-binary.js +32 -0
  38. package/ts/src/coerce-binary.js.map +1 -0
  39. package/ts/src/coerce-binary.test.d.ts +2 -0
  40. package/ts/src/coerce-binary.test.d.ts.map +1 -0
  41. package/ts/src/coerce-binary.test.js +39 -0
  42. package/ts/src/coerce-binary.test.js.map +1 -0
  43. package/ts/src/index.d.ts +2 -0
  44. package/ts/src/index.d.ts.map +1 -1
  45. package/ts/src/index.js +2 -0
  46. package/ts/src/index.js.map +1 -1
  47. package/ts/src/is-promise.d.ts +3 -0
  48. package/ts/src/is-promise.d.ts.map +1 -0
  49. package/ts/src/is-promise.js +10 -0
  50. package/ts/src/is-promise.js.map +1 -0
  51. package/ts/src/is-promise.test.d.ts +2 -0
  52. package/ts/src/is-promise.test.d.ts.map +1 -0
  53. package/ts/src/is-promise.test.js +48 -0
  54. package/ts/src/is-promise.test.js.map +1 -0
  55. package/ts/src/logger-impl.d.ts +1 -1
  56. package/ts/src/logger-impl.d.ts.map +1 -1
  57. package/ts/src/logger-impl.js +1 -1
  58. package/ts/src/logger-impl.js.map +1 -1
  59. package/ts/src/logger.d.ts.map +1 -1
  60. package/ts/src/logger.js +2 -1
  61. package/ts/src/logger.js.map +1 -1
  62. package/ts/src/result.d.ts.map +1 -1
  63. package/ts/src/result.js +2 -1
  64. package/ts/src/result.js.map +1 -1
  65. package/ts/src/tracer.d.ts.map +1 -1
  66. package/ts/src/tracer.js +2 -1
  67. package/ts/src/tracer.js.map +1 -1
  68. package/ts/src/utils/stream-map.d.ts.map +1 -1
  69. package/ts/src/utils/stream-map.js +2 -1
  70. package/ts/src/utils/stream-map.js.map +1 -1
  71. package/utils/index.cjs +7 -1
  72. package/utils/index.cjs.map +1 -1
  73. package/utils/index.js +2 -2
  74. package/web/index.cjs.map +1 -1
  75. package/web/index.js +2 -2
  76. package/chunk-6F3ACVHD.js.map +0 -1
  77. package/chunk-YKGCONBX.js.map +0 -1
  78. package/chunk-YVACAIUX.js.map +0 -1
  79. /package/{chunk-X3IV2RYT.js.map → chunk-XJ3SFZPE.js.map} +0 -0
@@ -1,3 +1,5 @@
1
+ import { isPromise } from "../is-promise.js";
2
+
1
3
  export interface StreamMap<T, U> {
2
4
  Map(s: T, idx: number): U | Promise<U>;
3
5
  readonly Close?: () => void;
@@ -16,7 +18,7 @@ export function streamMap<T, U>(s: ReadableStream<T>, sm: StreamMap<T, U>): Read
16
18
  }
17
19
  const promiseOrU = state.streamMap.Map(value, state.idx++);
18
20
  let mapped: U;
19
- if (promiseOrU instanceof Promise || typeof (promiseOrU as { then: () => void }).then === "function") {
21
+ if (isPromise(promiseOrU)) {
20
22
  mapped = await promiseOrU;
21
23
  } else {
22
24
  mapped = promiseOrU;
package/test/index.cjs CHANGED
@@ -193,6 +193,12 @@ var LRUMap = class {
193
193
  // }
194
194
  };
195
195
 
196
+ // src/is-promise.ts
197
+ function isPromise(a) {
198
+ const mayBe = a;
199
+ return mayBe instanceof Promise || !!(mayBe && mayBe !== null && typeof mayBe.then === "function" && typeof mayBe.catch === "function" && typeof mayBe.finally === "function");
200
+ }
201
+
196
202
  // src/result.ts
197
203
  var Result = class _Result {
198
204
  static Ok(t) {
@@ -275,7 +281,7 @@ var ResultError = class extends Result {
275
281
  function exception2Result(fn) {
276
282
  try {
277
283
  const res = fn();
278
- if (res instanceof Promise) {
284
+ if (isPromise(res)) {
279
285
  return res.then((value) => Result.Ok(value)).catch((e) => Result.Err(e));
280
286
  }
281
287
  return Result.Ok(res);
@@ -710,7 +716,7 @@ function logValueInternal(val, ctx) {
710
716
  if (val instanceof ReadableStream) {
711
717
  return new LogValue(() => ">Stream<");
712
718
  }
713
- if (val instanceof Promise) {
719
+ if (isPromise(val)) {
714
720
  return new LogValue(() => ">Promise<");
715
721
  }
716
722
  if ((_a = ctx.state) == null ? void 0 : _a.has(val)) {
@@ -1594,53 +1600,6 @@ var URI = class _URI {
1594
1600
  }
1595
1601
  };
1596
1602
 
1597
- // src/log-writer-impl.ts
1598
- var LogWriterStream = class {
1599
- constructor(out) {
1600
- this._toFlush = [];
1601
- this._flushIsRunning = false;
1602
- this._flushDoneFns = [];
1603
- this._out = out;
1604
- this._id = Math.random();
1605
- }
1606
- write(encoded) {
1607
- const my = async () => {
1608
- try {
1609
- const writer = this._out.getWriter();
1610
- await writer.ready;
1611
- await writer.write(encoded);
1612
- writer.releaseLock();
1613
- } catch (err) {
1614
- console.error("Chunk error:", err);
1615
- }
1616
- };
1617
- this._toFlush.push(my);
1618
- this._flush();
1619
- }
1620
- _flush(toFlush = void 0, done) {
1621
- if (done) {
1622
- this._flushDoneFns.push(done);
1623
- }
1624
- if (this._toFlush.length == 0) {
1625
- this._flushIsRunning = false;
1626
- this._flushDoneFns.forEach((fn) => fn());
1627
- this._flushDoneFns = [];
1628
- return;
1629
- }
1630
- if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {
1631
- this._flushIsRunning = true;
1632
- } else if (!toFlush) {
1633
- return;
1634
- }
1635
- const my = this._toFlush.shift();
1636
- my == null ? void 0 : my().catch((e) => {
1637
- console.error("Flush error:", e);
1638
- }).finally(() => {
1639
- this._flush(this._toFlush);
1640
- });
1641
- }
1642
- };
1643
-
1644
1603
  // src/runtime.ts
1645
1604
  function isSet(value, ref = globalThis) {
1646
1605
  const [head, ...tail] = value.split(".");
@@ -2414,6 +2373,53 @@ var WrapperBasicSysAbstraction = class {
2414
2373
  // }
2415
2374
  };
2416
2375
 
2376
+ // src/log-writer-impl.ts
2377
+ var LogWriterStream = class {
2378
+ constructor(out) {
2379
+ this._toFlush = [];
2380
+ this._flushIsRunning = false;
2381
+ this._flushDoneFns = [];
2382
+ this._out = out;
2383
+ this._id = Math.random();
2384
+ }
2385
+ write(encoded) {
2386
+ const my = async () => {
2387
+ try {
2388
+ const writer = this._out.getWriter();
2389
+ await writer.ready;
2390
+ await writer.write(encoded);
2391
+ writer.releaseLock();
2392
+ } catch (err) {
2393
+ console.error("Chunk error:", err);
2394
+ }
2395
+ };
2396
+ this._toFlush.push(my);
2397
+ this._flush();
2398
+ }
2399
+ _flush(toFlush = void 0, done) {
2400
+ if (done) {
2401
+ this._flushDoneFns.push(done);
2402
+ }
2403
+ if (this._toFlush.length == 0) {
2404
+ this._flushIsRunning = false;
2405
+ this._flushDoneFns.forEach((fn) => fn());
2406
+ this._flushDoneFns = [];
2407
+ return;
2408
+ }
2409
+ if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {
2410
+ this._flushIsRunning = true;
2411
+ } else if (!toFlush) {
2412
+ return;
2413
+ }
2414
+ const my = this._toFlush.shift();
2415
+ my == null ? void 0 : my().catch((e) => {
2416
+ console.error("Flush error:", e);
2417
+ }).finally(() => {
2418
+ this._flush(this._toFlush);
2419
+ });
2420
+ }
2421
+ };
2422
+
2417
2423
  // src/logger-impl.ts
2418
2424
  function getLen(value, lvs) {
2419
2425
  if (Array.isArray(value)) {