@bitblit/ratchet-common 4.0.99-alpha → 4.0.102-alpha

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 (298) hide show
  1. package/dist/{types/2d → 2d}/line-2d.d.ts +1 -1
  2. package/dist/{types/2d → 2d}/poly-line-2d.d.ts +1 -1
  3. package/dist/{types/2d → 2d}/ratchet-2d.d.ts +4 -4
  4. package/dist/{es/2d → 2d}/ratchet-2d.js +1 -1
  5. package/dist/2d/ratchet-2d.spec.js +117 -0
  6. package/dist/{types/build → build}/ratchet-common-info.d.ts +1 -1
  7. package/dist/{types/histogram → histogram}/histogram.d.ts +1 -4
  8. package/dist/{es/histogram → histogram}/histogram.js +1 -3
  9. package/dist/histogram/histogram.spec.js +19 -0
  10. package/dist/jwt/common-jwt-token.d.ts +6 -0
  11. package/dist/{types/jwt → jwt}/jwt-ratchet-like.d.ts +3 -6
  12. package/dist/{types/jwt → jwt}/jwt-ratchet.d.ts +4 -13
  13. package/dist/{es/jwt → jwt}/jwt-ratchet.js +12 -7
  14. package/dist/jwt/jwt-ratchet.spec.js +49 -0
  15. package/dist/{types/jwt → jwt}/jwt-token-base.d.ts +0 -4
  16. package/dist/lang/array-ratchet.d.ts +14 -0
  17. package/dist/{es/lang → lang}/array-ratchet.js +2 -2
  18. package/dist/lang/array-ratchet.spec.js +68 -0
  19. package/dist/{types/lang → lang}/base64-ratchet.d.ts +1 -1
  20. package/dist/{es/lang → lang}/base64-ratchet.js +1 -1
  21. package/dist/lang/base64-ratchet.spec.js +28 -0
  22. package/dist/{es/lang → lang}/boolean-ratchet.js +1 -1
  23. package/dist/lang/boolean-ratchet.spec.js +81 -0
  24. package/dist/{types/lang → lang}/composite-last-success-provider.d.ts +1 -2
  25. package/dist/{es/lang → lang}/composite-last-success-provider.js +2 -0
  26. package/dist/lang/composite-last-success-provider.spec.js +26 -0
  27. package/dist/{es/lang → lang}/date-ratchet.js +5 -5
  28. package/dist/lang/date-ratchet.spec.js +21 -0
  29. package/dist/{es/lang → lang}/duration-ratchet.js +1 -1
  30. package/dist/lang/duration-ratchet.spec.js +39 -0
  31. package/dist/lang/enum-ratchet.d.ts +5 -0
  32. package/dist/{es/lang → lang}/enum-ratchet.js +1 -1
  33. package/dist/lang/enum-ratchet.spec.d.ts +5 -0
  34. package/dist/lang/enum-ratchet.spec.js +31 -0
  35. package/dist/{es/lang → lang}/error-ratchet.js +1 -1
  36. package/dist/lang/error-ratchet.spec.js +20 -0
  37. package/dist/lang/esm-ratchet.d.ts +4 -0
  38. package/dist/lang/esm-ratchet.js +11 -0
  39. package/dist/{types/lang → lang}/expiring-object.d.ts +1 -1
  40. package/dist/{es/lang → lang}/expiring-object.js +13 -4
  41. package/dist/lang/expiring-object.spec.js +51 -0
  42. package/dist/{es/lang → lang}/geolocation-ratchet.js +4 -4
  43. package/dist/lang/geolocation-ratchet.spec.d.ts +1 -0
  44. package/dist/lang/geolocation-ratchet.spec.js +74 -0
  45. package/dist/{es/lang → lang}/global-ratchet.js +3 -3
  46. package/dist/lang/global-ratchet.spec.d.ts +1 -0
  47. package/dist/lang/global-ratchet.spec.js +14 -0
  48. package/dist/{es/lang → lang}/key-value.js +2 -0
  49. package/dist/lang/last-success-provider.d.ts +3 -0
  50. package/dist/lang/last-success-provider.js +1 -0
  51. package/dist/{types/lang → lang}/map-ratchet.d.ts +1 -1
  52. package/dist/{es/lang → lang}/map-ratchet.js +3 -3
  53. package/dist/lang/map-ratchet.spec.d.ts +1 -0
  54. package/dist/lang/map-ratchet.spec.js +90 -0
  55. package/dist/lang/no.spec.d.ts +1 -0
  56. package/dist/lang/no.spec.js +7 -0
  57. package/dist/{es/lang → lang}/number-ratchet.js +3 -3
  58. package/dist/lang/number-ratchet.spec.d.ts +1 -0
  59. package/dist/lang/number-ratchet.spec.js +118 -0
  60. package/dist/lang/parsed-url.js +1 -0
  61. package/dist/lang/promise-ratchet.d.ts +18 -0
  62. package/dist/{es/lang → lang}/promise-ratchet.js +5 -5
  63. package/dist/lang/promise-ratchet.spec.d.ts +1 -0
  64. package/dist/lang/promise-ratchet.spec.js +74 -0
  65. package/dist/{es/lang → lang}/require-ratchet.js +1 -1
  66. package/dist/lang/require-ratchet.spec.d.ts +3 -0
  67. package/dist/lang/require-ratchet.spec.js +80 -0
  68. package/dist/{types/lang → lang}/stop-watch.d.ts +1 -1
  69. package/dist/{es/lang → lang}/stop-watch.js +9 -8
  70. package/dist/{es/lang → lang}/string-ratchet.js +2 -2
  71. package/dist/lang/string-ratchet.spec.d.ts +1 -0
  72. package/dist/lang/string-ratchet.spec.js +158 -0
  73. package/dist/lang/time-zone-ratchet.d.ts +19 -0
  74. package/dist/{es/lang → lang}/time-zone-ratchet.js +2 -1
  75. package/dist/lang/time-zone-ratchet.spec.d.ts +1 -0
  76. package/dist/lang/time-zone-ratchet.spec.js +40 -0
  77. package/dist/{types/lang → lang}/timeout-token.d.ts +1 -1
  78. package/dist/{es/lang → lang}/timeout-token.js +5 -3
  79. package/dist/lang/timeout-token.spec.d.ts +1 -0
  80. package/dist/lang/timeout-token.spec.js +9 -0
  81. package/dist/{types/lang → lang}/transform-ratchet.d.ts +1 -1
  82. package/dist/{es/lang → lang}/transform-ratchet.js +1 -1
  83. package/dist/lang/transform-ratchet.spec.d.ts +1 -0
  84. package/dist/lang/transform-ratchet.spec.js +118 -0
  85. package/dist/logger/classic-single-line-log-message-formatter.d.ts +6 -0
  86. package/dist/{types/logger → logger}/log-message-builder.d.ts +2 -2
  87. package/dist/{es/logger → logger}/log-message-builder.js +1 -0
  88. package/dist/{types/logger → logger}/log-message-formatter.d.ts +2 -2
  89. package/dist/logger/log-message-formatter.js +1 -0
  90. package/dist/{types/logger → logger}/log-message-processor.d.ts +1 -1
  91. package/dist/logger/log-message-processor.js +1 -0
  92. package/dist/{types/logger → logger}/log-message.d.ts +1 -1
  93. package/dist/logger/log-message.js +1 -0
  94. package/dist/{types/logger → logger}/log-snapshot.d.ts +1 -1
  95. package/dist/logger/log-snapshot.js +1 -0
  96. package/dist/{types/logger → logger}/logger-instance.d.ts +6 -6
  97. package/dist/{es/logger → logger}/logger-instance.js +15 -8
  98. package/dist/{types/logger → logger}/logger-meta.d.ts +1 -1
  99. package/dist/logger/logger-meta.js +1 -0
  100. package/dist/{types/logger → logger}/logger-options.d.ts +4 -4
  101. package/dist/logger/logger-options.js +1 -0
  102. package/dist/{types/logger → logger}/logger-ring-buffer.d.ts +2 -2
  103. package/dist/{es/logger → logger}/logger-ring-buffer.js +7 -6
  104. package/dist/{types/logger → logger}/logger-util.d.ts +2 -2
  105. package/dist/{es/logger → logger}/logger-util.js +10 -10
  106. package/dist/logger/logger-util.spec.d.ts +1 -0
  107. package/dist/logger/logger-util.spec.js +9 -0
  108. package/dist/{types/logger → logger}/logger.d.ts +7 -16
  109. package/dist/{es/logger → logger}/logger.js +14 -14
  110. package/dist/logger/logger.spec.d.ts +1 -0
  111. package/dist/logger/logger.spec.js +134 -0
  112. package/dist/logger/none-log-message-formatter.d.ts +6 -0
  113. package/dist/logger/structured-json-log-message-formatter.d.ts +6 -0
  114. package/dist/{types/network → network}/browser-local-ip-provider.d.ts +1 -1
  115. package/dist/{es/network → network}/browser-local-ip-provider.js +3 -3
  116. package/dist/network/browser-local-ip-provider.spec.d.ts +1 -0
  117. package/dist/network/browser-local-ip-provider.spec.js +16 -0
  118. package/dist/{types/network → network}/fixed-local-ip-provider.d.ts +1 -1
  119. package/dist/{es/network → network}/fixed-local-ip-provider.js +1 -0
  120. package/dist/network/local-ip-provider.d.ts +3 -0
  121. package/dist/network/local-ip-provider.js +1 -0
  122. package/dist/{types/network → network}/network-ratchet.d.ts +1 -1
  123. package/dist/{es/network → network}/network-ratchet.js +2 -2
  124. package/dist/network/network-ratchet.spec.d.ts +1 -0
  125. package/dist/network/network-ratchet.spec.js +13 -0
  126. package/dist/{types/stream → stream}/buffer-writable.d.ts +2 -2
  127. package/dist/{es/stream → stream}/buffer-writable.js +1 -1
  128. package/dist/stream/multi-stream.d.ts +7 -0
  129. package/dist/stream/multi-stream.js +12 -0
  130. package/dist/{types/stream → stream}/stream-ratchet.d.ts +2 -2
  131. package/dist/{es/stream → stream}/stream-ratchet.js +2 -2
  132. package/dist/stream/stream-ratchet.spec.d.ts +1 -0
  133. package/dist/stream/stream-ratchet.spec.js +13 -0
  134. package/dist/{types/stream → stream}/string-writable.d.ts +1 -1
  135. package/dist/{es/stream → stream}/string-writable.js +1 -1
  136. package/dist/stream/string-writable.spec.d.ts +1 -0
  137. package/dist/stream/string-writable.spec.js +12 -0
  138. package/dist/{es/third-party → third-party}/google/google-recaptcha-ratchet.js +3 -3
  139. package/dist/third-party/google/google-recaptcha-ratchet.spec.d.ts +1 -0
  140. package/dist/third-party/google/google-recaptcha-ratchet.spec.js +20 -0
  141. package/dist/{types/third-party → third-party}/twilio/twilio-ratchet.d.ts +0 -4
  142. package/dist/{es/third-party → third-party}/twilio/twilio-ratchet.js +8 -5
  143. package/dist/{types/transform → transform}/built-in-transforms.d.ts +1 -1
  144. package/dist/{es/transform → transform}/built-in-transforms.js +2 -2
  145. package/dist/transform/transform-rule.js +1 -0
  146. package/dist/{types/tx → tx}/transaction-configuration.d.ts +2 -2
  147. package/dist/tx/transaction-configuration.js +1 -0
  148. package/dist/{types/tx → tx}/transaction-ratchet.d.ts +3 -3
  149. package/dist/{es/tx → tx}/transaction-ratchet.js +4 -4
  150. package/dist/tx/transaction-ratchet.spec.d.ts +1 -0
  151. package/dist/tx/transaction-ratchet.spec.js +130 -0
  152. package/dist/{types/tx → tx}/transaction-result.d.ts +1 -1
  153. package/dist/tx/transaction-result.js +1 -0
  154. package/dist/tx/transaction-step.js +1 -0
  155. package/package.json +10 -11
  156. package/dist/cjs/2d/line-2d.js +0 -2
  157. package/dist/cjs/2d/plane-2d.js +0 -2
  158. package/dist/cjs/2d/point-2d.js +0 -2
  159. package/dist/cjs/2d/poly-line-2d.js +0 -2
  160. package/dist/cjs/2d/ratchet-2d.js +0 -250
  161. package/dist/cjs/build/build-information.js +0 -2
  162. package/dist/cjs/build/ratchet-common-info.js +0 -18
  163. package/dist/cjs/histogram/histogram-entry.js +0 -2
  164. package/dist/cjs/histogram/histogram.js +0 -54
  165. package/dist/cjs/index.js +0 -74
  166. package/dist/cjs/jwt/common-jwt-token.js +0 -2
  167. package/dist/cjs/jwt/expired-jwt-handling.js +0 -9
  168. package/dist/cjs/jwt/jwt-ratchet-like.js +0 -2
  169. package/dist/cjs/jwt/jwt-ratchet.js +0 -164
  170. package/dist/cjs/jwt/jwt-token-base.js +0 -2
  171. package/dist/cjs/lang/array-ratchet.js +0 -87
  172. package/dist/cjs/lang/base64-ratchet.js +0 -49
  173. package/dist/cjs/lang/boolean-ratchet.js +0 -49
  174. package/dist/cjs/lang/composite-last-success-provider.js +0 -28
  175. package/dist/cjs/lang/date-ratchet.js +0 -33
  176. package/dist/cjs/lang/duration-ratchet.js +0 -46
  177. package/dist/cjs/lang/enum-ratchet.js +0 -34
  178. package/dist/cjs/lang/error-ratchet.js +0 -49
  179. package/dist/cjs/lang/expiring-object.js +0 -68
  180. package/dist/cjs/lang/geolocation-ratchet.js +0 -267
  181. package/dist/cjs/lang/global-ratchet.js +0 -48
  182. package/dist/cjs/lang/key-value.js +0 -6
  183. package/dist/cjs/lang/last-success-provider.js +0 -2
  184. package/dist/cjs/lang/map-ratchet.js +0 -168
  185. package/dist/cjs/lang/no.js +0 -8
  186. package/dist/cjs/lang/number-ratchet.js +0 -159
  187. package/dist/cjs/lang/parsed-url.js +0 -2
  188. package/dist/cjs/lang/promise-ratchet.js +0 -142
  189. package/dist/cjs/lang/require-ratchet.js +0 -60
  190. package/dist/cjs/lang/stop-watch.js +0 -117
  191. package/dist/cjs/lang/string-ratchet.js +0 -195
  192. package/dist/cjs/lang/time-zone-ratchet.js +0 -80
  193. package/dist/cjs/lang/timeout-token.js +0 -19
  194. package/dist/cjs/lang/transform-ratchet.js +0 -70
  195. package/dist/cjs/logger/classic-single-line-log-message-formatter.js +0 -18
  196. package/dist/cjs/logger/log-message-builder.js +0 -51
  197. package/dist/cjs/logger/log-message-format-type.js +0 -9
  198. package/dist/cjs/logger/log-message-formatter.js +0 -2
  199. package/dist/cjs/logger/log-message-processor.js +0 -2
  200. package/dist/cjs/logger/log-message.js +0 -2
  201. package/dist/cjs/logger/log-snapshot.js +0 -2
  202. package/dist/cjs/logger/logger-instance.js +0 -207
  203. package/dist/cjs/logger/logger-level-name.js +0 -12
  204. package/dist/cjs/logger/logger-meta.js +0 -2
  205. package/dist/cjs/logger/logger-options.js +0 -2
  206. package/dist/cjs/logger/logger-output-function.js +0 -9
  207. package/dist/cjs/logger/logger-ring-buffer.js +0 -76
  208. package/dist/cjs/logger/logger-util.js +0 -49
  209. package/dist/cjs/logger/logger.js +0 -139
  210. package/dist/cjs/logger/none-log-message-formatter.js +0 -9
  211. package/dist/cjs/logger/structured-json-log-message-formatter.js +0 -24
  212. package/dist/cjs/network/browser-local-ip-provider.js +0 -25
  213. package/dist/cjs/network/fixed-local-ip-provider.js +0 -12
  214. package/dist/cjs/network/local-ip-provider.js +0 -2
  215. package/dist/cjs/network/network-ratchet.js +0 -106
  216. package/dist/cjs/stream/buffer-writable.js +0 -20
  217. package/dist/cjs/stream/stream-ratchet.js +0 -72
  218. package/dist/cjs/stream/string-writable.js +0 -18
  219. package/dist/cjs/third-party/google/google-recaptcha-ratchet.js +0 -33
  220. package/dist/cjs/third-party/twilio/twilio-ratchet.js +0 -75
  221. package/dist/cjs/transform/built-in-transforms.js +0 -195
  222. package/dist/cjs/transform/transform-rule.js +0 -2
  223. package/dist/cjs/tx/transaction-configuration.js +0 -2
  224. package/dist/cjs/tx/transaction-final-state.js +0 -9
  225. package/dist/cjs/tx/transaction-ratchet.js +0 -80
  226. package/dist/cjs/tx/transaction-result.js +0 -2
  227. package/dist/cjs/tx/transaction-step.js +0 -2
  228. package/dist/es/index.js +0 -71
  229. package/dist/tsconfig.cjs.tsbuildinfo +0 -1
  230. package/dist/tsconfig.es.tsbuildinfo +0 -1
  231. package/dist/tsconfig.types.tsbuildinfo +0 -1
  232. package/dist/types/index.d.ts +0 -74
  233. package/dist/types/jwt/common-jwt-token.d.ts +0 -17
  234. package/dist/types/lang/array-ratchet.d.ts +0 -30
  235. package/dist/types/lang/enum-ratchet.d.ts +0 -12
  236. package/dist/types/lang/last-success-provider.d.ts +0 -4
  237. package/dist/types/lang/promise-ratchet.d.ts +0 -32
  238. package/dist/types/lang/time-zone-ratchet.d.ts +0 -50
  239. package/dist/types/logger/classic-single-line-log-message-formatter.d.ts +0 -6
  240. package/dist/types/logger/none-log-message-formatter.d.ts +0 -6
  241. package/dist/types/logger/structured-json-log-message-formatter.d.ts +0 -6
  242. package/dist/types/network/local-ip-provider.d.ts +0 -4
  243. /package/dist/{es/2d → 2d}/line-2d.js +0 -0
  244. /package/dist/{types/2d → 2d}/plane-2d.d.ts +0 -0
  245. /package/dist/{es/2d → 2d}/plane-2d.js +0 -0
  246. /package/dist/{types/2d → 2d}/point-2d.d.ts +0 -0
  247. /package/dist/{es/2d → 2d}/point-2d.js +0 -0
  248. /package/dist/{es/2d → 2d}/poly-line-2d.js +0 -0
  249. /package/dist/{es/build/build-information.js → 2d/ratchet-2d.spec.d.ts} +0 -0
  250. /package/dist/{types/build → build}/build-information.d.ts +0 -0
  251. /package/dist/{es/histogram/histogram-entry.js → build/build-information.js} +0 -0
  252. /package/dist/{es/build → build}/ratchet-common-info.js +0 -0
  253. /package/dist/{types/histogram → histogram}/histogram-entry.d.ts +0 -0
  254. /package/dist/{es/jwt/common-jwt-token.js → histogram/histogram-entry.js} +0 -0
  255. /package/dist/{es/jwt/jwt-ratchet-like.js → histogram/histogram.spec.d.ts} +0 -0
  256. /package/dist/{es/jwt/jwt-token-base.js → index.d.ts} +0 -0
  257. /package/dist/{es/lang/last-success-provider.js → index.js} +0 -0
  258. /package/dist/{es/lang/parsed-url.js → jwt/common-jwt-token.js} +0 -0
  259. /package/dist/{types/jwt → jwt}/expired-jwt-handling.d.ts +0 -0
  260. /package/dist/{es/jwt → jwt}/expired-jwt-handling.js +0 -0
  261. /package/dist/{es/logger/log-message-formatter.js → jwt/jwt-ratchet-like.js} +0 -0
  262. /package/dist/{es/logger/log-message-processor.js → jwt/jwt-ratchet.spec.d.ts} +0 -0
  263. /package/dist/{es/logger/log-message.js → jwt/jwt-token-base.js} +0 -0
  264. /package/dist/{es/logger/log-snapshot.js → lang/array-ratchet.spec.d.ts} +0 -0
  265. /package/dist/{es/logger/logger-meta.js → lang/base64-ratchet.spec.d.ts} +0 -0
  266. /package/dist/{types/lang → lang}/boolean-ratchet.d.ts +0 -0
  267. /package/dist/{es/logger/logger-options.js → lang/boolean-ratchet.spec.d.ts} +0 -0
  268. /package/dist/{es/network/local-ip-provider.js → lang/composite-last-success-provider.spec.d.ts} +0 -0
  269. /package/dist/{types/lang → lang}/date-ratchet.d.ts +0 -0
  270. /package/dist/{es/transform/transform-rule.js → lang/date-ratchet.spec.d.ts} +0 -0
  271. /package/dist/{types/lang → lang}/duration-ratchet.d.ts +0 -0
  272. /package/dist/{es/tx/transaction-configuration.js → lang/duration-ratchet.spec.d.ts} +0 -0
  273. /package/dist/{types/lang → lang}/error-ratchet.d.ts +0 -0
  274. /package/dist/{es/tx/transaction-result.js → lang/error-ratchet.spec.d.ts} +0 -0
  275. /package/dist/{es/tx/transaction-step.js → lang/expiring-object.spec.d.ts} +0 -0
  276. /package/dist/{types/lang → lang}/geolocation-ratchet.d.ts +0 -0
  277. /package/dist/{types/lang → lang}/global-ratchet.d.ts +0 -0
  278. /package/dist/{types/lang → lang}/key-value.d.ts +0 -0
  279. /package/dist/{types/lang → lang}/no.d.ts +0 -0
  280. /package/dist/{es/lang → lang}/no.js +0 -0
  281. /package/dist/{types/lang → lang}/number-ratchet.d.ts +0 -0
  282. /package/dist/{types/lang → lang}/parsed-url.d.ts +0 -0
  283. /package/dist/{types/lang → lang}/require-ratchet.d.ts +0 -0
  284. /package/dist/{types/lang → lang}/string-ratchet.d.ts +0 -0
  285. /package/dist/{es/logger → logger}/classic-single-line-log-message-formatter.js +0 -0
  286. /package/dist/{types/logger → logger}/log-message-format-type.d.ts +0 -0
  287. /package/dist/{es/logger → logger}/log-message-format-type.js +0 -0
  288. /package/dist/{types/logger → logger}/logger-level-name.d.ts +0 -0
  289. /package/dist/{es/logger → logger}/logger-level-name.js +0 -0
  290. /package/dist/{types/logger → logger}/logger-output-function.d.ts +0 -0
  291. /package/dist/{es/logger → logger}/logger-output-function.js +0 -0
  292. /package/dist/{es/logger → logger}/none-log-message-formatter.js +0 -0
  293. /package/dist/{es/logger → logger}/structured-json-log-message-formatter.js +0 -0
  294. /package/dist/{types/third-party → third-party}/google/google-recaptcha-ratchet.d.ts +0 -0
  295. /package/dist/{types/transform → transform}/transform-rule.d.ts +0 -0
  296. /package/dist/{types/tx → tx}/transaction-final-state.d.ts +0 -0
  297. /package/dist/{es/tx → tx}/transaction-final-state.js +0 -0
  298. /package/dist/{types/tx → tx}/transaction-step.d.ts +0 -0
@@ -1,8 +1,8 @@
1
- import { Logger } from '../logger/logger';
2
- import { ArrayRatchet } from './array-ratchet';
3
- import { TimeoutToken } from './timeout-token';
4
- import { StopWatch } from './stop-watch';
5
- import { LoggerLevelName } from '../logger/logger-level-name';
1
+ import { Logger } from '../logger/logger.js';
2
+ import { ArrayRatchet } from './array-ratchet.js';
3
+ import { TimeoutToken } from './timeout-token.js';
4
+ import { StopWatch } from './stop-watch.js';
5
+ import { LoggerLevelName } from '../logger/logger-level-name.js';
6
6
  export class PromiseRatchet {
7
7
  static resolveOnEvent(evtSrc, okEvtNames, errEvtNames = [], rval = null) {
8
8
  if (!evtSrc || !okEvtNames || okEvtNames.length === 0 || !evtSrc['on']) {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,74 @@
1
+ import { PromiseRatchet } from './promise-ratchet.js';
2
+ import { Logger } from '../logger/logger.js';
3
+ import { LoggerLevelName } from '../logger/logger-level-name.js';
4
+ const fnFalse = (ignored) => {
5
+ return false;
6
+ };
7
+ const fnOn3 = (t) => {
8
+ Logger.info('t=%d', t);
9
+ return t == 3;
10
+ };
11
+ const waitAndPrint = async (t1, t2) => {
12
+ Logger.info('Running: %s', t2);
13
+ await PromiseRatchet.wait(t1 * 2);
14
+ return t1 * 2;
15
+ };
16
+ describe('#promiseRatchet', function () {
17
+ it('should timeout eventually', async () => {
18
+ try {
19
+ Logger.setLevel(LoggerLevelName.silly);
20
+ const result = await PromiseRatchet.waitFor(fnFalse, true, 100, 2);
21
+ Logger.info('Got : %s', result);
22
+ expect(result).toEqual(false);
23
+ }
24
+ catch (err) {
25
+ Logger.warn('Error: %s', err, err);
26
+ }
27
+ });
28
+ it('should succeed on 3rd try', async () => {
29
+ const promise = PromiseRatchet.waitFor(fnOn3, true, 100, 4);
30
+ const result = await promise;
31
+ expect(result).toEqual(true);
32
+ });
33
+ it('should run 10 elements, 2 at a time', async () => {
34
+ Logger.setLevel(LoggerLevelName.debug);
35
+ const elements = [
36
+ [100, 'Test1'],
37
+ [200, 'Test2'],
38
+ [300, 'Test3'],
39
+ [400, 'Test4'],
40
+ [500, 'Test5'],
41
+ [600, 'Test6'],
42
+ [700, 'Test7'],
43
+ [800, 'Test8'],
44
+ [900, 'Test9'],
45
+ [1000, 'Test10'],
46
+ ];
47
+ const results = await PromiseRatchet.runBoundedParallel(waitAndPrint, elements, this, 2);
48
+ Logger.info('Final results %j', results);
49
+ expect(results).toBeTruthy();
50
+ expect(results.length).toEqual(10);
51
+ }, 30000);
52
+ it('should run 10 waits, 2 at a time', async () => {
53
+ Logger.setLevel(LoggerLevelName.debug);
54
+ const elements = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000];
55
+ const results = await PromiseRatchet.runBoundedParallelSingleParam(PromiseRatchet.wait, elements, this, 2);
56
+ Logger.info('Final results %j', results);
57
+ expect(results).toBeTruthy();
58
+ expect(results.length).toEqual(10);
59
+ });
60
+ xit('should run an async function as a for/each', async () => {
61
+ Logger.setLevel(LoggerLevelName.debug);
62
+ const elements = [1001, 1002, 2000];
63
+ const pfn = async (v) => {
64
+ Logger.info('Waiting %s', v);
65
+ await PromiseRatchet.wait(v);
66
+ Logger.info('Finished %s', v);
67
+ };
68
+ Logger.info('Serial test');
69
+ await PromiseRatchet.asyncForEachSerial(elements, pfn);
70
+ Logger.info('Parallel test');
71
+ await PromiseRatchet.asyncForEachParallel(elements, pfn);
72
+ Logger.info('Done');
73
+ });
74
+ });
@@ -1,4 +1,4 @@
1
- import { ErrorRatchet } from './error-ratchet';
1
+ import { ErrorRatchet } from './error-ratchet.js';
2
2
  export class RequireRatchet {
3
3
  static isNullOrUndefined(ob) {
4
4
  return ob === null || ob === undefined;
@@ -0,0 +1,3 @@
1
+ export declare class ConstructorTester {
2
+ constructor(testVal1: string, testVal2: string);
3
+ }
@@ -0,0 +1,80 @@
1
+ import { RequireRatchet } from './require-ratchet.js';
2
+ import { fail } from 'assert';
3
+ import { Logger } from '../logger/logger.js';
4
+ describe('#standardCases', function () {
5
+ it('should throw exception on null value', function () {
6
+ try {
7
+ RequireRatchet.notNullOrUndefined(null, 'test1');
8
+ fail('Should have thrown exception');
9
+ }
10
+ catch (err) {
11
+ Logger.debug('Correctly threw exception : %s', err);
12
+ }
13
+ try {
14
+ RequireRatchet.notNullOrUndefined(undefined, 'test2');
15
+ fail('Should have thrown exception');
16
+ }
17
+ catch (err) {
18
+ Logger.debug('Correctly threw exception : %s', err);
19
+ }
20
+ });
21
+ it('should throw exception on whitespace value', function () {
22
+ try {
23
+ RequireRatchet.notNullUndefinedOrOnlyWhitespaceString('', 'test1');
24
+ fail('Should have thrown exception');
25
+ }
26
+ catch (err) {
27
+ Logger.debug('Correctly threw exception : %s', err);
28
+ }
29
+ try {
30
+ RequireRatchet.notNullUndefinedOrOnlyWhitespaceString(' ', 'test2');
31
+ fail('Should have thrown exception');
32
+ }
33
+ catch (err) {
34
+ Logger.debug('Correctly threw exception : %s', err);
35
+ }
36
+ });
37
+ });
38
+ describe('#noNullOrUndefinedValuesInArray', function () {
39
+ it('should throw exception on null value', function () {
40
+ const arr = [1, null, 'a'];
41
+ try {
42
+ RequireRatchet.noNullOrUndefinedValuesInArray(arr);
43
+ fail('Should have thrown exception');
44
+ }
45
+ catch (err) {
46
+ Logger.debug('Correctly threw exception : %s', err);
47
+ }
48
+ });
49
+ it('throw exception on bad length', function () {
50
+ const arr = [1, 2, 'a'];
51
+ try {
52
+ RequireRatchet.noNullOrUndefinedValuesInArray(arr, 4);
53
+ fail('Should have thrown exception');
54
+ }
55
+ catch (err) {
56
+ Logger.debug('Correctly threw exception : %s', err);
57
+ }
58
+ });
59
+ it('should not throw exception on good values', function () {
60
+ const arr = [1, 2, 'a'];
61
+ RequireRatchet.noNullOrUndefinedValuesInArray(arr, 3);
62
+ });
63
+ it('should not throw exception on good constructor values', function () {
64
+ const test = new ConstructorTester('a', 'b');
65
+ });
66
+ it('throw exception on null constructor param', function () {
67
+ try {
68
+ const test = new ConstructorTester('a', null);
69
+ fail('Should have thrown exception');
70
+ }
71
+ catch (err) {
72
+ Logger.debug('Correctly threw exception : %s', err);
73
+ }
74
+ });
75
+ });
76
+ export class ConstructorTester {
77
+ constructor(testVal1, testVal2) {
78
+ Logger.info('Args : %j', this.constructor);
79
+ }
80
+ }
@@ -1,4 +1,4 @@
1
- import { LoggerLevelName } from '../logger/logger-level-name';
1
+ import { LoggerLevelName } from '../logger/logger-level-name.js';
2
2
  export declare class StopWatch {
3
3
  private label;
4
4
  private starts;
@@ -1,14 +1,15 @@
1
- import { DurationRatchet } from './duration-ratchet';
2
- import { StringRatchet } from './string-ratchet';
3
- import { RequireRatchet } from './require-ratchet';
4
- import { LoggerLevelName } from '../logger/logger-level-name';
5
- import { Logger } from '../logger/logger';
1
+ import { DurationRatchet } from './duration-ratchet.js';
2
+ import { StringRatchet } from './string-ratchet.js';
3
+ import { RequireRatchet } from './require-ratchet.js';
4
+ import { LoggerLevelName } from '../logger/logger-level-name.js';
5
+ import { Logger } from '../logger/logger.js';
6
6
  export class StopWatch {
7
+ label;
8
+ starts = new Map();
9
+ ends = new Map();
10
+ createTime = Date.now();
7
11
  constructor(label = StringRatchet.createRandomHexString(4)) {
8
12
  this.label = label;
9
- this.starts = new Map();
10
- this.ends = new Map();
11
- this.createTime = Date.now();
12
13
  }
13
14
  start(name) {
14
15
  RequireRatchet.notNullUndefinedOrOnlyWhitespaceString(name, 'name');
@@ -1,5 +1,6 @@
1
- import { RequireRatchet } from './require-ratchet';
1
+ import { RequireRatchet } from './require-ratchet.js';
2
2
  export class StringRatchet {
3
+ static RFC_3986_RESERVED = ['!', '*', "'", '(', ')', ';', ':', '@', '&', '=', '+', '$', ',', '/', '?', '#', '[', ']', '%'];
3
4
  static stringToUint8Array(val) {
4
5
  return val ? new TextEncoder().encode(val) : null;
5
6
  }
@@ -188,4 +189,3 @@ export class StringRatchet {
188
189
  return rval;
189
190
  }
190
191
  }
191
- StringRatchet.RFC_3986_RESERVED = ['!', '*', "'", '(', ')', ';', ':', '@', '&', '=', '+', '$', ',', '/', '?', '#', '[', ']', '%'];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,158 @@
1
+ import { StringRatchet } from './string-ratchet.js';
2
+ describe('#formatBytes', function () {
3
+ it('should format 0 bytes correctly', function () {
4
+ const result = StringRatchet.formatBytes(0);
5
+ expect(result).toEqual('0 Bytes');
6
+ });
7
+ it('should format less than a Kb correctly', function () {
8
+ const result = StringRatchet.formatBytes(123);
9
+ expect(result).toEqual('123 Bytes');
10
+ });
11
+ it('should format less than a Mb correctly', function () {
12
+ const result = StringRatchet.formatBytes(1024);
13
+ expect(result).toEqual('1 KB');
14
+ });
15
+ it('should format less than a Mb correctly with 3 decimals', function () {
16
+ const result = StringRatchet.formatBytes(1234, 3);
17
+ expect(result).toEqual('1.205 KB');
18
+ });
19
+ });
20
+ describe('#safeToString', function () {
21
+ it('should return "asdf"', function () {
22
+ const result = StringRatchet.safeString('asdf');
23
+ expect(result).toEqual('asdf');
24
+ });
25
+ it('should return "55"', function () {
26
+ const result = StringRatchet.safeString(55);
27
+ expect(result).toEqual('55');
28
+ });
29
+ });
30
+ describe('#obscure', function () {
31
+ it('should return "pa****rd"', function () {
32
+ const result = StringRatchet.obscure('password', 2, 2);
33
+ expect(result).toEqual('pa****rd');
34
+ });
35
+ it('should return null', function () {
36
+ const result = StringRatchet.obscure(null, 2, 2);
37
+ expect(result).toBeNull();
38
+ });
39
+ it('should return "p**s"', function () {
40
+ const result = StringRatchet.obscure('pass', 2, 2);
41
+ expect(result).toEqual('p**s');
42
+ });
43
+ it('should return "****"', function () {
44
+ const result = StringRatchet.obscure('pass', 0, 0);
45
+ expect(result).toEqual('****');
46
+ });
47
+ it('should return "p***"', function () {
48
+ const result = StringRatchet.obscure('pass', 1, 0);
49
+ expect(result).toEqual('p***');
50
+ });
51
+ it('should return "***s"', function () {
52
+ const result = StringRatchet.obscure('pass', 0, 1);
53
+ expect(result).toEqual('***s');
54
+ });
55
+ });
56
+ describe('#guid', function () {
57
+ it('should generate a guid"', function () {
58
+ const result = StringRatchet.createType4Guid();
59
+ expect(result).toBeTruthy();
60
+ });
61
+ });
62
+ describe('#randomHexString', function () {
63
+ it('should generate a random hex string"', function () {
64
+ const result = StringRatchet.createRandomHexString(12);
65
+ expect(result).toBeTruthy();
66
+ expect(result.length).toEqual(12);
67
+ });
68
+ });
69
+ describe('#leadingZeros', function () {
70
+ it('should generate string with leading zeros"', function () {
71
+ const result = StringRatchet.leadingZeros(25, 4);
72
+ expect(result).toEqual('0025');
73
+ });
74
+ it('should generate string with leading zeros and a negative sign"', function () {
75
+ const result = StringRatchet.leadingZeros(-8, 2);
76
+ expect(result).toEqual('-08');
77
+ });
78
+ });
79
+ describe('#stripNonNumeric', function () {
80
+ it('should return a string containing only numbers"', function () {
81
+ const result = StringRatchet.stripNonNumeric('702-555-1212');
82
+ expect(result).toEqual('7025551212');
83
+ });
84
+ });
85
+ describe('#stringContainsOnly', function () {
86
+ it('should check string contains only valid chars"', function () {
87
+ expect(StringRatchet.stringContainsOnly('test', 'tes')).toBeTruthy();
88
+ expect(StringRatchet.stringContainsOnly('test', 'teg')).toBeFalsy();
89
+ expect(StringRatchet.stringContainsOnlyAlphanumeric('test')).toBeTruthy();
90
+ expect(StringRatchet.stringContainsOnlyAlphanumeric('tes-')).toBeFalsy();
91
+ expect(StringRatchet.stringContainsOnlyHex('1a3')).toBeTruthy();
92
+ expect(StringRatchet.stringContainsOnlyHex('test')).toBeFalsy();
93
+ });
94
+ });
95
+ describe('#stringCsvSafe', function () {
96
+ it('should make values safe to place in a CSV"', function () {
97
+ expect(StringRatchet.csvSafe('test')).toEqual('test');
98
+ expect(StringRatchet.csvSafe('test,and 1')).toEqual('"test,and 1"');
99
+ expect(StringRatchet.csvSafe(1)).toEqual('1');
100
+ expect(StringRatchet.csvSafe("test'blah")).toEqual('"test\'blah"');
101
+ });
102
+ });
103
+ describe('#trimToEmpty', function () {
104
+ it('should return an empty string for null"', function () {
105
+ const result = StringRatchet.trimToEmpty(null);
106
+ expect(result).toEqual('');
107
+ });
108
+ it('should return an empty string for undefined"', function () {
109
+ const result = StringRatchet.trimToEmpty(undefined);
110
+ expect(result).toEqual('');
111
+ });
112
+ it('should return an empty string"', function () {
113
+ const result = StringRatchet.trimToEmpty(' ');
114
+ expect(result).toEqual('');
115
+ });
116
+ it('should return an abc"', function () {
117
+ const result = StringRatchet.trimToEmpty('abc ');
118
+ expect(result).toEqual('abc');
119
+ });
120
+ it('should return string "5"', function () {
121
+ const result = StringRatchet.trimToEmpty(5);
122
+ expect(result).toEqual('5');
123
+ });
124
+ });
125
+ describe('#trimStringPropertiesInPlace', function () {
126
+ it('should trim properties to null"', function () {
127
+ const test = {
128
+ a: 'test ',
129
+ b: 1,
130
+ c: ' test',
131
+ d: null,
132
+ e: ' ',
133
+ };
134
+ const nullResult = StringRatchet.trimAllStringPropertiesToNullInPlace(test);
135
+ expect(nullResult).not.toBeNull();
136
+ expect(nullResult['a']).toEqual('test');
137
+ expect(nullResult['b']).toEqual(1);
138
+ expect(nullResult['c']).toEqual('test');
139
+ expect(nullResult['d']).toEqual(null);
140
+ expect(nullResult['e']).toEqual(null);
141
+ });
142
+ it('should trim properties to empty"', function () {
143
+ const test = {
144
+ a: 'test ',
145
+ b: 1,
146
+ c: ' test',
147
+ d: null,
148
+ e: ' ',
149
+ };
150
+ const emptyResult = StringRatchet.trimAllStringPropertiesToEmptyInPlace(test);
151
+ expect(emptyResult).not.toBeNull();
152
+ expect(emptyResult['a']).toEqual('test');
153
+ expect(emptyResult['b']).toEqual(1);
154
+ expect(emptyResult['c']).toEqual('test');
155
+ expect(emptyResult['d']).toEqual(null);
156
+ expect(emptyResult['e']).toEqual('');
157
+ });
158
+ });
@@ -0,0 +1,19 @@
1
+ export declare class TimeZoneRatchet {
2
+ static PACIFIC: TimeZoneRatchet;
3
+ private timezone;
4
+ constructor(timezone: string);
5
+ currentHour(): number;
6
+ private toEpochSeconds;
7
+ startOfTodayEpochSeconds(): number;
8
+ startOfMatchingDayEpochSeconds(inputTS: number): number;
9
+ startOfMatchingDayEpochMS(inputTS: number): number;
10
+ startOfCurrentHourEpochSeconds(): number;
11
+ startOfCurrentMinuteEpochSeconds(): number;
12
+ startOfCurrentSecondEpochSeconds(): number;
13
+ startOfTodayEpochMS(): number;
14
+ dailySlotCount(slotWidthMs: number): number;
15
+ currentTimeSlotIdx(slotWidthMs: number): number;
16
+ matchingTimeSlotIdx(timestamp: number, slotWidthMs: number): number;
17
+ startOfCurrentSlotEpochMS(slotWidthMs: number): number;
18
+ startOfMatchingSlotEpochMS(timestamp: number, slotWidthMs: number): number;
19
+ }
@@ -1,5 +1,7 @@
1
1
  import { DateTime } from 'luxon';
2
2
  export class TimeZoneRatchet {
3
+ static PACIFIC = new TimeZoneRatchet('America/Los_Angeles');
4
+ timezone;
3
5
  constructor(timezone) {
4
6
  if (!timezone) {
5
7
  throw 'Timezone cannot be null';
@@ -73,4 +75,3 @@ export class TimeZoneRatchet {
73
75
  return startOfDay + currentIdx * slotWidthMs;
74
76
  }
75
77
  }
76
- TimeZoneRatchet.PACIFIC = new TimeZoneRatchet('America/Los_Angeles');
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import { TimeZoneRatchet } from './time-zone-ratchet.js';
2
+ const tz = TimeZoneRatchet.PACIFIC;
3
+ describe('#currentHour', function () {
4
+ it('should return 0- 23', function () {
5
+ const result = tz.currentHour();
6
+ expect(result).toBeGreaterThanOrEqual(0);
7
+ expect(result).toBeLessThanOrEqual(23);
8
+ });
9
+ });
10
+ describe('#startOfTodayEpochSeconds', function () {
11
+ it('should never be more than now or more than 86400 seconds in the past', function () {
12
+ const now = Math.floor(new Date().getTime() / 1000);
13
+ const start = tz.startOfTodayEpochSeconds();
14
+ const result = now - start;
15
+ expect(result).toBeGreaterThanOrEqual(0);
16
+ expect(result).toBeLessThanOrEqual(86400);
17
+ });
18
+ });
19
+ describe('#dailySlotCount', function () {
20
+ it('should return 86400', function () {
21
+ const result = tz.dailySlotCount(1000);
22
+ expect(result).toEqual(86400);
23
+ });
24
+ });
25
+ describe('#currentTimeSlotIdx', function () {
26
+ xit('should return same as current hour', function () {
27
+ const curHour = tz.currentHour();
28
+ const hourSlot = 1000 * 60 * 60;
29
+ const curSlot = tz.currentTimeSlotIdx(hourSlot);
30
+ expect(curSlot).toEqual(curHour);
31
+ });
32
+ });
33
+ describe('#matchingTimeSlotIdx', function () {
34
+ xit('should return same as current hour', function () {
35
+ const curHour = tz.currentHour();
36
+ const hourSlot = 1000 * 60 * 60;
37
+ const matchSlot = tz.matchingTimeSlotIdx(new Date().getTime(), hourSlot);
38
+ expect(matchSlot).toEqual(curHour);
39
+ });
40
+ });
@@ -1,4 +1,4 @@
1
- import { LoggerLevelName } from '../logger/logger-level-name';
1
+ import { LoggerLevelName } from '../logger/logger-level-name.js';
2
2
  export declare class TimeoutToken {
3
3
  private title;
4
4
  private timeoutMS;
@@ -1,10 +1,12 @@
1
- import { Logger } from '../logger/logger';
2
- import { LoggerLevelName } from '../logger/logger-level-name';
1
+ import { Logger } from '../logger/logger.js';
2
+ import { LoggerLevelName } from '../logger/logger-level-name.js';
3
3
  export class TimeoutToken {
4
+ title;
5
+ timeoutMS;
6
+ __timeoutTokenFlagField = true;
4
7
  constructor(title, timeoutMS) {
5
8
  this.title = title;
6
9
  this.timeoutMS = timeoutMS;
7
- this.__timeoutTokenFlagField = true;
8
10
  }
9
11
  writeToLog(logLevel = LoggerLevelName.warn) {
10
12
  Logger.logByLevel(logLevel, 'Timed out after %d ms waiting for results of %s', this.timeoutMS, this.title);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { TimeoutToken } from './timeout-token.js';
2
+ describe('#timeoutToken', function () {
3
+ it('should return the correct value for isTimeoutToken', function () {
4
+ const tt = new TimeoutToken('title', 20000);
5
+ const ntt = { a: 'b' };
6
+ expect(TimeoutToken.isTimeoutToken(tt)).toBeTruthy();
7
+ expect(TimeoutToken.isTimeoutToken(ntt)).toBeFalsy();
8
+ });
9
+ });
@@ -1,4 +1,4 @@
1
- import { TransformRule } from '../transform/transform-rule';
1
+ import { TransformRule } from '../transform/transform-rule.js';
2
2
  export declare class TransformRatchet {
3
3
  static transform(toTransform: any, rules?: TransformRule[]): any;
4
4
  private static transformGeneric;
@@ -1,4 +1,4 @@
1
- import { Logger } from '../logger/logger';
1
+ import { Logger } from '../logger/logger.js';
2
2
  export class TransformRatchet {
3
3
  static transform(toTransform, rules = []) {
4
4
  return TransformRatchet.transformGeneric(toTransform, rules, false, null);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,118 @@
1
+ import { TransformRatchet } from './transform-ratchet.js';
2
+ import { BuiltInTransforms } from '../transform/built-in-transforms.js';
3
+ describe('#formatBytes', function () {
4
+ const srcData = {
5
+ key1: 'value1',
6
+ key2: 'value2',
7
+ dateKey1: '1995-02-01',
8
+ intKey1: 0,
9
+ intKey2: 1,
10
+ boolKey1: true,
11
+ boolKey2: false,
12
+ camelSnake: 'this is a camel case',
13
+ subKey: {
14
+ key1: 'subValue1',
15
+ key2: 'subValue2',
16
+ convertToNumberInner: '42',
17
+ },
18
+ convertToNumber: '1',
19
+ convertToNumberAlso: '20',
20
+ };
21
+ const srcUnderData = {
22
+ new_key_1: 'value1',
23
+ sub_key: {
24
+ new_key_2: 'value2',
25
+ },
26
+ };
27
+ it('should convert camel to snakecase', function () {
28
+ const result = TransformRatchet.transform(srcData, [BuiltInTransforms.keysOnly(BuiltInTransforms.camelToSnakeCase())]);
29
+ expect(result['dateKey1']).toBeUndefined();
30
+ expect(result['intKey1']).toBeUndefined();
31
+ expect(result['intKey2']).toBeUndefined();
32
+ expect(result['boolKey1']).toBeUndefined();
33
+ expect(result['boolKey2']).toBeUndefined();
34
+ expect(result['subKey']).toBeUndefined();
35
+ expect(result['date_key1']).toBeTruthy();
36
+ expect(result['int_key1']).toEqual(0);
37
+ expect(result['int_key2']).toBeTruthy();
38
+ expect(result['bool_key1']).toBeTruthy();
39
+ expect(result['bool_key1']).toBeTruthy();
40
+ expect(result['sub_key']).toBeTruthy();
41
+ });
42
+ it('should duplicate key1 into key3', function () {
43
+ const result = TransformRatchet.transform(srcData, [BuiltInTransforms.makeDuplicateField('key1', 'key3')]);
44
+ expect(result.key1).toEqual('value1');
45
+ expect(result.key3).toEqual('value1');
46
+ });
47
+ it('should create a new field named key3', function () {
48
+ const result = TransformRatchet.transform(srcData, [BuiltInTransforms.addField('key3', 'value3')]);
49
+ expect(result.key1).toEqual('value1');
50
+ expect(result.key3).toEqual('value3');
51
+ });
52
+ it('should reformat the date in dateField1 to MM-dd-yyyy', function () {
53
+ const result = TransformRatchet.transform(srcData, [BuiltInTransforms.reformatDateFields(['dateKey1'], 'yyyy-MM-dd', 'MM/dd/yyyy')]);
54
+ expect(result.dateKey1).toEqual('02/01/1995');
55
+ });
56
+ it('should convert numbers to booleans', function () {
57
+ const result = TransformRatchet.transform(srcData, [BuiltInTransforms.numberToBool(['intKey1', 'intKey2'])]);
58
+ expect(result.key1).toEqual('value1');
59
+ expect(result.intKey1).toEqual(false);
60
+ expect(result.intKey2).toEqual(true);
61
+ });
62
+ it('should convert booleans to number', function () {
63
+ const result = TransformRatchet.transform(srcData, [BuiltInTransforms.boolToNumber(['boolKey1', 'boolKey2'])]);
64
+ expect(result.key1).toEqual('value1');
65
+ expect(result.boolKey1).toEqual(1);
66
+ expect(result.boolKey2).toEqual(0);
67
+ });
68
+ it('should concatenate key1 and key2 into key3', function () {
69
+ const result = TransformRatchet.transform(srcData, [BuiltInTransforms.concatenateToNewField('key3', ['key1', 'key2'])]);
70
+ expect(result.key1).toBeUndefined();
71
+ expect(result.key2).toBeUndefined();
72
+ expect(result.key3).toEqual('value1value2');
73
+ expect(result.subKey.key1).toBeUndefined();
74
+ expect(result.subKey.key2).toBeUndefined();
75
+ expect(result.subKey.key3).toEqual('subValue1subValue2');
76
+ });
77
+ it('should strip a key correctly', function () {
78
+ const result = TransformRatchet.transform(srcData, [BuiltInTransforms.stripStringTransform('key1')]);
79
+ expect(result.key1).toBeUndefined();
80
+ });
81
+ it('should rename a key correctly', function () {
82
+ const result = TransformRatchet.transform(srcData, [BuiltInTransforms.stringReplaceTransform('key1', 'newKey1')]);
83
+ expect(result.key1).toBeUndefined();
84
+ expect(result.newKey1).toEqual('value1');
85
+ expect(result.subKey.key1).toBeUndefined();
86
+ expect(result.subKey.newKey1).toEqual('subValue1');
87
+ });
88
+ it('should retain only key1 and key2', function () {
89
+ const result = TransformRatchet.transform(srcData, [BuiltInTransforms.keysOnly(BuiltInTransforms.retainAll(['key1', 'key2']))]);
90
+ expect(result.key1).toBeTruthy();
91
+ expect(result.key2).toBeTruthy();
92
+ expect(result.intKey1).toBeUndefined();
93
+ expect(result.boolKey1).toBeUndefined();
94
+ expect(result.subKey).toBeUndefined();
95
+ });
96
+ it('should remove only key1 and key2', function () {
97
+ const result = TransformRatchet.transform(srcData, [BuiltInTransforms.keysOnly(BuiltInTransforms.removeAll(['key1', 'key2']))]);
98
+ expect(result.key1).toBeUndefined();
99
+ expect(result.key2).toBeUndefined();
100
+ expect(result.intKey1).toEqual(0);
101
+ expect(result.boolKey1).toBeTruthy();
102
+ expect(result.subKey).toBeTruthy();
103
+ });
104
+ it('should convert snake to camelcase', function () {
105
+ const result = TransformRatchet.transform(srcUnderData, [BuiltInTransforms.keysOnly(BuiltInTransforms.snakeToCamelCase())]);
106
+ expect(result['new_key_1']).toBeUndefined();
107
+ expect(result['sub_key']).toBeUndefined();
108
+ expect(result.newKey1).toBeTruthy();
109
+ expect(result.subKey).toBeTruthy();
110
+ expect(result.subKey.newKey2).toBeTruthy();
111
+ });
112
+ it('should convert strings to numbers', function () {
113
+ const result = TransformRatchet.transform(srcData, [BuiltInTransforms.valuesOnly(BuiltInTransforms.stringToNumber())]);
114
+ expect(result['convertToNumber']).toEqual(1);
115
+ expect(result['convertToNumberAlso']).toEqual(20);
116
+ expect(result['subKey']['convertToNumberInner']).toEqual(42);
117
+ });
118
+ });
@@ -0,0 +1,6 @@
1
+ import { LogMessage } from './log-message.js';
2
+ import { LogMessageFormatter } from './log-message-formatter.js';
3
+ import { LoggerMeta } from './logger-meta.js';
4
+ export declare class ClassicSingleLineLogMessageFormatter implements LogMessageFormatter {
5
+ formatMessage(msg: LogMessage, meta: LoggerMeta): string;
6
+ }
@@ -1,5 +1,5 @@
1
- import { LoggerLevelName } from './logger-level-name';
2
- import { LogMessage } from './log-message';
1
+ import { LoggerLevelName } from './logger-level-name.js';
2
+ import { LogMessage } from './log-message.js';
3
3
  export declare class LogMessageBuilder {
4
4
  private wrapped;
5
5
  constructor(lvl: LoggerLevelName, messageSource?: string);