@idlebox/common 1.5.3 → 1.5.5

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 (119) hide show
  1. package/lib/array/diff.d.ts.map +1 -1
  2. package/lib/array/diff.js +1 -0
  3. package/lib/array/diff.js.map +1 -1
  4. package/lib/autoindex.d.ts +13 -2
  5. package/lib/autoindex.d.ts.map +1 -1
  6. package/lib/autoindex.js +14 -4
  7. package/lib/autoindex.js.map +1 -1
  8. package/lib/date/to-string.js +3 -3
  9. package/lib/date/to-string.js.map +1 -1
  10. package/lib/debugging/inspect.d.ts.map +1 -1
  11. package/lib/debugging/inspect.js +8 -2
  12. package/lib/debugging/inspect.js.map +1 -1
  13. package/lib/debugging/object-with-name.js +1 -1
  14. package/lib/debugging/object-with-name.js.map +1 -1
  15. package/lib/debugging/serializable.d.ts.map +1 -1
  16. package/lib/debugging/serializable.js +7 -1
  17. package/lib/debugging/serializable.js.map +1 -1
  18. package/lib/error/pretty.nodejs.d.ts.map +1 -1
  19. package/lib/error/pretty.nodejs.js +7 -5
  20. package/lib/error/pretty.nodejs.js.map +1 -1
  21. package/lib/function/callback-list.async.d.ts.map +1 -1
  22. package/lib/function/callback-list.async.js +1 -0
  23. package/lib/function/callback-list.async.js.map +1 -1
  24. package/lib/function/callback-list.d.ts.map +1 -1
  25. package/lib/function/callback-list.js +1 -0
  26. package/lib/function/callback-list.js.map +1 -1
  27. package/lib/iterate/merge-iterable.d.ts +9 -0
  28. package/lib/iterate/merge-iterable.d.ts.map +1 -0
  29. package/lib/iterate/merge-iterable.js +51 -0
  30. package/lib/iterate/merge-iterable.js.map +1 -0
  31. package/lib/lifecycle/dispose/disposedError.d.ts.map +1 -1
  32. package/lib/lifecycle/dispose/disposedError.js +1 -1
  33. package/lib/lifecycle/dispose/disposedError.js.map +1 -1
  34. package/lib/map-and-set/required-map.d.ts.map +1 -1
  35. package/lib/map-and-set/required-map.js +4 -0
  36. package/lib/map-and-set/required-map.js.map +1 -1
  37. package/lib/misc/assertNotNull.d.ts +1 -7
  38. package/lib/misc/assertNotNull.d.ts.map +1 -1
  39. package/lib/misc/assertNotNull.js +4 -11
  40. package/lib/misc/assertNotNull.js.map +1 -1
  41. package/lib/object/objectPath.d.ts.map +1 -1
  42. package/lib/object/objectPath.js +6 -1
  43. package/lib/object/objectPath.js.map +1 -1
  44. package/lib/path/isAbsolute.d.ts.map +1 -1
  45. package/lib/path/isAbsolute.js +2 -1
  46. package/lib/path/isAbsolute.js.map +1 -1
  47. package/lib/path/normalizePath.d.ts.map +1 -1
  48. package/lib/path/normalizePath.js +6 -4
  49. package/lib/path/normalizePath.js.map +1 -1
  50. package/lib/platform/compile.d.ts +0 -5
  51. package/lib/platform/compile.d.ts.map +1 -1
  52. package/lib/platform/compile.js +1 -0
  53. package/lib/platform/compile.js.map +1 -1
  54. package/lib/platform/globalSingleton.d.ts +0 -1
  55. package/lib/platform/globalSingleton.d.ts.map +1 -1
  56. package/lib/platform/globalSingleton.js +0 -1
  57. package/lib/platform/globalSingleton.js.map +1 -1
  58. package/lib/platform/globalSymbol.d.ts.map +1 -1
  59. package/lib/platform/globalSymbol.js +3 -2
  60. package/lib/platform/globalSymbol.js.map +1 -1
  61. package/lib/promise/deferred-promise.d.ts.map +1 -1
  62. package/lib/reflection/classes/singleton.js +1 -1
  63. package/lib/reflection/classes/singleton.js.map +1 -1
  64. package/lib/reflection/methods/bind.js +1 -1
  65. package/lib/reflection/methods/bind.js.map +1 -1
  66. package/lib/reflection/methods/memorize.d.ts.map +1 -1
  67. package/lib/reflection/methods/memorize.js +2 -1
  68. package/lib/reflection/methods/memorize.js.map +1 -1
  69. package/lib/schedule/interval.js +1 -1
  70. package/lib/schedule/interval.js.map +1 -1
  71. package/lib/schedule/timeout.d.ts +1 -1
  72. package/lib/schedule/timeout.d.ts.map +1 -1
  73. package/lib/schedule/timeout.js +5 -5
  74. package/lib/schedule/timeout.js.map +1 -1
  75. package/lib/state/simple-state-machine.d.ts +3 -3
  76. package/lib/state/simple-state-machine.d.ts.map +1 -1
  77. package/lib/state/simple-state-machine.js +2 -0
  78. package/lib/state/simple-state-machine.js.map +1 -1
  79. package/lib/string/concatType.generated.d.ts.map +1 -1
  80. package/lib/string/concatType.generated.js +3 -11
  81. package/lib/string/concatType.generated.js.map +1 -1
  82. package/lib/typing-helper/deep.partial.d.ts.map +1 -1
  83. package/lib/typing-helper/deep.readonly.d.ts.map +1 -1
  84. package/lib/typing-helper/deep.required.d.ts +1 -1
  85. package/lib/typing-helper/deep.required.d.ts.map +1 -1
  86. package/lib/typing-helper/deep.writable.d.ts.map +1 -1
  87. package/package.json +4 -4
  88. package/src/array/diff.ts +1 -0
  89. package/src/autoindex.ts +20 -4
  90. package/src/date/to-string.ts +3 -3
  91. package/src/debugging/inspect.ts +8 -2
  92. package/src/debugging/object-with-name.ts +1 -1
  93. package/src/debugging/serializable.ts +9 -1
  94. package/src/error/pretty.nodejs.ts +12 -6
  95. package/src/function/callback-list.async.ts +1 -0
  96. package/src/function/callback-list.ts +1 -0
  97. package/src/iterate/merge-iterable.ts +59 -0
  98. package/src/lifecycle/dispose/disposedError.ts +1 -1
  99. package/src/map-and-set/required-map.ts +4 -0
  100. package/src/misc/assertNotNull.ts +5 -14
  101. package/src/object/objectPath.ts +6 -1
  102. package/src/path/isAbsolute.ts +2 -1
  103. package/src/path/normalizePath.ts +7 -4
  104. package/src/platform/compile.ts +2 -5
  105. package/src/platform/globalSingleton.ts +0 -2
  106. package/src/platform/globalSymbol.ts +5 -4
  107. package/src/promise/deferred-promise.ts +1 -1
  108. package/src/reflection/classes/singleton.ts +1 -1
  109. package/src/reflection/methods/bind.ts +1 -1
  110. package/src/reflection/methods/memorize.ts +2 -1
  111. package/src/schedule/interval.ts +1 -1
  112. package/src/schedule/timeout.ts +5 -5
  113. package/src/state/simple-state-machine.ts +5 -4
  114. package/src/string/concatType.generated.ts +4 -3
  115. package/src/typing-helper/deep.partial.ts +9 -1
  116. package/src/typing-helper/deep.readonly.ts +9 -1
  117. package/src/typing-helper/deep.required.ts +2 -2
  118. package/src/typing-helper/deep.writable.ts +9 -1
  119. package/src/global.d.ts +0 -12
@@ -1 +1 @@
1
- {"version":3,"file":"concatType.generated.js","sourceRoot":"","sources":["../../src/string/concatType.generated.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,aAAa;AACb,wBAAwB;AACxB,0BAA0B;AAC1B,0BAA0B;AAC1B;;;;;;;gFAOgF;AAmFhF,MAAM,UAAU,gBAAgB,CAAC,CAAW;IAC3C,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACnB,CAAC"}
1
+ {"version":3,"file":"concatType.generated.js","sourceRoot":"","sources":["../../src/string/concatType.generated.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,0CAA0C;AAC1C,0CAA0C;AAC1C,oBAAoB;AACpB,aAAa;AA4Fb,MAAM,UAAU,gBAAgB,CAAC,CAAW;IAC3C,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"deep.partial.d.ts","sourceRoot":"","sources":["../../src/typing-helper/deep.partial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,CAAC,GAAG,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAE3P,KAAK,gBAAgB,CAAC,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,KAAK,cAAc,CAAC,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,KAAK,iBAAiB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC"}
1
+ {"version":3,"file":"deep.partial.d.ts","sourceRoot":"","sources":["../../src/typing-helper/deep.partial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAC7C,CAAC,GACD,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAC/B,gBAAgB,CAAC,CAAC,CAAC,GACnB,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GACtC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GACpB,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAC7B,cAAc,CAAC,CAAC,CAAC,GACjB,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAE3B,KAAK,gBAAgB,CAAC,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,KAAK,cAAc,CAAC,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,KAAK,iBAAiB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"deep.readonly.d.ts","sourceRoot":"","sources":["../../src/typing-helper/deep.readonly.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,CAAC,GAAG,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAExO,KAAK,iBAAiB,CAAC,CAAC,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3E,KAAK,eAAe,CAAC,CAAC,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,KAAK,kBAAkB,CAAC,CAAC,IAAI;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC"}
1
+ {"version":3,"file":"deep.readonly.d.ts","sourceRoot":"","sources":["../../src/typing-helper/deep.readonly.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAC9C,CAAC,GACD,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACvB,iBAAiB,CAAC,CAAC,CAAC,GACpB,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC9B,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GACrB,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GACrB,eAAe,CAAC,CAAC,CAAC,GAClB,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAE5B,KAAK,iBAAiB,CAAC,CAAC,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3E,KAAK,eAAe,CAAC,CAAC,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,KAAK,kBAAkB,CAAC,CAAC,IAAI;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { Primitive } from './literal.js';
2
- export type DeepNonNullable<T> = T extends Primitive ? T : T extends ReadonlyArray<infer U> | Array<infer U> ? DeepNonNullableArray<U> : T extends ReadonlyMap<infer K, infer V> | Map<infer K, infer V> ? DeepNonNullableMap<K, V> : T extends ReadonlySet<infer M> ? DeepNonNullableSet<M> : DeepNonNullableObject<T>;
2
+ export type DeepNonNullable<T> = T extends Primitive ? T : T extends ReadonlyArray<infer U> ? DeepNonNullableArray<U> : T extends ReadonlyMap<infer K, infer V> ? DeepNonNullableMap<K, V> : T extends ReadonlySet<infer M> ? DeepNonNullableSet<M> : DeepNonNullableObject<T>;
3
3
  type DeepNonNullableArray<T> = Array<DeepNonNullable<T>>;
4
4
  type DeepNonNullableMap<K, V> = Map<DeepNonNullable<K>, DeepNonNullable<V>>;
5
5
  type DeepNonNullableSet<T> = Set<DeepNonNullable<T>>;
@@ -1 +1 @@
1
- {"version":3,"file":"deep.required.d.ts","sourceRoot":"","sources":["../../src/typing-helper/deep.required.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GACjD,CAAC,GACD,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAChD,oBAAoB,CAAC,CAAC,CAAC,GACvB,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC9D,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,GACxB,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAC7B,kBAAkB,CAAC,CAAC,CAAC,GACrB,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAE/B,KAAK,oBAAoB,CAAC,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AACzD,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5E,KAAK,kBAAkB,CAAC,CAAC,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,KAAK,qBAAqB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC"}
1
+ {"version":3,"file":"deep.required.d.ts","sourceRoot":"","sources":["../../src/typing-helper/deep.required.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GACjD,CAAC,GACD,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAC/B,oBAAoB,CAAC,CAAC,CAAC,GACvB,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GACtC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,GACxB,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAC7B,kBAAkB,CAAC,CAAC,CAAC,GACrB,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAE/B,KAAK,oBAAoB,CAAC,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AACzD,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5E,KAAK,kBAAkB,CAAC,CAAC,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,KAAK,qBAAqB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"deep.writable.d.ts","sourceRoot":"","sources":["../../src/typing-helper/deep.writable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,CAAC,GAAG,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAErQ,KAAK,kBAAkB,CAAC,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,KAAK,gBAAgB,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACtE,KAAK,gBAAgB,CAAC,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,KAAK,mBAAmB,CAAC,CAAC,IAAI;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC"}
1
+ {"version":3,"file":"deep.writable.d.ts","sourceRoot":"","sources":["../../src/typing-helper/deep.writable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAC/C,CAAC,GACD,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAC/B,kBAAkB,CAAC,CAAC,CAAC,GACrB,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GACtC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GACtB,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAC7B,gBAAgB,CAAC,CAAC,CAAC,GACnB,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAE7B,KAAK,kBAAkB,CAAC,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,KAAK,gBAAgB,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACtE,KAAK,gBAAgB,CAAC,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,KAAK,mBAAmB,CAAC,CAAC,IAAI;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idlebox/common",
3
3
  "type": "module",
4
- "version": "1.5.3",
4
+ "version": "1.5.5",
5
5
  "description": "Common utilities",
6
6
  "keywords": [
7
7
  "utilities",
@@ -19,11 +19,11 @@
19
19
  "sideEffects": false,
20
20
  "devDependencies": {
21
21
  "@types/debug": "^4.1.12",
22
- "@build-script/autoindex": "^0.0.10",
23
- "@build-script/codegen": "^1.0.10",
24
22
  "@build-script/single-dog-asset": "latest",
23
+ "@build-script/autoindex": "^0.0.11",
25
24
  "@idlebox/itypes": "^1.0.14",
26
- "@mpis/publisher": "^0.0.10",
25
+ "@build-script/codegen": "^1.0.11",
26
+ "@mpis/publisher": "^0.0.11",
27
27
  "@mpis/run": "^0.0.14"
28
28
  },
29
29
  "dependencies": {
package/src/array/diff.ts CHANGED
@@ -17,6 +17,7 @@ export function arrayDiff<T>(_before: readonly T[], after: readonly T[]) {
17
17
  const del: T[] = [];
18
18
  const same: T[] = [];
19
19
  next: while (before.length) {
20
+ // biome-ignore lint/style/noNonNullAssertion: ?
20
21
  const item = before.pop()!;
21
22
  for (let j = add.length - 1; j >= 0; j--) {
22
23
  if (item === add[j]) {
package/src/autoindex.ts CHANGED
@@ -1,6 +1,17 @@
1
- // DO NOT EDIT THIS FILE
2
- // @ts-ignore
1
+ /******************************************************************************
2
+ * GENERATED FILE, DO NOT MODIFY
3
+ * 这是生成的文件,千万不要修改
4
+ *
5
+ * @build-script/autoindex - Automatic TypeScript index file generator
6
+ * https://github.com/GongT/baobao
7
+ *
8
+ ******************************************************************************/
9
+
10
+ // biome-ignore-all lint: generated file
11
+ // biome-ignore-all assist: generated file
12
+ // biome-ignore-all syntax: generated file
3
13
  /* eslint-disable */
14
+ // @ts-ignore
4
15
 
5
16
  /* array/diff.ts */
6
17
  // Identifiers
@@ -110,6 +121,12 @@
110
121
  /* function/noop.ts */
111
122
  // Identifiers
112
123
  export { noop } from "./function/noop.js";
124
+ /* iterate/merge-iterable.ts */
125
+ // Identifiers
126
+ export { mergeIterables } from "./iterate/merge-iterable.js";
127
+ export { joinAsyncIterables } from "./iterate/merge-iterable.js";
128
+ export { interleaveIterables } from "./iterate/merge-iterable.js";
129
+ export { interleaveAsyncIterables } from "./iterate/merge-iterable.js";
113
130
  /* legacy/rename.ts */
114
131
  // Identifiers
115
132
  export { toDisposable } from "./legacy/rename.js";
@@ -199,7 +216,6 @@
199
216
  /* misc/assertNotNull.ts */
200
217
  // Identifiers
201
218
  export { assertNotNull } from "./misc/assertNotNull.js";
202
- export { throwNull } from "./misc/assertNotNull.js";
203
219
  /* misc/package.json.ts */
204
220
  // Identifiers
205
221
  export type { IExportCondition } from "./misc/package.json.js";
@@ -336,7 +352,7 @@
336
352
  export { raceTimeout } from "./schedule/timeout.js";
337
353
  /* state/simple-state-machine.ts */
338
354
  // Identifiers
339
- export type { IFsmRuleMap } from "./state/simple-state-machine.js";
355
+ export type { ISsmRuleMap } from "./state/simple-state-machine.js";
340
356
  export type { IStateChangeEvent } from "./state/simple-state-machine.js";
341
357
  export { SimpleStateMachine } from "./state/simple-state-machine.js";
342
358
  /* string/case-cast.ts */
@@ -7,7 +7,7 @@ export namespace humanDate {
7
7
  */
8
8
  export function time(date: Date | string | number) {
9
9
  if (typeof date === 'string') {
10
- date = Number.parseInt(date);
10
+ date = Number.parseInt(date, 10);
11
11
  }
12
12
  date = new Date(date as number);
13
13
  return `${pad2(date.getHours())}:${pad2(date.getMinutes())}:${pad2(date.getSeconds())}`;
@@ -20,7 +20,7 @@ export namespace humanDate {
20
20
  */
21
21
  export function date(date: Date | string | number, sp = '-') {
22
22
  if (typeof date === 'string') {
23
- date = Number.parseInt(date);
23
+ date = Number.parseInt(date, 10);
24
24
  }
25
25
  date = new Date(date as number);
26
26
  return `${date.getFullYear()}${sp}${pad2(date.getMonth() + 1)}${sp}${pad2(date.getDate())}`;
@@ -31,7 +31,7 @@ export namespace humanDate {
31
31
  */
32
32
  export function datetime(date: Date | string | number) {
33
33
  if (typeof date === 'string') {
34
- date = Number.parseInt(date);
34
+ date = Number.parseInt(date, 10);
35
35
  }
36
36
  date = new Date(date as number);
37
37
  return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${pad2(date.getHours())}:${pad2(date.getMinutes())}:${pad2(date.getSeconds())}`;
@@ -15,8 +15,14 @@ export function tryInspect(object: any): string {
15
15
  if (object.inspect) {
16
16
  return object.inspect();
17
17
  }
18
- if (object[Symbol.toStringTag]) {
19
- return object[Symbol.toStringTag]();
18
+
19
+ const tst = object[Symbol.toStringTag];
20
+ if (tst) {
21
+ if (typeof tst === 'string') {
22
+ return tst;
23
+ } else if (typeof tst === 'function') {
24
+ return tst.call(object);
25
+ }
20
26
  }
21
27
  if (object.toJSON) {
22
28
  return object.toJSON();
@@ -1,4 +1,4 @@
1
- import { definePrivateConstant } from '../autoindex.js';
1
+ import { definePrivateConstant } from '../object/definePublicConstant.js';
2
2
 
3
3
  export interface NamedObject {
4
4
  displayName: string;
@@ -48,7 +48,15 @@ export function isSerializable(value: any): SerializableKind {
48
48
  if ('toJSON' in value || Symbol.toPrimitive in value) {
49
49
  return SerializableKind.Manual;
50
50
  }
51
- if (value instanceof Map || value instanceof WeakMap || value instanceof Set || value instanceof WeakSet || value instanceof RegExp || value instanceof Promise || value === Math) {
51
+ if (
52
+ value instanceof Map ||
53
+ value instanceof WeakMap ||
54
+ value instanceof Set ||
55
+ value instanceof WeakSet ||
56
+ value instanceof RegExp ||
57
+ value instanceof Promise ||
58
+ value === Math
59
+ ) {
52
60
  return SerializableKind.Invalid;
53
61
  }
54
62
  if (typeof window === 'object') {
@@ -37,7 +37,11 @@ type TypeMatchInvalid = TypeMatchFileOnly | 'content';
37
37
 
38
38
  let root = process?.cwd?.() ?? window?.location?.domain ?? '/';
39
39
  export function setErrorLogRoot(_root: string) {
40
- if (typeof process !== 'undefined' && process.stderr?.write?.call && (process.env?.VSCODE_SHELL_INTEGRATION || process.env?.VSCODE_SHELL_INTEGRATION_SHELL_SCRIPT)) {
40
+ if (
41
+ typeof process !== 'undefined' &&
42
+ process.stderr?.write?.call &&
43
+ (process.env?.VSCODE_SHELL_INTEGRATION || process.env?.VSCODE_SHELL_INTEGRATION_SHELL_SCRIPT)
44
+ ) {
41
45
  process.stderr.write(`\x1B]633;P;Cwd=${vscEscapeValue(_root)}\x07`);
42
46
  }
43
47
  root = _root;
@@ -85,8 +89,8 @@ function addLoc(ret: IStructreStackLine, m: Record<TypeMatchFileOnly, string>) {
85
89
  ret.location = {
86
90
  schema: m.schema?.replace(endingSlashes, '') ?? '',
87
91
  path: path,
88
- line: Number.parseInt(m.line),
89
- column: Number.parseInt(m.column),
92
+ line: Number.parseInt(m.line, 10),
93
+ column: Number.parseInt(m.column, 10),
90
94
  isAbsolute: isAbsolute(path),
91
95
  };
92
96
  }
@@ -141,9 +145,9 @@ export function parseStackLine(line: string): IStructreStackLine {
141
145
  addLoc(ret, mEval);
142
146
 
143
147
  ret.eval = {
144
- eval_column: Number.parseInt(mEval.eval_column),
148
+ eval_column: Number.parseInt(mEval.eval_column, 10),
145
149
  eval_func: mEval.eval_func,
146
- eval_line: Number.parseInt(mEval.eval_line),
150
+ eval_line: Number.parseInt(mEval.eval_line, 10),
147
151
  funcs: [],
148
152
  };
149
153
  for (const item of line.matchAll(regEvalItem)) {
@@ -198,7 +202,9 @@ export function prettyPrintError<ErrorType extends IError = IError>(type: string
198
202
  if (!notify_printed && e.stack && e.message !== e.stack) {
199
203
  // console.log(JSON.stringify(e.stack), JSON.stringify(e.message));
200
204
  notify_printed = true;
201
- console.error('\x1B[2muse env.DISABLE_PRETTY_ERROR=yes / window.DISABLE_PRETTY_ERROR=true to see original error stack, use env.PRETTY_ERROR_LOCATION to see print location\x1B[0m');
205
+ console.error(
206
+ '\x1B[2muse env.DISABLE_PRETTY_ERROR=yes / window.DISABLE_PRETTY_ERROR=true to see original error stack, use env.PRETTY_ERROR_LOCATION to see print location\x1B[0m',
207
+ );
202
208
  }
203
209
  }
204
210
 
@@ -46,6 +46,7 @@ export class AsyncCallbackList<Argument extends unknown[]> {
46
46
  }
47
47
  const found = this.list.indexOf(item);
48
48
  if (found !== -1) {
49
+ // biome-ignore lint/style/noNonNullAssertion: ?
49
50
  return this.list.splice(found, 1)[0]!;
50
51
  }
51
52
  return null;
@@ -51,6 +51,7 @@ export class CallbackList<Argument extends unknown[]> {
51
51
  }
52
52
  const found = this.list.indexOf(item);
53
53
  if (found !== -1) {
54
+ // biome-ignore lint/style/noNonNullAssertion: already
54
55
  return this.list.splice(found, 1)[0]!;
55
56
  }
56
57
  return null;
@@ -0,0 +1,59 @@
1
+ export function mergeIterables<T>(...iterables: Iterable<T>[]): Generator<T, void, void>;
2
+ export function mergeIterables(...iterables: Iterable<unknown>[]): Generator<unknown, void, void>;
3
+ export function* mergeIterables<T>(...iterables: Iterable<T>[]) {
4
+ for (const iterable of iterables) {
5
+ for (const item of iterable) {
6
+ yield item;
7
+ }
8
+ }
9
+ }
10
+
11
+ export function joinAsyncIterables<T>(...iterables: (Iterable<T> | AsyncIterable<T>)[]): AsyncGenerator<Awaited<T>, void, void>;
12
+ export function joinAsyncIterables(...iterables: (Iterable<unknown> | AsyncIterable<unknown>)[]): AsyncGenerator<unknown, void, void>;
13
+ export async function* joinAsyncIterables<T>(...iterables: (Iterable<T> | AsyncIterable<T>)[]) {
14
+ for (const iterable of iterables) {
15
+ for await (const item of iterable) {
16
+ yield item;
17
+ }
18
+ }
19
+ }
20
+
21
+ export function interleaveIterables<T>(...iterables: Iterable<T>[]): Generator<T, void, void>;
22
+ export function interleaveIterables(...iterables: Iterable<unknown>[]): Generator<unknown, void, void>;
23
+ export function* interleaveIterables<T>(...iterables: Iterable<T>[]) {
24
+ const its = iterables.map((e) => e[Symbol.iterator]());
25
+ let active = its.length;
26
+
27
+ while (active > 0) {
28
+ for (const it of its) {
29
+ if (!it) continue;
30
+ const r = it.next();
31
+ if (r.done) {
32
+ active--;
33
+ its[its.indexOf(it)] = undefined as any;
34
+ } else {
35
+ yield r.value;
36
+ }
37
+ }
38
+ }
39
+ }
40
+
41
+ export function interleaveAsyncIterables<T>(...iterables: (Iterable<T> | AsyncIterable<T>)[]): AsyncGenerator<T, void, void>;
42
+ export function interleaveAsyncIterables(...iterables: (Iterable<unknown> | AsyncIterable<unknown>)[]): AsyncGenerator<unknown, void, void>;
43
+ export async function* interleaveAsyncIterables<T>(...iterables: (Iterable<T> | AsyncIterable<T>)[]) {
44
+ const its = iterables.map((e) => (Symbol.asyncIterator in e ? (e as AsyncIterable<T>)[Symbol.asyncIterator]() : (e as Iterable<T>)[Symbol.iterator]()));
45
+ let active = its.length;
46
+
47
+ while (active > 0) {
48
+ for (const it of its) {
49
+ if (!it) continue;
50
+ const r = await it.next();
51
+ if (r.done) {
52
+ active--;
53
+ its[its.indexOf(it)] = undefined as any;
54
+ } else {
55
+ yield r.value;
56
+ }
57
+ }
58
+ }
59
+ }
@@ -1,8 +1,8 @@
1
- import { isNodeJs } from '../../autoindex.js';
2
1
  import { tryInspect } from '../../debugging/inspect.js';
3
2
  import { getErrorFrame } from '../../error/get-frame.js';
4
3
  import { prettyFormatError } from '../../error/pretty.nodejs.js';
5
4
  import type { StackTraceHolder } from '../../error/stack-trace.js';
5
+ import { isNodeJs } from '../../platform/os.js';
6
6
  import { dispose_name } from './debug.js';
7
7
 
8
8
  export class Disposed extends Error {
@@ -13,9 +13,11 @@ export class RequiredMap<K, V> extends Map<K, V> {
13
13
 
14
14
  public override get(id: K, def?: V): V {
15
15
  if (super.has(id)) {
16
+ // biome-ignore lint/style/noNonNullAssertion: has
16
17
  return super.get(id)!;
17
18
  }
18
19
  if (arguments.length === 2) {
20
+ // biome-ignore lint/style/noNonNullAssertion: 1
19
21
  return def!;
20
22
  }
21
23
  throw new Error(`Unknown key {${id}} in map.`);
@@ -26,6 +28,7 @@ export class RequiredMap<K, V> extends Map<K, V> {
26
28
  */
27
29
  public entry(id: K, init: (id: K) => V): V {
28
30
  if (super.has(id)) {
31
+ // biome-ignore lint/style/noNonNullAssertion: has
29
32
  return super.get(id)!;
30
33
  }
31
34
  const nv = init(id);
@@ -45,6 +48,7 @@ export abstract class InstanceMap<K, V> extends Map<K, V> {
45
48
  */
46
49
  public override get(id: K): V {
47
50
  if (super.has(id)) {
51
+ // biome-ignore lint/style/noNonNullAssertion: has
48
52
  return super.get(id)!;
49
53
  }
50
54
  const nv = this.instance(id);
@@ -2,19 +2,10 @@
2
2
  * assert value is not null or undefined or NaN
3
3
  * @public
4
4
  */
5
- export function assertNotNull<T>(val: T | null | undefined): T {
6
- console.assert(val !== undefined && val !== null, 'AssertValue failed, got %s(%s).', typeof val, val);
7
- return val!;
8
- }
9
-
10
- /**
11
- * assert value is not null or undefined or NaN
12
- * @throws Value is null or undefined
13
- * @public
14
- */
15
- export function throwNull<T>(val: T) {
16
- if (val === undefined || val === null) {
17
- return val!;
5
+ export function assertNotNull<T>(val: T): NonNullable<T> {
6
+ if (val !== undefined && val !== null && !Number.isNaN(val)) {
7
+ return val;
8
+ } else {
9
+ throw new Error(`Assertion failed, got nullish value: ${typeof val}(${val}).`);
18
10
  }
19
- throw new Error(`Value is ${typeof val}`);
20
11
  }
@@ -4,7 +4,8 @@
4
4
  */
5
5
  export function objectPath(obj: object, path: string): any {
6
6
  path.split('.').every((name) => {
7
- return (obj = (obj as any)[name]);
7
+ obj = (obj as any)[name];
8
+ return !!obj;
8
9
  });
9
10
  return obj;
10
11
  }
@@ -26,6 +27,7 @@ export class ObjectPath {
26
27
  public get(path: readonly KeyType[]) {
27
28
  if (path.length === 0) throw new Error('path must not be empty');
28
29
  const rest = path.slice();
30
+ // biome-ignore lint/style/noNonNullAssertion: slice
29
31
  const last = rest.pop()!;
30
32
 
31
33
  let cursor = this.object;
@@ -42,6 +44,7 @@ export class ObjectPath {
42
44
  public exists(path: readonly KeyType[]) {
43
45
  if (path.length === 0) throw new Error('path must not be empty');
44
46
  const rest = path.slice();
47
+ // biome-ignore lint/style/noNonNullAssertion: slice
45
48
  const last = rest.pop()!;
46
49
 
47
50
  let cursor = this.object;
@@ -64,6 +67,7 @@ export class ObjectPath {
64
67
  if (path.length === 0) throw new Error('path must not be empty');
65
68
  function walkSet(cursor: any) {
66
69
  const rest = path.slice();
70
+ // biome-ignore lint/style/noNonNullAssertion: 100%
67
71
  const last = rest.pop()!;
68
72
 
69
73
  for (const [index, name] of rest.entries()) {
@@ -81,6 +85,7 @@ export class ObjectPath {
81
85
  }
82
86
  function walkDelete(cursor: any) {
83
87
  const rest = path.slice();
88
+ // biome-ignore lint/style/noNonNullAssertion: slice
84
89
  const last = rest.pop()!;
85
90
  const objects = [];
86
91
  for (const name of rest) {
@@ -1,3 +1,4 @@
1
+ const isAbsoluteReg = /^\/|^\\|^[a-z]:[\\/]|^[^:]{1,10}:\/\//i;
1
2
  /**
2
3
  * return true if a path is absolute:
3
4
  * - /xxxx
@@ -7,5 +8,5 @@
7
8
  * - http://
8
9
  */
9
10
  export function isAbsolute(path: string) {
10
- return /^\/|^\\|^[a-z]:[\\/]|^[^:]{1,10}:\/\//i.test(path);
11
+ return isAbsoluteReg.test(path);
11
12
  }
@@ -9,6 +9,9 @@ const winLetter = /^[a-z]:[/\\]/i;
9
9
  // samba: \\xxx\yyy
10
10
  const doubleSlash = /^[/\\]{2}[^/\\]/i;
11
11
 
12
+ const anySlash = /[/\\]/;
13
+ const startingSlashes = /^[/\\]+/;
14
+
12
15
  export enum PathKind {
13
16
  url = 0,
14
17
  unc = 1,
@@ -36,8 +39,8 @@ export function analyzePath(p: string) {
36
39
  url: u,
37
40
  };
38
41
  } else if (unc.test(p)) {
39
- p = p.replace(unc, '').replace(/^[/\\]+/, '');
40
- const i = /[///]/.exec(p)?.index ?? -1;
42
+ p = p.replace(unc, '').replace(startingSlashes, '');
43
+ const i = anySlash.exec(p)?.index ?? -1;
41
44
  if (i <= 0) throw new Error(`invalid unc path: ${inp}`);
42
45
 
43
46
  r = {
@@ -54,8 +57,8 @@ export function analyzePath(p: string) {
54
57
  path: p.slice(3),
55
58
  };
56
59
  } else if (doubleSlash.test(p)) {
57
- p = p.replace(/^[/\\]+/, '');
58
- const i = /[///]/.exec(p)?.index ?? -1;
60
+ p = p.replace(startingSlashes, '');
61
+ const i = anySlash.exec(p)?.index ?? -1;
59
62
  if (i <= 0) throw new Error(`invalid cifs url: ${inp}`);
60
63
 
61
64
  r = {
@@ -1,6 +1,3 @@
1
- declare global {
2
- interface ImportMeta {
3
- env?: Record<string, string>;
4
- }
5
- }
1
+ /// <reference path="./meta.d.ts" />
2
+
6
3
  export const isProductionMode = import.meta.env?.['MODE'] === 'production';
@@ -1,5 +1,3 @@
1
- /** biome-ignore-all lint/suspicious/noShadowRestrictedNames: */
2
-
3
1
  import { functionName } from '../debugging/object-with-name.js';
4
2
  import { ensureGlobalObject } from './globalObject.js';
5
3
 
@@ -12,14 +12,15 @@ const symbolRegistry = ensureGlobalObject('@@idlebox/global-symbol', () => {
12
12
  */
13
13
  export function createSymbol(category: string, name: string): symbol {
14
14
  if (symbolRegistry[category]?.[name]) {
15
- return symbolRegistry[category]?.[name]!;
15
+ return symbolRegistry[category][name];
16
16
  }
17
17
  if (!symbolRegistry[category]) {
18
18
  symbolRegistry[category] = {};
19
19
  }
20
- const c = symbolRegistry[category]!;
20
+ const c = symbolRegistry[category];
21
21
 
22
- return (c[name] = Symbol(name));
22
+ c[name] = Symbol(name);
23
+ return c[name];
23
24
  }
24
25
 
25
26
  /**
@@ -28,7 +29,7 @@ export function createSymbol(category: string, name: string): symbol {
28
29
  */
29
30
  export function deleteSymbol(category: string, name: string) {
30
31
  if (symbolRegistry[category]?.[name]) {
31
- const c = symbolRegistry[category]!;
32
+ const c = symbolRegistry[category];
32
33
  delete c[name];
33
34
  if (Object.keys(c).length === 0) {
34
35
  delete symbolRegistry[category];
@@ -1,6 +1,6 @@
1
1
  import { CanceledError, TimeoutError } from '@idlebox/errors';
2
- import type { TimeoutType } from '../autoindex.js';
3
2
  import type { IDisposable } from '../lifecycle/dispose/disposable.js';
3
+ import type { TimeoutType } from '../schedule/local-type.js';
4
4
  import { scheduler } from '../schedule/scheduler.js';
5
5
 
6
6
  export type ValueCallback<T = any> = (value: T | Promise<T>) => void;
@@ -1,4 +1,4 @@
1
- import { definePrivateConstant } from '../../autoindex.js';
1
+ import { definePrivateConstant } from '../../object/definePublicConstant.js';
2
2
 
3
3
  export const singletonSymbol = Symbol('@idlebox/singleton');
4
4
 
@@ -1,4 +1,4 @@
1
- import { nameObject } from '../../autoindex.js';
1
+ import { nameObject } from '../../debugging/object-with-name.js';
2
2
 
3
3
  export function bindThis(method: Function, context: ClassMethodDecoratorContext) {
4
4
  if (context.kind !== 'method') throw new Error(`this decorator can only be applied to classes`);
@@ -1,4 +1,5 @@
1
- import { definePrivateConstant, nameObject } from '../../autoindex.js';
1
+ import { nameObject } from '../../debugging/object-with-name.js';
2
+ import { definePrivateConstant } from '../../object/definePublicConstant.js';
2
3
 
3
4
  const memoizeSymbol = Symbol('@gongt/memorize');
4
5
 
@@ -1,4 +1,4 @@
1
- import { objectName } from '../autoindex.js';
1
+ import { objectName } from '../debugging/object-with-name.js';
2
2
  import type { IDisposable } from '../lifecycle/dispose/disposable.js';
3
3
  import { EnhancedDisposable } from '../lifecycle/dispose/sync-disposable.js';
4
4
  import { Emitter } from '../lifecycle/event/event.js';
@@ -1,8 +1,9 @@
1
1
  import { TimeoutError } from '@idlebox/errors';
2
+ import { isNodeJs } from '../platform/os.js';
2
3
 
3
4
  /**
4
5
  * @param unref defaults to `false`, when true, call `unref()` on the timer.
5
- * can not set to `true` on other platform.
6
+ * can not set to `true` on other platform (will throw "unref is not function" error).
6
7
  * @returns promise reject with TimeoutError after specific time
7
8
  */
8
9
  export function timeout(ms: number, error = 'no response', unref = false): Promise<never> {
@@ -39,11 +40,10 @@ export function raceTimeout<T>(ms: number, message: string, p: PromiseLike<T>):
39
40
  * @param p the promise
40
41
  * @returns
41
42
  */
42
- export function raceTimeout<T>(ms: number, message: string | PromiseLike<T>, p?: PromiseLike<T>): Promise<T> {
43
- let msg: string | undefined;
43
+ export function raceTimeout<T>(ms: number, message_or_p: string | PromiseLike<T>, p?: PromiseLike<T>): Promise<T> {
44
44
  if (p) {
45
- return Promise.race([p, timeout(ms, msg, true)]);
45
+ return Promise.race([p, timeout(ms, message_or_p as string, isNodeJs)]);
46
46
  } else {
47
- return Promise.race([message as any, timeout(ms, msg, true)]);
47
+ return Promise.race([message_or_p as PromiseLike<T>, timeout(ms, undefined, isNodeJs)]);
48
48
  }
49
49
  }
@@ -1,6 +1,6 @@
1
1
  import { Emitter } from '../lifecycle/event/event.js';
2
2
 
3
- export type IFsmRuleMap<StateType, EventType> = MapLike<StateType, MapLike<EventType, StateType>>;
3
+ export type ISsmRuleMap<StateType, EventType> = MapLike<StateType, MapLike<EventType, StateType>>;
4
4
 
5
5
  type MapLike<K, V> = Pick<Map<K, V>, 'get' | 'has' | 'keys'>;
6
6
 
@@ -12,12 +12,12 @@ export interface IStateChangeEvent<StateType, EventType> {
12
12
 
13
13
  export class SimpleStateMachine<StateType, EventType> {
14
14
  protected declare currentState: StateType;
15
- protected readonly rules: IFsmRuleMap<StateType, EventType>;
15
+ protected readonly rules: ISsmRuleMap<StateType, EventType>;
16
16
 
17
17
  private readonly _onStateChange = new Emitter<IStateChangeEvent<StateType, EventType>>();
18
18
  public readonly onStateChange = this._onStateChange.register;
19
19
 
20
- constructor(rules: IFsmRuleMap<StateType, EventType>, init_state: StateType) {
20
+ constructor(rules: ISsmRuleMap<StateType, EventType>, init_state: StateType) {
21
21
  this.rules = rules;
22
22
  this.moveTo(init_state);
23
23
  }
@@ -33,7 +33,8 @@ export class SimpleStateMachine<StateType, EventType> {
33
33
  }
34
34
 
35
35
  change(event: EventType) {
36
- const state = this.rules.get(this.currentState)!;
36
+ const state = this.rules.get(this.currentState);
37
+ if (!state) throw new Error(`no state "${this.currentState}"`);
37
38
  const next = state.get(event);
38
39
  if (typeof next === 'undefined') {
39
40
  throw new Error(
@@ -1,8 +1,9 @@
1
+ // biome-ignore-all lint: generated file
2
+ // biome-ignore-all assist: generated file
3
+ // biome-ignore-all syntax: generated file
1
4
  /* eslint-disable */
2
5
  // @ts-ignore
3
- // biome-ignore-all lint
4
- // biome-ignore-all assist
5
- // biome-ignore-all syntax
6
+
6
7
  /******************************************************************************
7
8
  * GENERATED FILE, DO NOT MODIFY
8
9
  * 这是生成的文件,千万不要修改