@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,4 +1,4 @@
1
- import { Point2d } from './point-2d';
1
+ import { Point2d } from './point-2d.js';
2
2
  export interface Line2d {
3
3
  p1: Point2d;
4
4
  p2: Point2d;
@@ -1,4 +1,4 @@
1
- import { Point2d } from './point-2d';
1
+ import { Point2d } from './point-2d.js';
2
2
  export interface PolyLine2d {
3
3
  pts: Point2d[];
4
4
  }
@@ -1,7 +1,7 @@
1
- import { Point2d } from './point-2d';
2
- import { Plane2d } from './plane-2d';
3
- import { Line2d } from './line-2d';
4
- import { PolyLine2d } from './poly-line-2d';
1
+ import { Point2d } from './point-2d.js';
2
+ import { Plane2d } from './plane-2d.js';
3
+ import { Line2d } from './line-2d.js';
4
+ import { PolyLine2d } from './poly-line-2d.js';
5
5
  export declare class Ratchet2d {
6
6
  private constructor();
7
7
  static translateToOriginVector(points: Point2d[]): Point2d;
@@ -1,4 +1,4 @@
1
- import { BooleanRatchet } from '../lang/boolean-ratchet';
1
+ import { BooleanRatchet } from '../lang/boolean-ratchet.js';
2
2
  export class Ratchet2d {
3
3
  constructor() { }
4
4
  static translateToOriginVector(points) {
@@ -0,0 +1,117 @@
1
+ import { Ratchet2d } from './ratchet-2d.js';
2
+ describe('#ratchet2d', function () {
3
+ it('should check for valid planes', function () {
4
+ expect(Ratchet2d.validPlane(null)).toEqual(false);
5
+ expect(Ratchet2d.validPlane({ width: null, height: null })).toEqual(false);
6
+ expect(Ratchet2d.validPlane({ width: 0, height: null })).toEqual(false);
7
+ expect(Ratchet2d.validPlane({ width: 0, height: 2 })).toEqual(false);
8
+ expect(Ratchet2d.validPlane({ width: 1, height: 7 })).toEqual(true);
9
+ });
10
+ it('should check for valid lines', function () {
11
+ expect(Ratchet2d.validLine(null)).toEqual(false);
12
+ expect(Ratchet2d.validLine({ p1: null, p2: null })).toEqual(false);
13
+ expect(Ratchet2d.validLine({ p1: { x: null, y: 0 }, p2: null })).toEqual(false);
14
+ expect(Ratchet2d.validLine({ p1: { x: 0, y: 0 }, p2: { x: 27, y: null } })).toEqual(false);
15
+ expect(Ratchet2d.validLine({ p1: { x: 0, y: 0 }, p2: { x: 27, y: 0 } })).toEqual(true);
16
+ expect(Ratchet2d.validLine({ p1: { x: 1, y: 0 }, p2: { x: 1, y: 0 } })).toEqual(false);
17
+ expect(Ratchet2d.validLine({ p1: { x: 0, y: 0 }, p2: { x: 27, y: 13 } })).toEqual(true);
18
+ });
19
+ it('should transform points from one plane to another (scale)', function () {
20
+ const plane1 = { height: 10, width: 10 };
21
+ const plane2 = { height: 100, width: 50 };
22
+ const p1 = { x: 5, y: 5 };
23
+ const out1 = Ratchet2d.transformPointToNewPlane(p1, plane1, plane2);
24
+ const out2 = Ratchet2d.transformPointToNewPlane(out1, plane2, plane1);
25
+ expect(out1.x).toEqual(25);
26
+ expect(out1.y).toEqual(50);
27
+ expect(out2.x).toEqual(p1.x);
28
+ expect(out2.y).toEqual(p1.y);
29
+ });
30
+ it('should transform points from one plane to another (mirror)', function () {
31
+ const plane1 = { height: 10, width: 10 };
32
+ const plane2 = { height: 10, width: 10, rightToLeft: true, topToBottom: true };
33
+ const p1 = { x: 2, y: 8 };
34
+ const out1 = Ratchet2d.transformPointToNewPlane(p1, plane1, plane2);
35
+ const out2 = Ratchet2d.transformPointToNewPlane(out1, plane2, plane1);
36
+ expect(out1.x).toEqual(7);
37
+ expect(out1.y).toEqual(1);
38
+ expect(out2.x).toEqual(p1.x);
39
+ expect(out2.y).toEqual(p1.y);
40
+ });
41
+ it('should check for containment', function () {
42
+ const plane = {
43
+ width: 100,
44
+ height: 100,
45
+ };
46
+ expect(Ratchet2d.planeContainsPoint({ x: -1, y: 10 }, plane)).toEqual(false);
47
+ expect(Ratchet2d.planeContainsPoint({ x: 101, y: 10 }, plane)).toEqual(false);
48
+ expect(Ratchet2d.planeContainsPoint({ x: 1, y: -10 }, plane)).toEqual(false);
49
+ expect(Ratchet2d.planeContainsPoint({ x: 10, y: 101 }, plane)).toEqual(false);
50
+ expect(Ratchet2d.planeContainsPoint({ x: 10, y: 100 }, plane)).toEqual(false);
51
+ expect(Ratchet2d.planeContainsPoint({ x: 1, y: 10 }, plane)).toEqual(true);
52
+ expect(Ratchet2d.planeContainsPoint({ x: 10, y: 10 }, plane)).toEqual(true);
53
+ expect(Ratchet2d.planeContainsPoints([
54
+ { x: 10, y: 10 },
55
+ { x: 100, y: 10 },
56
+ ], plane)).toEqual(false);
57
+ expect(Ratchet2d.planeContainsPoints([
58
+ { x: 10, y: 10 },
59
+ { x: 11, y: 10 },
60
+ ], plane)).toEqual(true);
61
+ expect(Ratchet2d.planeContainsLine({
62
+ p1: { x: 10, y: 10 },
63
+ p2: { x: 100, y: 10 },
64
+ }, plane)).toEqual(false);
65
+ expect(Ratchet2d.planeContainsLine({
66
+ p1: { x: 10, y: 10 },
67
+ p2: { x: 11, y: 10 },
68
+ }, plane)).toEqual(true);
69
+ });
70
+ it('should fit input to curve', function () {
71
+ const curve = [
72
+ { x: 0, y: 50 },
73
+ { x: 0.5, y: 50 },
74
+ { x: 0.8, y: 60 },
75
+ { x: 1, y: 70 },
76
+ { x: 1.2, y: 80 },
77
+ { x: 1.5, y: 90 },
78
+ { x: 1.6, y: 91 },
79
+ { x: 1.7, y: 92 },
80
+ { x: 1.8, y: 93 },
81
+ { x: 1.9, y: 94 },
82
+ { x: 2, y: 95 },
83
+ {
84
+ x: 3,
85
+ y: 98,
86
+ },
87
+ { x: 4, y: 99 },
88
+ { x: 5, y: 100 },
89
+ ];
90
+ expect(Ratchet2d.fitCurve(curve, -1)).toEqual(50);
91
+ expect(Ratchet2d.fitCurve(curve, 0)).toEqual(50);
92
+ expect(Ratchet2d.fitCurve(curve, 0.3)).toEqual(50);
93
+ expect(Ratchet2d.fitCurve(curve, 0.5)).toEqual(50);
94
+ expect(Ratchet2d.fitCurve(curve, 0.8)).toEqual(60);
95
+ expect(Ratchet2d.fitCurve(curve, 1)).toEqual(70);
96
+ expect(Ratchet2d.fitCurve(curve, 5)).toEqual(100);
97
+ expect(Ratchet2d.fitCurve(curve, 6)).toEqual(100);
98
+ expect(Ratchet2d.fitCurve(curve, 1.65)).toEqual(91.5);
99
+ });
100
+ it('rotate about origin', function () {
101
+ const points = [
102
+ { x: 1, y: 0 },
103
+ { x: 2, y: 1 },
104
+ { x: 3, y: 2 },
105
+ { x: 4, y: 3 },
106
+ { x: 4, y: 1 },
107
+ { x: 6, y: 1 },
108
+ ];
109
+ const r1 = Ratchet2d.rotateRightAboutOrigin90Degrees(points);
110
+ expect(r1.length).toEqual(6);
111
+ const r3 = Ratchet2d.rotateRightAboutOrigin90Degrees(points, 3);
112
+ const r2 = Ratchet2d.rotateRightAboutOrigin90Degrees(points, 4);
113
+ expect(r2.length).toEqual(6);
114
+ expect(r2[0].x).toEqual(points[0].x);
115
+ expect(r2[0].y).toEqual(points[0].y);
116
+ });
117
+ });
@@ -1,4 +1,4 @@
1
- import { BuildInformation } from './build-information';
1
+ import { BuildInformation } from './build-information.js';
2
2
  export declare class RatchetInfo {
3
3
  private constructor();
4
4
  static buildInformation(): BuildInformation;
@@ -1,7 +1,4 @@
1
- import { HistogramEntry } from './histogram-entry';
2
- /**
3
- * Implements a simple histogram (for each object, how many times does it appear)
4
- */
1
+ import { HistogramEntry } from './histogram-entry.js';
5
2
  export declare class Histogram<T> {
6
3
  private entries;
7
4
  update(val: T, addValue?: number): void;
@@ -1,7 +1,5 @@
1
1
  export class Histogram {
2
- constructor() {
3
- this.entries = [];
4
- }
2
+ entries = [];
5
3
  update(val, addValue = 1) {
6
4
  if (val) {
7
5
  const entry = this.entries.find((e) => e.item === val);
@@ -0,0 +1,19 @@
1
+ import { Histogram } from './histogram.js';
2
+ describe('#histogram', function () {
3
+ it('should count the values correctly', function () {
4
+ const histogram = new Histogram();
5
+ histogram.update('a');
6
+ histogram.update('a');
7
+ histogram.update('b');
8
+ histogram.update('c');
9
+ expect(histogram.getTotalCount()).toEqual(4);
10
+ expect(histogram.countForValue('a')).toEqual(2);
11
+ expect(histogram.countForValue('b')).toEqual(1);
12
+ expect(histogram.countForValue('c')).toEqual(1);
13
+ expect(histogram.countForValue('d')).toEqual(0);
14
+ expect(histogram.percentForValue('a')).toEqual(0.5);
15
+ expect(histogram.percentForValue('b')).toEqual(0.25);
16
+ expect(histogram.percentForValue('c')).toEqual(0.25);
17
+ expect(histogram.percentForValue('d')).toEqual(0);
18
+ });
19
+ });
@@ -0,0 +1,6 @@
1
+ import { JwtTokenBase } from './jwt-token-base.js';
2
+ export interface CommonJwtToken<T> extends JwtTokenBase {
3
+ user: T;
4
+ proxy: T;
5
+ roles: string[];
6
+ }
@@ -1,9 +1,6 @@
1
- import { JwtTokenBase } from './jwt-token-base';
2
- import { LoggerLevelName } from '../logger/logger-level-name';
3
- import { ExpiredJwtHandling } from './expired-jwt-handling';
4
- /**
5
- * Classes implementing this interface have Functions to help with creating and decoding JWTs
6
- */
1
+ import { JwtTokenBase } from './jwt-token-base.js';
2
+ import { LoggerLevelName } from '../logger/logger-level-name.js';
3
+ import { ExpiredJwtHandling } from './expired-jwt-handling.js';
7
4
  export interface JwtRatchetLike {
8
5
  get encryptionKeyPromise(): Promise<string | string[]>;
9
6
  get decryptKeysPromise(): Promise<string[]>;
@@ -1,16 +1,7 @@
1
- import { JwtTokenBase } from './jwt-token-base';
2
- import { LoggerLevelName } from '../logger/logger-level-name';
3
- import { ExpiredJwtHandling } from './expired-jwt-handling';
4
- import { JwtRatchetLike } from './jwt-ratchet-like';
5
- /**
6
- * Functions to help with creating and decoding JWTs
7
- *
8
- * JWTRatchet accepts promises for its inputs for the simple reason that best practice dictates that the keys
9
- * should never be in the code, which means it is likely somewhere else. That MIGHT be somewhere synchronous
10
- * like an environmental variable, but it could very likely be someplace remote like a secure key store. By
11
- * accepting promises here, we make it easy to do JwtRatchet construction in a place (like an IOT container)
12
- * that itself must be synchronous
13
- */
1
+ import { JwtTokenBase } from './jwt-token-base.js';
2
+ import { LoggerLevelName } from '../logger/logger-level-name.js';
3
+ import { ExpiredJwtHandling } from './expired-jwt-handling.js';
4
+ import { JwtRatchetLike } from './jwt-ratchet-like.js';
14
5
  export declare class JwtRatchet implements JwtRatchetLike {
15
6
  private _encryptionKeyPromise;
16
7
  private _decryptKeysPromise?;
@@ -1,11 +1,17 @@
1
1
  import jwt from 'jsonwebtoken';
2
- import { RequireRatchet } from '../lang/require-ratchet';
3
- import { Logger } from '../logger/logger';
4
- import { StringRatchet } from '../lang/string-ratchet';
5
- import { DurationRatchet } from '../lang/duration-ratchet';
6
- import { LoggerLevelName } from '../logger/logger-level-name';
7
- import { ExpiredJwtHandling } from './expired-jwt-handling';
2
+ import { RequireRatchet } from '../lang/require-ratchet.js';
3
+ import { Logger } from '../logger/logger.js';
4
+ import { StringRatchet } from '../lang/string-ratchet.js';
5
+ import { DurationRatchet } from '../lang/duration-ratchet.js';
6
+ import { LoggerLevelName } from '../logger/logger-level-name.js';
7
+ import { ExpiredJwtHandling } from './expired-jwt-handling.js';
8
8
  export class JwtRatchet {
9
+ _encryptionKeyPromise;
10
+ _decryptKeysPromise;
11
+ _jtiGenerator;
12
+ _decryptOnlyKeyUseLogLevel;
13
+ _parseFailureLogLevel;
14
+ static EXPIRED_FLAG_NAME = '__jwtServiceExpiredFlag';
9
15
  constructor(_encryptionKeyPromise, _decryptKeysPromise, _jtiGenerator = StringRatchet.createType4Guid, _decryptOnlyKeyUseLogLevel = LoggerLevelName.info, _parseFailureLogLevel = LoggerLevelName.debug) {
10
16
  this._encryptionKeyPromise = _encryptionKeyPromise;
11
17
  this._decryptKeysPromise = _decryptKeysPromise;
@@ -156,4 +162,3 @@ export class JwtRatchet {
156
162
  }
157
163
  }
158
164
  }
159
- JwtRatchet.EXPIRED_FLAG_NAME = '__jwtServiceExpiredFlag';
@@ -0,0 +1,49 @@
1
+ import { JwtRatchet } from './jwt-ratchet.js';
2
+ import { ExpiredJwtHandling } from './expired-jwt-handling.js';
3
+ describe('#jwtRatchet', function () {
4
+ it('should test expiration flag for a token with millisecond expiration', async () => {
5
+ const jwt = new JwtRatchet(Promise.resolve('test1234'), Promise.resolve([]));
6
+ const token1 = await jwt.createTokenString({ test: 1, exp: Date.now() - 100 }, null);
7
+ const output = await jwt.decodeToken(token1, ExpiredJwtHandling.ADD_FLAG);
8
+ expect(output).not.toBeNull();
9
+ expect(JwtRatchet.hasExpiredFlag(output)).toBeTruthy();
10
+ });
11
+ it('should test expiration calculation for a token', async () => {
12
+ const jwt = new JwtRatchet(Promise.resolve('test1234'), Promise.resolve([]));
13
+ const token1 = await jwt.createTokenString({ test: 1 }, 120);
14
+ const output = await JwtRatchet.secondsRemainingUntilExpiration(token1);
15
+ expect(output).not.toBeNull();
16
+ expect(output).toBeLessThan(121);
17
+ expect(output).toBeGreaterThan(115);
18
+ });
19
+ it('should test round-trip for a token', async () => {
20
+ const jwt = new JwtRatchet(Promise.resolve('test1234'), Promise.resolve([]));
21
+ const token1 = await jwt.createTokenString({ test: 1 }, 120);
22
+ const output = await jwt.decodeToken(token1);
23
+ expect(output).not.toBeNull();
24
+ expect(output['test']).toEqual(1);
25
+ });
26
+ it('should test round-trip for a token with array enc keys', async () => {
27
+ const jwt = new JwtRatchet(Promise.resolve(['test1234', 'test5678']), Promise.resolve([]));
28
+ const token1 = await jwt.createTokenString({ test: 1 }, 120);
29
+ const token2 = await jwt.createTokenString({ test: 1 }, 120);
30
+ const token3 = await jwt.createTokenString({ test: 1 }, 120);
31
+ const output1 = await jwt.decodeToken(token1);
32
+ const output2 = await jwt.decodeToken(token2);
33
+ const output3 = await jwt.decodeToken(token3);
34
+ expect(output1).not.toBeNull();
35
+ expect(output1['test']).toEqual(1);
36
+ expect(output2).not.toBeNull();
37
+ expect(output2['test']).toEqual(1);
38
+ expect(output3).not.toBeNull();
39
+ expect(output3['test']).toEqual(1);
40
+ });
41
+ it('should decode with a decode key', async () => {
42
+ const jwtOld = new JwtRatchet(Promise.resolve('oldKey'), Promise.resolve([]));
43
+ const jwtNew = new JwtRatchet(Promise.resolve('newKey'), Promise.resolve(['oldKey']));
44
+ const token1 = await jwtOld.createTokenString({ test: 1 }, 120);
45
+ const output = await jwtNew.decodeToken(token1);
46
+ expect(output).not.toBeNull();
47
+ expect(output['test']).toEqual(1);
48
+ });
49
+ });
@@ -1,7 +1,3 @@
1
- /**
2
- * Defines the common fields expected in a JWT token according to the RFC
3
- * https://www.rfc-editor.org/rfc/rfc7519.html
4
- */
5
1
  export interface JwtTokenBase {
6
2
  iss?: string;
7
3
  sub?: string;
@@ -0,0 +1,14 @@
1
+ export declare class ArrayRatchet {
2
+ static wrapElementsInArray(input: any[]): any[][];
3
+ static compareTwoArrays<T>(ar1: T[], ar2: T[], fn: ComparisonFunction<T>): MatchReport<T>;
4
+ static extractSubarrayFromSortedByNumberField<T>(input: T[], fieldDotPath: string, minInclusive: number, maxExclusive: number): T[];
5
+ static findSplit(input: any[], fieldDotPath: string, target: number): number;
6
+ }
7
+ export interface ComparisonFunction<T> {
8
+ (t1: T, t2: T): number;
9
+ }
10
+ export interface MatchReport<T> {
11
+ matching: T[];
12
+ setOneOnly: T[];
13
+ setTwoOnly: T[];
14
+ }
@@ -1,5 +1,5 @@
1
- import { RequireRatchet } from './require-ratchet';
2
- import { MapRatchet } from './map-ratchet';
1
+ import { RequireRatchet } from './require-ratchet.js';
2
+ import { MapRatchet } from './map-ratchet.js';
3
3
  export class ArrayRatchet {
4
4
  static wrapElementsInArray(input) {
5
5
  return input.map((i) => [i]);
@@ -0,0 +1,68 @@
1
+ import { ArrayRatchet } from './array-ratchet.js';
2
+ const sortedArr = [
3
+ {
4
+ n: 'test1',
5
+ v: 1,
6
+ },
7
+ {
8
+ n: 'test1',
9
+ v: 2,
10
+ },
11
+ {
12
+ n: 'test1',
13
+ v: 4,
14
+ },
15
+ {
16
+ n: 'test1',
17
+ v: 4,
18
+ },
19
+ {
20
+ n: 'test1',
21
+ v: 7,
22
+ },
23
+ {
24
+ n: 'test1',
25
+ v: 12,
26
+ },
27
+ {
28
+ n: 'test1',
29
+ v: 25,
30
+ },
31
+ {
32
+ n: 'test1',
33
+ v: 30,
34
+ },
35
+ ];
36
+ describe('#extractSubarrayFromSortedByNumberField', function () {
37
+ it('should extract the subarray', function () {
38
+ const subArr1 = ArrayRatchet.extractSubarrayFromSortedByNumberField(sortedArr, 'v', 5, 14);
39
+ expect(subArr1.length).toEqual(2);
40
+ const subArr2 = ArrayRatchet.extractSubarrayFromSortedByNumberField(sortedArr, 'v', null, 4);
41
+ expect(subArr2.length).toEqual(4);
42
+ const subArr3 = ArrayRatchet.extractSubarrayFromSortedByNumberField(sortedArr, 'v', 7, null);
43
+ expect(subArr3.length).toEqual(4);
44
+ });
45
+ });
46
+ describe('#compareTwoArrays', function () {
47
+ it('should create a match report', function () {
48
+ const arr1 = ['a', 'b', 'c'];
49
+ const arr2 = ['a', 'e', 'i', 'o', 'u'];
50
+ const report = ArrayRatchet.compareTwoArrays(arr1, arr2, (a, b) => a.localeCompare(b));
51
+ expect(report).toBeTruthy();
52
+ expect(report.setOneOnly.length).toEqual(2);
53
+ expect(report.setTwoOnly.length).toEqual(4);
54
+ expect(report.matching.length).toEqual(1);
55
+ });
56
+ });
57
+ describe('#findSplit', function () {
58
+ it('should find the split', function () {
59
+ const split10 = ArrayRatchet.findSplit(sortedArr, 'v', 10);
60
+ const split4 = ArrayRatchet.findSplit(sortedArr, 'v', 4);
61
+ const split0 = ArrayRatchet.findSplit(sortedArr, 'v', 0);
62
+ const split32 = ArrayRatchet.findSplit(sortedArr, 'v', 32);
63
+ expect(split10).toEqual(4);
64
+ expect(split4).toEqual(3);
65
+ expect(split0).toEqual(null);
66
+ expect(split32).toEqual(7);
67
+ });
68
+ });
@@ -1,4 +1,4 @@
1
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  export declare class Base64Ratchet {
3
3
  static safeObjectToBase64JSON(input: any): any;
4
4
  static safeBase64JSONParse(input: string): any;
@@ -1,4 +1,4 @@
1
- import { Logger } from '../logger/logger';
1
+ import { Logger } from '../logger/logger.js';
2
2
  export class Base64Ratchet {
3
3
  static safeObjectToBase64JSON(input) {
4
4
  return !!input ? Base64Ratchet.generateBase64VersionOfString(JSON.stringify(input)) : null;
@@ -0,0 +1,28 @@
1
+ import { Base64Ratchet } from './base64-ratchet.js';
2
+ describe('#base64', function () {
3
+ it('should parse a buffer from base64', function () {
4
+ const result = Base64Ratchet.base64StringToBuffer('dGVzdHVzZXI6dGVzdHBhc3M=');
5
+ expect(result).toBeTruthy();
6
+ expect(result.length).toEqual(17);
7
+ });
8
+ it('should parse a string from base64', function () {
9
+ const result = Base64Ratchet.base64StringToString('dGVzdHVzZXI6dGVzdHBhc3M=');
10
+ expect(result).toBeTruthy();
11
+ expect(result.length).toEqual(17);
12
+ });
13
+ it('should round-trip a string', function () {
14
+ const testString = 'teststring';
15
+ const enc = Base64Ratchet.generateBase64VersionOfString(testString);
16
+ const result = Base64Ratchet.base64StringToString(enc);
17
+ expect(result).toBeTruthy();
18
+ expect(result).toEqual(testString);
19
+ });
20
+ it('should round-trip an object', function () {
21
+ const testOb = { a: 'teststring', b: 27 };
22
+ const enc = Base64Ratchet.safeObjectToBase64JSON(testOb);
23
+ const result = Base64Ratchet.safeBase64JSONParse(enc);
24
+ expect(result).toBeTruthy();
25
+ expect(result.a).toEqual(testOb.a);
26
+ expect(result.b).toEqual(testOb.b);
27
+ });
28
+ });
@@ -1,4 +1,4 @@
1
- import { NumberRatchet } from './number-ratchet';
1
+ import { NumberRatchet } from './number-ratchet.js';
2
2
  export class BooleanRatchet {
3
3
  static allTrue(vals, emptyArraysReturn = false) {
4
4
  let rval = null;
@@ -0,0 +1,81 @@
1
+ import { BooleanRatchet } from './boolean-ratchet.js';
2
+ import { NumberRatchet } from './number-ratchet.js';
3
+ describe('#parseBool', function () {
4
+ it('should check all true', function () {
5
+ expect(BooleanRatchet.allTrue(null)).toEqual(false);
6
+ expect(BooleanRatchet.allTrue([])).toEqual(false);
7
+ expect(BooleanRatchet.allTrue([], true)).toEqual(true);
8
+ expect(BooleanRatchet.allTrue([true])).toEqual(true);
9
+ expect(BooleanRatchet.allTrue([true, true])).toEqual(true);
10
+ expect(BooleanRatchet.allTrue([true, false, true])).toEqual(false);
11
+ expect(BooleanRatchet.allTrue([false])).toEqual(false);
12
+ expect(BooleanRatchet.allTrue([false, false])).toEqual(false);
13
+ });
14
+ it('should check any true', function () {
15
+ expect(BooleanRatchet.anyTrue(null)).toEqual(false);
16
+ expect(BooleanRatchet.anyTrue([])).toEqual(false);
17
+ expect(BooleanRatchet.anyTrue([], true)).toEqual(true);
18
+ expect(BooleanRatchet.anyTrue([true])).toEqual(true);
19
+ expect(BooleanRatchet.anyTrue([true, true])).toEqual(true);
20
+ expect(BooleanRatchet.anyTrue([true, false, true])).toEqual(true);
21
+ expect(BooleanRatchet.anyTrue([false])).toEqual(false);
22
+ expect(BooleanRatchet.anyTrue([false, false])).toEqual(false);
23
+ });
24
+ it('should xxx', function () {
25
+ const val = 'false';
26
+ const r1 = BooleanRatchet.parseBool(val);
27
+ const r2 = BooleanRatchet.intToBool(val);
28
+ const result = BooleanRatchet.parseBool(val) || BooleanRatchet.intToBool(NumberRatchet.safeNumber(val));
29
+ expect(result).toEqual(false);
30
+ });
31
+ it('should parse the string true as true', function () {
32
+ const result = BooleanRatchet.parseBool('true');
33
+ expect(result).toEqual(true);
34
+ });
35
+ it('should parse the string TRUE as true', function () {
36
+ const result = BooleanRatchet.parseBool('TRUE');
37
+ expect(result).toEqual(true);
38
+ });
39
+ it('should parse the boolean true as true', function () {
40
+ const result = BooleanRatchet.parseBool(true);
41
+ expect(result).toEqual(true);
42
+ });
43
+ it('should parse the empty string as false', function () {
44
+ const result = BooleanRatchet.parseBool('');
45
+ expect(result).toEqual(false);
46
+ });
47
+ it('should parse null as false', function () {
48
+ const result = BooleanRatchet.parseBool(null);
49
+ expect(result).toEqual(false);
50
+ });
51
+ it('should parse "asdf" as false', function () {
52
+ const result = BooleanRatchet.parseBool('asdf');
53
+ expect(result).toEqual(false);
54
+ });
55
+ });
56
+ describe('#intToBool', function () {
57
+ it('should parse null as false', function () {
58
+ const result = BooleanRatchet.intToBool(null);
59
+ expect(result).toEqual(false);
60
+ });
61
+ it('should parse 0 as false', function () {
62
+ const result = BooleanRatchet.intToBool(0);
63
+ expect(result).toEqual(false);
64
+ });
65
+ it('should parse "0" as false', function () {
66
+ const result = BooleanRatchet.intToBool('0');
67
+ expect(result).toEqual(false);
68
+ });
69
+ it('should parse 1 as true', function () {
70
+ const result = BooleanRatchet.intToBool(1);
71
+ expect(result).toEqual(true);
72
+ });
73
+ it('should parse "1" as true', function () {
74
+ const result = BooleanRatchet.intToBool('1');
75
+ expect(result).toEqual(true);
76
+ });
77
+ it('should parse "2" as true', function () {
78
+ const result = BooleanRatchet.intToBool('2');
79
+ expect(result).toEqual(true);
80
+ });
81
+ });
@@ -1,5 +1,4 @@
1
- /** Classes implementing this interface return a timestamp of their last success **/
2
- import { LastSuccessProvider } from './last-success-provider';
1
+ import { LastSuccessProvider } from './last-success-provider.js';
3
2
  export declare class CompositeLastSuccessProvider implements LastSuccessProvider {
4
3
  private sources;
5
4
  private mostRecent;
@@ -1,4 +1,6 @@
1
1
  export class CompositeLastSuccessProvider {
2
+ sources;
3
+ mostRecent;
2
4
  constructor(src, mostRecentSrc = true) {
3
5
  if (!src || src.length == 0) {
4
6
  throw Error('Cannot create composite provider with null/empty sources');
@@ -0,0 +1,26 @@
1
+ import { CompositeLastSuccessProvider } from './composite-last-success-provider.js';
2
+ describe('#lastSuccess', function () {
3
+ const last5 = {
4
+ lastSuccess() {
5
+ return 5;
6
+ },
7
+ };
8
+ const last4 = {
9
+ lastSuccess() {
10
+ return 4;
11
+ },
12
+ };
13
+ const lastNull = {
14
+ lastSuccess() {
15
+ return null;
16
+ },
17
+ };
18
+ it('should return 4 as last (min)', function () {
19
+ const result = new CompositeLastSuccessProvider([last5, last4, lastNull], false).lastSuccess();
20
+ expect(result).toEqual(4);
21
+ });
22
+ it('should return 5 as last (max)', function () {
23
+ const result = new CompositeLastSuccessProvider([last5, last4, lastNull], true).lastSuccess();
24
+ expect(result).toEqual(5);
25
+ });
26
+ });
@@ -1,5 +1,10 @@
1
1
  import { DateTime } from 'luxon';
2
2
  export class DateRatchet {
3
+ static COMMON_US_DATE_FORMAT = 'MM/dd/yyyy';
4
+ static DEFAULT_DATE_FORMAT = 'yyyy-MM-dd';
5
+ static FULL_DATE_FORMAT = 'yyyy-MM-dd_HH_mm_ss';
6
+ static PACIFIC_TIME_ZONE = 'America/Los_Angeles';
7
+ static UTC_TIME_ZONE = 'etc/UTC';
3
8
  static formatFullDate(input) {
4
9
  return DateTime.fromJSDate(input).toFormat(DateRatchet.FULL_DATE_FORMAT);
5
10
  }
@@ -22,8 +27,3 @@ export class DateRatchet {
22
27
  return rval;
23
28
  }
24
29
  }
25
- DateRatchet.COMMON_US_DATE_FORMAT = 'MM/dd/yyyy';
26
- DateRatchet.DEFAULT_DATE_FORMAT = 'yyyy-MM-dd';
27
- DateRatchet.FULL_DATE_FORMAT = 'yyyy-MM-dd_HH_mm_ss';
28
- DateRatchet.PACIFIC_TIME_ZONE = 'America/Los_Angeles';
29
- DateRatchet.UTC_TIME_ZONE = 'etc/UTC';
@@ -0,0 +1,21 @@
1
+ import { DateRatchet } from './date-ratchet.js';
2
+ describe('#dateRatchet', function () {
3
+ it('should parse my common date format', function () {
4
+ const dt = DateRatchet.parseDefaultDate('1976-07-04');
5
+ expect(dt.getFullYear()).toEqual(1976);
6
+ expect(dt.getMonth()).toEqual(6);
7
+ expect(dt.getDate()).toEqual(4);
8
+ });
9
+ it('should parse us with slashes', function () {
10
+ const dt = DateRatchet.parseCommonUsDate('07/04/1976');
11
+ expect(dt.getFullYear()).toEqual(1976);
12
+ expect(dt.getMonth()).toEqual(6);
13
+ expect(dt.getDate()).toEqual(4);
14
+ });
15
+ it('should parse us with dashes', function () {
16
+ const dt = DateRatchet.parseCommonUsDate('07-04-1976');
17
+ expect(dt.getFullYear()).toEqual(1976);
18
+ expect(dt.getMonth()).toEqual(6);
19
+ expect(dt.getDate()).toEqual(4);
20
+ });
21
+ });
@@ -1,5 +1,5 @@
1
1
  import { DateTime } from 'luxon';
2
- import { NumberRatchet } from './number-ratchet';
2
+ import { NumberRatchet } from './number-ratchet.js';
3
3
  export class DurationRatchet {
4
4
  static formatMsDuration(ms, includeMS = false) {
5
5
  const rem_ms = Math.floor(ms % 1000);