@vbarbarosh/node-helpers 3.75.0 → 3.76.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/README.md +29 -3
  2. package/dist/browser.js +1 -2504
  3. package/dist/index.html +1 -1
  4. package/package.json +33 -12
  5. package/src/HeartbeatServer.js +24 -3
  6. package/src/HeartbeatServer.md +33 -0
  7. package/src/array_chunk.js +1 -1
  8. package/src/array_chunk.md +8 -0
  9. package/src/array_chunk_balanced.md +14 -0
  10. package/src/array_fps.md +12 -0
  11. package/src/array_gcd.js +4 -2
  12. package/src/array_gcd.md +2 -1
  13. package/src/array_group.js +3 -3
  14. package/src/array_group.md +14 -0
  15. package/src/array_group_map.js +3 -3
  16. package/src/array_group_map.md +13 -0
  17. package/src/array_index.js +2 -2
  18. package/src/array_index.md +9 -0
  19. package/src/array_lcm.js +4 -2
  20. package/src/array_lcm.md +2 -1
  21. package/src/array_max.js +11 -4
  22. package/src/array_max.md +1 -1
  23. package/src/array_min.js +11 -4
  24. package/src/array_min.md +1 -1
  25. package/src/array_permutations.js +4 -0
  26. package/src/array_permutations.md +13 -0
  27. package/src/array_sort.js +7 -2
  28. package/src/array_sort.md +13 -0
  29. package/src/array_sort_other.js +8 -5
  30. package/src/array_sort_other.md +11 -0
  31. package/src/array_sum.js +2 -2
  32. package/src/array_sum.md +8 -0
  33. package/src/array_unique.js +2 -2
  34. package/src/array_unique_last.js +2 -2
  35. package/src/assert_valid_expires_at.md +10 -0
  36. package/src/clamp.md +9 -0
  37. package/src/cli-apps/watchdog.js +5 -0
  38. package/src/cli.js +3 -1
  39. package/src/cli.md +15 -0
  40. package/src/const_stream.md +7 -0
  41. package/src/const_type.md +5 -0
  42. package/src/countdown.js +22 -5
  43. package/src/countdown.md +21 -0
  44. package/src/crypto_decrypt_aes256.md +13 -0
  45. package/src/crypto_encrypt_aes256.md +13 -0
  46. package/src/crypto_hash_md5.md +10 -0
  47. package/src/crypto_hash_sha256.md +10 -0
  48. package/src/crypto_hmac_sha256.md +11 -0
  49. package/src/date_add_hours.md +8 -0
  50. package/src/date_add_milliseconds.md +4 -0
  51. package/src/date_add_minutes.md +4 -0
  52. package/src/date_add_months.md +13 -0
  53. package/src/date_add_seconds.md +4 -0
  54. package/src/date_diff_seconds.md +4 -0
  55. package/src/date_is_leap_year.md +9 -0
  56. package/src/escape_content_disposition.js +6 -3
  57. package/src/escape_content_disposition.md +13 -0
  58. package/src/escape_regexp.md +7 -0
  59. package/src/eta.js +7 -1
  60. package/src/eta.md +18 -0
  61. package/src/factorize_ms.js +3 -0
  62. package/src/factorize_ms.md +10 -0
  63. package/src/fastdl.js +14 -3
  64. package/src/fcmp_dates.md +12 -0
  65. package/src/fcmp_default.js +7 -0
  66. package/src/fcmp_default.md +29 -0
  67. package/src/fcmp_default_desc.js +4 -7
  68. package/src/fcmp_default_desc.md +10 -0
  69. package/src/fcmp_from_spec.md +13 -0
  70. package/src/fcmp_numbers.md +11 -0
  71. package/src/fcmp_tuples.md +17 -0
  72. package/src/fcmp_utf8_bin.md +14 -0
  73. package/src/fcmp_utf8_ci.md +14 -0
  74. package/src/fcmp_utf8_cs.md +15 -0
  75. package/src/fcmp_utf8_natural_bin.js +38 -0
  76. package/src/fcmp_utf8_natural_bin.md +8 -0
  77. package/src/fcmp_utf8_natural_ci.md +13 -0
  78. package/src/fcmp_utf8_natural_cs.md +13 -0
  79. package/src/fcmpx.md +26 -9
  80. package/src/filter1_from_spec.js +3 -3
  81. package/src/format_bytes.md +15 -0
  82. package/src/format_date.md +7 -0
  83. package/src/format_date_fs.md +7 -0
  84. package/src/format_date_human.md +6 -0
  85. package/src/format_date_ymd.md +6 -0
  86. package/src/format_error_report.js +3 -3
  87. package/src/format_error_report.md +12 -0
  88. package/src/format_kilo.md +13 -0
  89. package/src/format_ms.js +3 -2
  90. package/src/format_ms.md +12 -0
  91. package/src/format_ms2.js +6 -3
  92. package/src/format_ms2.md +12 -0
  93. package/src/format_ms3.js +3 -2
  94. package/src/format_ms3.md +12 -0
  95. package/src/format_percents.md +10 -0
  96. package/src/format_progress_bytes.md +13 -0
  97. package/src/format_progress_kilo.md +10 -0
  98. package/src/format_seconds.md +11 -0
  99. package/src/format_thousands.md +9 -0
  100. package/src/fs_append.md +7 -0
  101. package/src/fs_append_json.md +8 -0
  102. package/src/fs_append_utf8.md +6 -0
  103. package/src/fs_assert_file_exists.md +3 -0
  104. package/src/fs_assert_file_readable.js +1 -1
  105. package/src/fs_assert_file_readable.md +3 -0
  106. package/src/fs_assert_file_socket.md +2 -0
  107. package/src/fs_copy.md +7 -0
  108. package/src/fs_copy_excl.md +2 -0
  109. package/src/fs_exists.md +6 -0
  110. package/src/fs_fclose.md +5 -0
  111. package/src/fs_fi.js +13 -1
  112. package/src/fs_fi.md +11 -0
  113. package/src/fs_file_md5.md +8 -0
  114. package/src/fs_find.md +7 -0
  115. package/src/fs_fopen.md +6 -0
  116. package/src/fs_fread.js +2 -2
  117. package/src/fs_fread.md +11 -0
  118. package/src/fs_fsize.md +2 -0
  119. package/src/fs_fstat.md +2 -0
  120. package/src/fs_fwrite.js +2 -2
  121. package/src/fs_fwrite.md +9 -0
  122. package/src/fs_list.md +5 -0
  123. package/src/fs_list_deep.md +5 -0
  124. package/src/fs_ls.md +2 -0
  125. package/src/fs_lsr.md +4 -0
  126. package/src/fs_lstat.md +3 -0
  127. package/src/fs_mkdir.md +3 -0
  128. package/src/fs_mkdirp.js +3 -30
  129. package/src/fs_mkdirp.md +7 -0
  130. package/src/fs_path_basename.md +2 -0
  131. package/src/fs_path_dirname.md +2 -0
  132. package/src/fs_path_extname.md +9 -0
  133. package/src/fs_path_join.md +2 -0
  134. package/src/fs_path_relative.md +2 -0
  135. package/src/fs_path_resolve.md +2 -0
  136. package/src/fs_path_tempdir.md +2 -0
  137. package/src/fs_path_untildify.md +8 -0
  138. package/src/fs_read.md +3 -0
  139. package/src/fs_read_buffer.md +5 -0
  140. package/src/fs_read_json.md +6 -0
  141. package/src/fs_read_lines.md +7 -0
  142. package/src/fs_read_stream.md +2 -0
  143. package/src/fs_read_utf8.md +5 -0
  144. package/src/fs_readdir.md +3 -0
  145. package/src/fs_readlink.md +6 -0
  146. package/src/fs_rename.md +6 -0
  147. package/src/fs_rm.md +4 -0
  148. package/src/fs_rmdir.md +3 -0
  149. package/src/fs_rmf.md +2 -0
  150. package/src/fs_rmrf.md +8 -0
  151. package/src/fs_sha256.js +16 -0
  152. package/src/fs_sha256.md +9 -0
  153. package/src/fs_size.js +2 -2
  154. package/src/fs_size.md +6 -0
  155. package/src/fs_stat.md +2 -0
  156. package/src/fs_tempdir.js +20 -5
  157. package/src/fs_touch.md +6 -0
  158. package/src/fs_walk.js +2 -2
  159. package/src/fs_walk.md +14 -0
  160. package/src/fs_write.md +3 -0
  161. package/src/fs_write_json.md +7 -0
  162. package/src/fs_write_stream.md +2 -0
  163. package/src/gettype.md +13 -0
  164. package/src/http_delete.md +11 -0
  165. package/src/http_get_blob.md +8 -0
  166. package/src/http_get_buffer.md +10 -0
  167. package/src/http_get_file.js +8 -8
  168. package/src/http_get_file.md +14 -0
  169. package/src/http_get_json.md +10 -0
  170. package/src/http_get_stream.md +14 -0
  171. package/src/http_get_stream_range.js +27 -9
  172. package/src/http_get_stream_range.md +22 -0
  173. package/src/http_get_utf8.md +9 -0
  174. package/src/http_head.md +9 -0
  175. package/src/http_patch_json.md +10 -0
  176. package/src/http_post_json.md +11 -0
  177. package/src/http_post_multipart.md +15 -0
  178. package/src/http_post_urlencoded.md +11 -0
  179. package/src/http_put_buffer.md +9 -0
  180. package/src/http_put_file.js +9 -6
  181. package/src/http_put_file.md +16 -0
  182. package/src/http_put_json.md +11 -0
  183. package/src/http_put_utf8.md +9 -0
  184. package/src/http_range_parse.js +6 -3
  185. package/src/http_range_parse.md +18 -0
  186. package/src/http_stream_range.js +35 -22
  187. package/src/http_stream_range.md +29 -0
  188. package/src/identity.md +2 -0
  189. package/src/ignore.md +2 -0
  190. package/src/json_stringify_safe.md +10 -0
  191. package/src/json_stringify_stable.md +9 -0
  192. package/src/logger.js +2 -3
  193. package/src/logger.md +15 -0
  194. package/src/make_progress.js +8 -5
  195. package/src/make_progress.md +20 -0
  196. package/src/math_gcd.js +2 -1
  197. package/src/mongo_stream_upsert.js +10 -3
  198. package/src/mongo_stream_upsert.md +17 -0
  199. package/src/mongo_stream_write.js +10 -3
  200. package/src/mongo_stream_write.md +16 -0
  201. package/src/msval.md +10 -0
  202. package/src/now_fs.md +7 -0
  203. package/src/now_human.md +6 -0
  204. package/src/object_defaults.md +11 -0
  205. package/src/object_schema.js +2 -1
  206. package/src/object_schema.md +12 -0
  207. package/src/object_walk_preorder.md +16 -0
  208. package/src/parallel.js +23 -10
  209. package/src/parse_bytes.js +4 -2
  210. package/src/parse_bytes.md +15 -0
  211. package/src/parse_hms.js +1 -1
  212. package/src/parse_http_content_range.js +9 -5
  213. package/src/parse_http_content_range.md +16 -0
  214. package/src/perf_end_human.md +10 -0
  215. package/src/perf_end_ms.md +8 -0
  216. package/src/perf_measure.md +10 -0
  217. package/src/perf_measure_human.md +8 -0
  218. package/src/perf_start.md +9 -0
  219. package/src/pgid_exists.md +6 -0
  220. package/src/pgid_kill_grace.js +1 -1
  221. package/src/pgid_kill_grace.md +15 -0
  222. package/src/pid_exists.md +5 -0
  223. package/src/pid_kill_grace.js +1 -1
  224. package/src/pid_kill_grace.md +14 -0
  225. package/src/plural.md +13 -0
  226. package/src/random_hex.md +9 -0
  227. package/src/random_int.md +8 -0
  228. package/src/range.js +4 -2
  229. package/src/range.md +2 -0
  230. package/src/redis_connect.js +1 -1
  231. package/src/redis_connect.md +10 -0
  232. package/src/redis_lshift.md +14 -0
  233. package/src/redis_poll.js +1 -0
  234. package/src/redis_poll.md +17 -0
  235. package/src/redis_poll_zshift_callback_rpush.js +1 -2
  236. package/src/redis_poll_zshift_callback_rpush.md +17 -0
  237. package/src/redis_poll_zshift_spawn_rpush.js +2 -1
  238. package/src/redis_poll_zshift_spawn_rpush.md +20 -0
  239. package/src/redis_zshift.md +14 -0
  240. package/src/round.js +7 -8
  241. package/src/round.md +15 -0
  242. package/src/sanitize_dash_name.md +13 -0
  243. package/src/sanitize_filename.md +9 -0
  244. package/src/sanitize_var_name.md +14 -0
  245. package/src/sftp_get_file_info.js +2 -2
  246. package/src/sftp_get_file_info.md +14 -0
  247. package/src/sftp_get_stream_range.js +32 -22
  248. package/src/sftp_get_stream_range.md +20 -0
  249. package/src/shell_curl_progress.js +2 -1
  250. package/src/shell_curl_progress.md +17 -0
  251. package/src/shell_lines.js +2 -2
  252. package/src/shell_lines.md +1 -1
  253. package/src/shell_spawn.js +7 -0
  254. package/src/shell_ytdlp_progress.js +2 -1
  255. package/src/shell_ytdlp_progress.md +17 -0
  256. package/src/str_camel_to_snake.md +11 -0
  257. package/src/str_parse_kv.md +11 -0
  258. package/src/stream_curl_progress.md +14 -0
  259. package/src/stream_data_ln.js +7 -1
  260. package/src/stream_discard.md +8 -0
  261. package/src/stream_group.md +3 -0
  262. package/src/stream_gunzip.md +7 -0
  263. package/src/stream_hash.md +10 -0
  264. package/src/stream_map.js +8 -1
  265. package/src/stream_map_parallel.js +9 -1
  266. package/src/stream_md5.md +9 -0
  267. package/src/stream_multiplex.js +11 -0
  268. package/src/stream_multiplex.md +16 -0
  269. package/src/stream_through.md +3 -0
  270. package/src/stream_transform.md +2 -0
  271. package/src/stream_xml_analyze.js +9 -1
  272. package/src/stream_xml_parse.js +9 -1
  273. package/src/stream_ytdlp_progress.js +1 -1
  274. package/src/stream_ytdlp_progress.md +18 -0
  275. package/src/strtr.js +15 -5
  276. package/src/strtr.md +11 -0
  277. package/src/urlclean.js +9 -2
  278. package/src/urlmod.js +22 -11
  279. package/src/urlmod.md +15 -3
  280. package/src/urlparts.md +17 -0
  281. package/src/wait_while.js +1 -1
  282. package/src/wait_while.md +1 -1
  283. package/src/HeartbeatServer.test.js +0 -31
  284. package/src/array_chunk.test.js +0 -24
  285. package/src/array_chunk_balanced.test.js +0 -37
  286. package/src/array_fps.test.js +0 -72
  287. package/src/array_gcd.test.js +0 -10
  288. package/src/array_index.test.js +0 -14
  289. package/src/array_lcm.test.js +0 -12
  290. package/src/array_max.test.js +0 -20
  291. package/src/array_min.test.js +0 -20
  292. package/src/array_permutations.test.js +0 -20
  293. package/src/array_sort.test.js +0 -85
  294. package/src/array_sort_other.test.js +0 -9
  295. package/src/array_sum.test.js +0 -11
  296. package/src/cli-apps/watchdog.d/connect_close.js +0 -17
  297. package/src/cli-apps/watchdog.d/connect_close2.js +0 -20
  298. package/src/cli-apps/watchdog.d/connect_close3.js +0 -25
  299. package/src/cli-apps/watchdog.d/connect_no_ping.js +0 -13
  300. package/src/cli-apps/watchdog.d/early_exit.js +0 -7
  301. package/src/cli-apps/watchdog.d/flood.js +0 -13
  302. package/src/cli-apps/watchdog.d/flood2.js +0 -15
  303. package/src/cli-apps/watchdog.d/hang.js +0 -8
  304. package/src/cli-apps/watchdog.d/huge_delay.js +0 -18
  305. package/src/cli-apps/watchdog.d/ignore_sigterm.js +0 -29
  306. package/src/cli-apps/watchdog.d/late_heartbeat.js +0 -21
  307. package/src/cli-apps/watchdog.d/my-exit-after-2-pings.js +0 -16
  308. package/src/cli-apps/watchdog.d/my-happy-path.js +0 -16
  309. package/src/cli-apps/watchdog.d/my-ignore-sigterm.js +0 -22
  310. package/src/cli-apps/watchdog.d/my-never-ping.js +0 -15
  311. package/src/cli-apps/watchdog.d/no_heartbeat.js +0 -5
  312. package/src/cli-apps/watchdog.d/ok.js +0 -17
  313. package/src/cli-apps/watchdog.d/quick-exit-after-2-pings.js +0 -15
  314. package/src/cli-apps/watchdog.d/quick-hang-after-1-ping.js +0 -15
  315. package/src/cli-apps/watchdog.d/spawn_children.js +0 -14
  316. package/src/cli-apps/watchdog.test.js +0 -48
  317. package/src/crypto_encrypt_aes256.test.js +0 -10
  318. package/src/crypto_hash_sha256.test.js +0 -10
  319. package/src/date_add_months.test.js +0 -40
  320. package/src/date_is_leap_year.test.js +0 -14
  321. package/src/escape_content_disposition.test.js +0 -22
  322. package/src/fcmp_from_spec.test.js +0 -91
  323. package/src/fcmpx.test.js +0 -173
  324. package/src/filter1_from_spec.test.js +0 -31
  325. package/src/format_bytes.test.js +0 -22
  326. package/src/format_error_report.d/src/1.js +0 -26
  327. package/src/format_error_report.d/src/2.js +0 -29
  328. package/src/format_kilo.test.js +0 -25
  329. package/src/format_ms.test.js +0 -33
  330. package/src/format_ms2.test.js +0 -33
  331. package/src/format_ms3.test.js +0 -33
  332. package/src/format_percents.test.js +0 -22
  333. package/src/format_progress_bytes.test.js +0 -19
  334. package/src/format_progress_kilo.test.js +0 -19
  335. package/src/format_seconds.test.js +0 -42
  336. package/src/format_thousands.test.js +0 -28
  337. package/src/fs_file_md5.test.js +0 -11
  338. package/src/fs_mkdirp.test.js +0 -24
  339. package/src/fs_path_extname.test.js +0 -22
  340. package/src/gettype.test.js +0 -27
  341. package/src/object_schema.test.js +0 -15
  342. package/src/object_walk_preorder.test.js +0 -17
  343. package/src/parallel.test.js +0 -11
  344. package/src/parse_bytes.test.js +0 -21
  345. package/src/parse_hms.test.js +0 -32
  346. package/src/parse_http_content_range.test.js +0 -14
  347. package/src/pid_kill_grace.d/ignore-sigterm-for-10ms.js +0 -33
  348. package/src/pid_kill_grace.d/ignore-sigterm.js +0 -22
  349. package/src/pid_kill_grace.test.js +0 -63
  350. package/src/ping_socket.test.js +0 -58
  351. package/src/plural.test.js +0 -20
  352. package/src/range.test.js +0 -41
  353. package/src/redis_lshift.test.js +0 -57
  354. package/src/redis_zshift.test.js +0 -58
  355. package/src/round.test.js +0 -56
  356. package/src/sanitize_dash_name.test.js +0 -59
  357. package/src/sanitize_var_name.test.js +0 -39
  358. package/src/shell_spawn.test.js +0 -30
  359. package/src/str_camel_to_snake.test.js +0 -17
  360. package/src/stream_curl_progress.d/basic +0 -3
  361. package/src/stream_curl_progress.d/basic.json +0 -42
  362. package/src/stream_curl_progress.test.js +0 -17
  363. package/src/stream_data_ln.test.js +0 -24
  364. package/src/stream_map_parallel.test.js +0 -26
  365. package/src/stream_multiplex.test.js +0 -67
  366. package/src/stream_strpbrk.test.js +0 -29
  367. package/src/urlclean.test.js +0 -18
  368. package/src/urlmod.test.js +0 -40
  369. package/src/urlparts.test.js +0 -294
@@ -1,37 +0,0 @@
1
- const array_chunk_balanced = require('./array_chunk_balanced');
2
- const assert = require('assert');
3
-
4
- describe('array_chunk_balanced', function () {
5
- it('should handle basic input', function () {
6
- assert.deepStrictEqual(array_chunk_balanced([1]), [[1]]);
7
- assert.deepStrictEqual(array_chunk_balanced([1,2]), [[1,2]]);
8
- assert.deepStrictEqual(array_chunk_balanced([1,2,3]), [[1,2,3]]);
9
- assert.deepStrictEqual(array_chunk_balanced([1,2,3,4,5], 3, 2), [[1,2,3],[4,5]]);
10
- assert.deepStrictEqual(array_chunk_balanced([1,2,3,4,5,6], 3, 2), [[1,2],[3,4],[5,6]]);
11
- assert.deepStrictEqual(array_chunk_balanced([1,2,3,4,5,6,7], 3, 2), [[1,2,3],[4,5],[6,7]]);
12
- assert.deepStrictEqual(array_chunk_balanced([1,2,3,4,5], 3, 3), [[1,2,3,4,5]]);
13
- assert.deepStrictEqual(array_chunk_balanced([1,2,3,4,5,6], 3, 3), [[1,2,3],[4,5,6]]);
14
- assert.deepStrictEqual(array_chunk_balanced([1,2,3,4,5,6,7], 3, 3), [[1,2,3,4],[5,6,7]]);
15
- assert.deepStrictEqual(array_chunk_balanced([1,2,3,4,5,6,7,8], 3, 3), [[1,2,3,4],[5,6,7,8]]);
16
- });
17
- it('edge: If an array is empty → returns []', function () {
18
- assert.deepStrictEqual(array_chunk_balanced([]), []);
19
- });
20
- it('edge: If there are too few items to satisfy `min_items_per_chunk`, even for 1 chunk, everything goes into a single chunk', function () {
21
- assert.deepStrictEqual(array_chunk_balanced([1,2,3], 5, 5), [[1,2,3]]);
22
- });
23
- it('should never produce more chunks than max_threads', function () {
24
- // 12 jobs, max 5 threads, min 2 jobs per thread
25
- // Correct result MUST have exactly 5 chunks
26
- assert.deepStrictEqual(
27
- array_chunk_balanced([1,2,3,4,5,6,7,8,9,10,11,12], 5, 2),
28
- [
29
- [1,2,3],
30
- [4,5,6],
31
- [7,8],
32
- [9,10],
33
- [11,12]
34
- ]
35
- );
36
- });
37
- });
@@ -1,72 +0,0 @@
1
- const array_fps = require('./array_fps');
2
- const assert = require('assert');
3
-
4
- describe('array_fps', function () {
5
- it('should handle basic input', function () {
6
- assert.deepStrictEqual(array_fps(1, 1), [0]);
7
- assert.deepStrictEqual(array_fps(1, 2), [0, 0.99999]);
8
- assert.deepStrictEqual(array_fps(1, 3), [0, 0.49999, 0.99999]);
9
- assert.deepStrictEqual(array_fps(1, 4), [0, 0.33333, 0.66666, 0.99999]);
10
- assert.deepStrictEqual(array_fps(5, 20), [
11
- 0, 0.0505, 0.10101, 0.15151, 0.20202, 0.25252, 0.30303, 0.35353, 0.40404, 0.45454,
12
- 0.50505, 0.55555, 0.60606, 0.65656, 0.70707, 0.75757, 0.80808, 0.85858, 0.90909, 0.95959,
13
- 1.0101, 1.0606, 1.11111, 1.16161, 1.21212, 1.26262, 1.31313, 1.36363, 1.41414, 1.46464,
14
- 1.51515, 1.56565, 1.61616, 1.66666, 1.71717, 1.76767, 1.81818, 1.86868, 1.91919, 1.96969,
15
- 2.0202, 2.0707, 2.12121, 2.17171, 2.22222, 2.27272, 2.32323, 2.37373, 2.42424, 2.47474,
16
- 2.52525, 2.57575, 2.62626, 2.67676, 2.72727, 2.77777, 2.82828, 2.87878, 2.92929, 2.97979,
17
- 3.0303, 3.0808, 3.13131, 3.18181, 3.23232, 3.28282, 3.33333, 3.38383, 3.43434, 3.48484,
18
- 3.53535, 3.58585, 3.63636, 3.68686, 3.73737, 3.78787, 3.83838, 3.88888, 3.93939, 3.98989,
19
- 4.0404, 4.0909, 4.14141, 4.19191, 4.24242, 4.29292, 4.34343, 4.39393, 4.44444, 4.49494,
20
- 4.54545, 4.59595, 4.64646, 4.69696, 4.74747, 4.79797, 4.84848, 4.89898, 4.94949, 4.99999,
21
- ]);
22
- assert.deepStrictEqual(array_fps(5, 30), [
23
- 0, 0.03356, 0.06711, 0.10067, 0.13423, 0.16778, 0.20134, 0.2349, 0.26846, 0.30201,
24
- 0.33557, 0.36913, 0.40268, 0.43624, 0.4698, 0.50335, 0.53691, 0.57047, 0.60403, 0.63758,
25
- 0.67114, 0.7047, 0.73825, 0.77181, 0.80537, 0.83892, 0.87248, 0.90604, 0.9396, 0.97315,
26
- 1.00671, 1.04027, 1.07382, 1.10738, 1.14094, 1.17449, 1.20805, 1.24161, 1.27517, 1.30872,
27
- 1.34228, 1.37584, 1.40939, 1.44295, 1.47651, 1.51006, 1.54362, 1.57718, 1.61074, 1.64429,
28
- 1.67785, 1.71141, 1.74496, 1.77852, 1.81208, 1.84563, 1.87919, 1.91275, 1.9463, 1.97986,
29
- 2.01342, 2.04698, 2.08053, 2.11409, 2.14765, 2.1812, 2.21476, 2.24832, 2.28187, 2.31543,
30
- 2.34899, 2.38255, 2.4161, 2.44966, 2.48322, 2.51677, 2.55033, 2.58389, 2.61744, 2.651,
31
- 2.68456, 2.71812, 2.75167, 2.78523, 2.81879, 2.85234, 2.8859, 2.91946, 2.95301, 2.98657,
32
- 3.02013, 3.05369, 3.08724, 3.1208, 3.15436, 3.18791, 3.22147, 3.25503, 3.28858, 3.32214,
33
- 3.3557, 3.38925, 3.42281, 3.45637, 3.48993, 3.52348, 3.55704, 3.5906, 3.62415, 3.65771,
34
- 3.69127, 3.72482, 3.75838, 3.79194, 3.8255, 3.85905, 3.89261, 3.92617, 3.95972, 3.99328,
35
- 4.02684, 4.06039, 4.09395, 4.12751, 4.16107, 4.19462, 4.22818, 4.26174, 4.29529, 4.32885,
36
- 4.36241, 4.39596, 4.42952, 4.46308, 4.49664, 4.53019, 4.56375, 4.59731, 4.63086, 4.66442,
37
- 4.69798, 4.73153, 4.76509, 4.79865, 4.83221, 4.86576, 4.89932, 4.93288, 4.96643, 4.99999,
38
- ]);
39
- assert.deepStrictEqual(array_fps(5, 60), [
40
- 0, 0.01672, 0.03344, 0.05017, 0.06689, 0.08361, 0.10033, 0.11706, 0.13378, 0.1505,
41
- 0.16722, 0.18395, 0.20067, 0.21739, 0.23411, 0.25084, 0.26756, 0.28428, 0.301, 0.31773,
42
- 0.33445, 0.35117, 0.36789, 0.38461, 0.40134, 0.41806, 0.43478, 0.4515, 0.46823, 0.48495,
43
- 0.50167, 0.51839, 0.53512, 0.55184, 0.56856, 0.58528, 0.60201, 0.61873, 0.63545, 0.65217,
44
- 0.66889, 0.68562, 0.70234, 0.71906, 0.73578, 0.75251, 0.76923, 0.78595, 0.80267, 0.8194,
45
- 0.83612, 0.85284, 0.86956, 0.88629, 0.90301, 0.91973, 0.93645, 0.95318, 0.9699, 0.98662,
46
- 1.00334, 1.02006, 1.03679, 1.05351, 1.07023, 1.08695, 1.10368, 1.1204, 1.13712, 1.15384,
47
- 1.17057, 1.18729, 1.20401, 1.22073, 1.23746, 1.25418, 1.2709, 1.28762, 1.30435, 1.32107,
48
- 1.33779, 1.35451, 1.37123, 1.38796, 1.40468, 1.4214, 1.43812, 1.45485, 1.47157, 1.48829,
49
- 1.50501, 1.52174, 1.53846, 1.55518, 1.5719, 1.58863, 1.60535, 1.62207, 1.63879, 1.65552,
50
- 1.67224, 1.68896, 1.70568, 1.7224, 1.73913, 1.75585, 1.77257, 1.78929, 1.80602, 1.82274,
51
- 1.83946, 1.85618, 1.87291, 1.88963, 1.90635, 1.92307, 1.9398, 1.95652, 1.97324, 1.98996,
52
- 2.00668, 2.02341, 2.04013, 2.05685, 2.07357, 2.0903, 2.10702, 2.12374, 2.14046, 2.15719,
53
- 2.17391, 2.19063, 2.20735, 2.22408, 2.2408, 2.25752, 2.27424, 2.29097, 2.30769, 2.32441,
54
- 2.34113, 2.35785, 2.37458, 2.3913, 2.40802, 2.42474, 2.44147, 2.45819, 2.47491, 2.49163,
55
- 2.50836, 2.52508, 2.5418, 2.55852, 2.57525, 2.59197, 2.60869, 2.62541, 2.64214, 2.65886,
56
- 2.67558, 2.6923, 2.70902, 2.72575, 2.74247, 2.75919, 2.77591, 2.79264, 2.80936, 2.82608,
57
- 2.8428, 2.85953, 2.87625, 2.89297, 2.90969, 2.92642, 2.94314, 2.95986, 2.97658, 2.99331,
58
- 3.01003, 3.02675, 3.04347, 3.06019, 3.07692, 3.09364, 3.11036, 3.12708, 3.14381, 3.16053,
59
- 3.17725, 3.19397, 3.2107, 3.22742, 3.24414, 3.26086, 3.27759, 3.29431, 3.31103, 3.32775,
60
- 3.34447, 3.3612, 3.37792, 3.39464, 3.41136, 3.42809, 3.44481, 3.46153, 3.47825, 3.49498,
61
- 3.5117, 3.52842, 3.54514, 3.56187, 3.57859, 3.59531, 3.61203, 3.62876, 3.64548, 3.6622,
62
- 3.67892, 3.69564, 3.71237, 3.72909, 3.74581, 3.76253, 3.77926, 3.79598, 3.8127, 3.82942,
63
- 3.84615, 3.86287, 3.87959, 3.89631, 3.91304, 3.92976, 3.94648, 3.9632, 3.97993, 3.99665,
64
- 4.01337, 4.03009, 4.04681, 4.06354, 4.08026, 4.09698, 4.1137, 4.13043, 4.14715, 4.16387,
65
- 4.18059, 4.19732, 4.21404, 4.23076, 4.24748, 4.26421, 4.28093, 4.29765, 4.31437, 4.3311,
66
- 4.34782, 4.36454, 4.38126, 4.39798, 4.41471, 4.43143, 4.44815, 4.46487, 4.4816, 4.49832,
67
- 4.51504, 4.53176, 4.54849, 4.56521, 4.58193, 4.59865, 4.61538, 4.6321, 4.64882, 4.66554,
68
- 4.68226, 4.69899, 4.71571, 4.73243, 4.74915, 4.76588, 4.7826, 4.79932, 4.81604, 4.83277,
69
- 4.84949, 4.86621, 4.88293, 4.89966, 4.91638, 4.9331, 4.94982, 4.96655, 4.98327, 4.99999,
70
- ]);
71
- });
72
- });
@@ -1,10 +0,0 @@
1
- const array_gcd = require('./array_gcd');
2
- const assert = require('assert');
3
-
4
- describe('array_gcd', function () {
5
- it('should handle basic input', function () {
6
- assert.deepStrictEqual(array_gcd([1,2,3,4,5]), 1);
7
- assert.deepStrictEqual(array_gcd([4,8,16]), 4);
8
- assert.deepStrictEqual(array_gcd([300,100,200,300]), 100);
9
- });
10
- });
@@ -1,14 +0,0 @@
1
- const array_index = require('./array_index');
2
- const assert = require('assert');
3
-
4
- describe('array_index', function () {
5
- it('should accept empty array', function () {
6
- assert.deepStrictEqual(array_index([]), {});
7
- });
8
- it('should handle basic input', function () {
9
- const a = {uid: 'a'};
10
- const b = {uid: 'b'};
11
- const c = {uid: 'c'};
12
- assert.deepStrictEqual(array_index([a, b, c], v => v.uid), {a, b, c});
13
- });
14
- });
@@ -1,12 +0,0 @@
1
- const array_lcm = require('./array_lcm');
2
- const assert = require('assert');
3
-
4
- describe('array_lcm', function () {
5
- it('should handle basic input', function () {
6
- assert.deepStrictEqual(array_lcm([1,2,3,4,5]), 60);
7
- assert.deepStrictEqual(array_lcm([15,25]), 75);
8
- assert.deepStrictEqual(array_lcm([4,6,8]), 24);
9
- assert.deepStrictEqual(array_lcm([4,8,16]), 16);
10
- assert.deepStrictEqual(array_lcm([300,100,200,300]), 600);
11
- });
12
- });
@@ -1,20 +0,0 @@
1
- const array_max = require('./array_max');
2
- const assert = require('assert');
3
-
4
- describe('array_max', function () {
5
- it('should accept empty array', function () {
6
- assert.deepStrictEqual(array_max([]), null);
7
- });
8
- it('should handle basic input', function () {
9
- assert.deepStrictEqual(array_max([1, 1, 2, 2, 3, 3, 1]), 3);
10
- assert.deepStrictEqual(array_max([{x:1},{x:2}], v => v.x), {x: 2});
11
- });
12
- it('should handle strings', function () {
13
- const items = [
14
- {id: 1, time: '2025-08-08T05:03:13+00:00'},
15
- {id: 2, time: '2025-08-07T05:03:13+00:00'},
16
- {id: 3, time: '2025-08-06T05:03:13+00:00'},
17
- ];
18
- assert.deepStrictEqual(array_max(items, v => v.time), items[0]);
19
- });
20
- });
@@ -1,20 +0,0 @@
1
- const array_min = require('./array_min');
2
- const assert = require('assert');
3
-
4
- describe('array_min', function () {
5
- it('should accept empty array', function () {
6
- assert.deepStrictEqual(array_min([]), null);
7
- });
8
- it('should handle basic input', function () {
9
- assert.deepStrictEqual(array_min([1, 1, 2, 2, 3, 3, 1]), 1);
10
- assert.deepStrictEqual(array_min([{x:2},{x:1}], v => v.x), {x: 1});
11
- });
12
- it('should handle strings', function () {
13
- const items = [
14
- {id: 1, time: '2025-08-08T05:03:13+00:00'},
15
- {id: 2, time: '2025-08-07T05:03:13+00:00'},
16
- {id: 3, time: '2025-08-06T05:03:13+00:00'},
17
- ];
18
- assert.deepStrictEqual(array_min(items, v => v.time), items[2]);
19
- });
20
- });
@@ -1,20 +0,0 @@
1
- const array_permutations = require('./array_permutations');
2
- const assert = require('assert');
3
-
4
- describe('array_permutations', function () {
5
- it('should handle basic input', function () {
6
- assert.deepStrictEqual(array_permutations([]), [[]]);
7
- assert.deepStrictEqual(array_permutations([1,2]), [[1,2],[2,1]]);
8
- assert.deepStrictEqual(array_permutations([1,2,3]), [[1,2,3],[2,1,3],[3,1,2],[1,3,2],[2,3,1],[3,2,1]]);
9
- });
10
- it('should handle k', function () {
11
- assert.deepStrictEqual(array_permutations([1,2], 1), [[1],[2]]);
12
- assert.deepStrictEqual(array_permutations([1,2,3], 2), [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]);
13
- assert.deepStrictEqual(array_permutations([1,2,3,4], 3), [
14
- [1,2,3],[1,2,4],[1,3,2],[1,3,4],[1,4,2],[1,4,3],
15
- [2,1,3],[2,1,4],[2,3,1],[2,3,4],[2,4,1],[2,4,3],
16
- [3,1,2],[3,1,4],[3,2,1],[3,2,4],[3,4,1],[3,4,2],
17
- [4,1,2],[4,1,3],[4,2,1],[4,2,3],[4,3,1],[4,3,2]
18
- ]);
19
- });
20
- });
@@ -1,85 +0,0 @@
1
- const array_sort = require('./array_sort');
2
- const assert = require('assert');
3
- const fs_path_extname = require('./fs_path_extname');
4
-
5
- describe('array_sort', function () {
6
- it('should handle basic input', function () {
7
- assert.deepStrictEqual(array_sort([5,4,3,2,1], v => [v]), [1,2,3,4,5]);
8
- assert.deepStrictEqual(array_sort([5,4,3,2,1], v => [v]), [1,2,3,4,5]);
9
- assert.deepStrictEqual(array_sort([{id:5},{id:4},{id:3},{id:2},{id:1}], v => [v.id]), [{id:1},{id:2},{id:3},{id:4},{id:5}]);
10
- });
11
- it('should handle sort by priorities', function () {
12
- assert.deepStrictEqual(array_sort([1,2,3,4,5], v => [[5].indexOf(v) >>> 0]), [5,1,2,3,4]);
13
- assert.deepStrictEqual(array_sort([{id:1},{id:2},{id:3},{id:4},{id:5}], v => [[5].indexOf(v.id) >>> 0]), [{id:5},{id:1},{id:2},{id:3},{id:4}]);
14
- });
15
- it('should handle sort by priorities #2', function () {
16
- const files = [
17
- {name: 'README.md', size: 1024, type: 'file'},
18
- {name: 'package.json', size: 860, type: 'file'},
19
- {name: 'src', size: 0, type: 'dir'},
20
- {name: 'src/index.js', size: 2048, type: 'file'},
21
- {name: 'src/utils', size: 0, type: 'dir'},
22
- {name: 'src/utils/helpers.js', size: 1536, type: 'file'},
23
- {name: 'node_modules', size: 0, type: 'dir'},
24
- {name: 'LICENSE', size: 1078, type: 'file'},
25
- ];
26
- const expected = [
27
- {name: 'node_modules', size: 0, type: 'dir'},
28
- {name: 'src', size: 0, type: 'dir'},
29
- {name: 'src/utils', size: 0, type: 'dir'},
30
- {name: 'LICENSE', size: 1078, type: 'file'},
31
- {name: 'README.md', size: 1024, type: 'file'},
32
- {name: 'package.json', size: 860, type: 'file'},
33
- {name: 'src/index.js', size: 2048, type: 'file'},
34
- {name: 'src/utils/helpers.js', size: 1536, type: 'file'},
35
- ];
36
- const actual = array_sort(files, v => [pri_start(v.type, ['dir']), v.name]);
37
- assert.deepStrictEqual(actual, expected);
38
- });
39
- it('sort by name, directory first; .js, then .txt, then all the reset', function () {
40
- const files = [
41
- {name: 'docs', type: 'dir', size: 0},
42
- {name: 'zeta.txt', type: 'file', size: 1200},
43
- {name: 'alpha.js', type: 'file', size: 1500},
44
- {name: 'src', type: 'dir', size: 0},
45
- {name: 'readme.txt', type: 'file', size: 800},
46
- {name: 'beta.js', type: 'file', size: 1600},
47
- {name: 'build', type: 'dir', size: 0},
48
- {name: 'build.foo.js', type: 'dir', size: 0},
49
- {name: 'build.foo.md', type: 'dir', size: 0},
50
- {name: 'build.foo.txt', type: 'dir', size: 0},
51
- {name: 'notes.md', type: 'file', size: 400},
52
- {name: 'zeta.js', type: 'file', size: 1000},
53
- {name: 'config', type: 'dir', size: 0},
54
- ];
55
- const expected = [
56
- {name: 'build.foo.js', type: 'dir', size: 0},
57
- {name: 'build.foo.txt', type: 'dir', size: 0},
58
- {name: 'build', type: 'dir', size: 0},
59
- {name: 'build.foo.md', type: 'dir', size: 0},
60
- {name: 'config', type: 'dir', size: 0},
61
- {name: 'docs', type: 'dir', size: 0},
62
- {name: 'src', type: 'dir', size: 0},
63
- {name: 'alpha.js', type: 'file', size: 1500},
64
- {name: 'beta.js', type: 'file', size: 1600},
65
- {name: 'zeta.js', type: 'file', size: 1000},
66
- {name: 'readme.txt', type: 'file', size: 800},
67
- {name: 'zeta.txt', type: 'file', size: 1200},
68
- {name: 'notes.md', type: 'file', size: 400},
69
- ];
70
- array_sort(files, v => [pri_start(v.type, ['dir']), pri_start(fs_path_extname(v.name), ['.js', '.txt']), v.name])
71
- assert.deepStrictEqual(files, expected);
72
- });
73
- });
74
-
75
- // priorities.indexOf(v) >>> 0
76
- function pri_start(value, array)
77
- {
78
- const i = array.indexOf(value);
79
- return i === -1 ? array.length : i;
80
- }
81
-
82
- function pri_end(value, array)
83
- {
84
- return array.indexOf(value);
85
- }
@@ -1,9 +0,0 @@
1
- const array_sort_other = require('./array_sort_other');
2
- const assert = require('assert');
3
-
4
- describe('array_sort_other', function () {
5
- it('should handle basic input', function () {
6
- assert.deepStrictEqual(array_sort_other([1,2,3,4,5], v => v, [5]), [5,1,2,3,4]);
7
- assert.deepStrictEqual(array_sort_other([{id:1},{id:2},{id:3},{id:4},{id:5}], v => v.id, [5]), [{id:5},{id:1},{id:2},{id:3},{id:4}]);
8
- });
9
- });
@@ -1,11 +0,0 @@
1
- const array_sum = require('./array_sum');
2
- const assert = require('assert');
3
-
4
- describe('array_sum', function () {
5
- it('should handle basic input', function () {
6
- assert.deepStrictEqual(array_sum([1,2,3,4,5]), 15);
7
- });
8
- it('should cast strings to numbers', function () {
9
- assert.deepStrictEqual(array_sum(['1','2','3','4','5']), 15);
10
- });
11
- });
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // 9. Client that connects but sends absolutely NO DATA.
4
- // Watchdog must NOT treat this as a PING.
5
-
6
- const net = require('net');
7
-
8
- const SOCKET = process.env.WATCHDOG_SOCKET;
9
- if (!SOCKET) throw new Error('WATCHDOG_SOCKET missing');
10
-
11
- // Connect → immediately destroy the socket → NO write events
12
- const socket = net.connect(SOCKET, () => {
13
- console.log('connected (no ping), closing immediately');
14
- socket.destroy(); // IMPORTANT: destroy() does not flush anything
15
- });
16
-
17
- setInterval(() => {}, 1000);
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // 9. Client that connects but sends absolutely NO DATA.
4
- // Watchdog must NOT treat this as a PING.
5
-
6
- const net = require('net');
7
-
8
- const SOCKET = process.env.WATCHDOG_SOCKET;
9
- if (!SOCKET) throw new Error('WATCHDOG_SOCKET missing');
10
-
11
- setInterval(ping, 1000);
12
-
13
- function ping()
14
- {
15
- // Connect → immediately destroy the socket → NO write events
16
- const socket = net.connect(SOCKET, () => {
17
- console.log('connected (no ping), closing immediately');
18
- socket.destroy(); // IMPORTANT: destroy() does not flush anything
19
- });
20
- }
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ❌ 11. Client sends heartbeats sporadically (sometimes missing)
4
- // Simulates flaky client.
5
-
6
- const net = require('net');
7
-
8
- const SOCKET = process.env.WATCHDOG_SOCKET;
9
- if (!SOCKET) throw new Error('WATCHDOG_SOCKET missing');
10
-
11
- setInterval(ping, 1000);
12
-
13
- function ping()
14
- {
15
- // Connect → immediately destroy the socket → NO write events
16
- const socket = net.connect(SOCKET, () => {
17
- if (Math.random() > 0.5) {
18
- socket.end('PING');
19
- }
20
- else {
21
- console.log('connected (no ping), closing immediately');
22
- socket.destroy(); // IMPORTANT: destroy() does not flush anything
23
- }
24
- });
25
- }
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ❌ 8. Client connects but NEVER sends PING
4
- // Simulates misbehaving client.
5
-
6
- const net = require('net');
7
-
8
- net.connect(process.env.WATCHDOG_SOCKET, () => {
9
- console.log('connected but no ping');
10
- // do nothing
11
- });
12
-
13
- setInterval(() => {}, 1000);
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ❌ 4. Client that exits immediately
4
- // Watchdog must detect child exit first.
5
-
6
- console.log('bye');
7
- process.exit(0);
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ❌ 7. Client that floods watchdog with 1GB of data
4
- // Outcome: watchdog must handle MASSIVE reads and still time out.
5
-
6
- const fs = require('fs');
7
- const net = require('net');
8
-
9
- const socket = net.connect(process.env.WATCHDOG_SOCKET, () => {
10
- console.log('connected');
11
- const stream = fs.createReadStream('/dev/zero');
12
- stream.pipe(socket);
13
- });
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ❌ 7. Client that floods watchdog with 1GB of data
4
- // Outcome: watchdog must handle MASSIVE reads and still time out.
5
-
6
- const fs = require('fs');
7
- const net = require('net');
8
-
9
- const socket = net.connect(process.env.WATCHDOG_SOCKET, () => {
10
- console.log('connected');
11
- const stream = fs.createReadStream('/dev/zero');
12
- stream.pipe(socket).on('error', () => 0);
13
- });
14
-
15
- setInterval(() => {}, 1000);
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ❌ 5. Client that freezes (event loop blocked)
4
- // Watchdog will not receive PINGs.
5
-
6
- while (true) {
7
- // infinite CPU loop
8
- }
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ❌ 10. Client sends heartbeats but with huge delay
4
- // Tests delayed heartbeat behavior.
5
- // Expected: watchdog should kill before that.
6
-
7
- const net = require('net');
8
-
9
- const INTERVAL = Number(process.env.WATCHDOG_INTERVAL || 1000);
10
-
11
- const socket = net.connect(process.env.WATCHDOG_SOCKET, () => {
12
- console.log('connected');
13
-
14
- setTimeout(() => {
15
- console.log('sending late heartbeat');
16
- socket.end('PING');
17
- }, INTERVAL * 10);
18
- });
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // 1️⃣ Client that ignores SIGTERM
4
- // Goal: process stays alive after SIGTERM and only dies on SIGKILL (exactly what pid_kill_grace should handle).
5
- //
6
- // What this tests for watchdog:
7
- // - watchdog sends SIGTERM → process prints “ignored” and keeps running.
8
- // - pid_kill_grace waits grace_timeout_ms, sees PID still alive, sends SIGKILL.
9
- // - Process must die after SIGKILL.
10
- // - Watchdog should log the whole sequence correctly.
11
- // This is a realistic scenario.
12
-
13
- console.log('PID:', process.pid);
14
-
15
- // Ignore SIGTERM
16
- process.on('SIGTERM', function () {
17
- console.log('SIGTERM received, but intentionally ignored');
18
- });
19
-
20
- // Still react to SIGINT (Ctrl+C) so you can stop it manually if needed
21
- process.on('SIGINT', function () {
22
- console.log('SIGINT received, exiting');
23
- process.exit(130);
24
- });
25
-
26
- // Keep process alive
27
- setInterval(() => {
28
- // simulate work
29
- }, 1000);
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ❌ 11. Client sends heartbeats sporadically (sometimes missing)
4
- // Simulates flaky client.
5
-
6
- const net = require('net');
7
-
8
- function randomDelay() {
9
- return Math.floor(Math.random() * 5000);
10
- }
11
-
12
- setTimeout(ping, randomDelay());
13
-
14
- function ping()
15
- {
16
- const socket = net.connect(process.env.WATCHDOG_SOCKET);
17
- socket.on('connect', () => {
18
- socket.end('PING');
19
- setTimeout(ping, randomDelay());
20
- });
21
- }
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const Promise = require('bluebird');
4
- const cli = require('../../cli');
5
- const ping_socket = require('../../ping_socket');
6
-
7
- cli(main);
8
-
9
- async function main()
10
- {
11
- for (let iter = 1, last = 2; iter <= last; ++iter) {
12
- await ping_socket(process.env.WATCHDOG_SOCKET);
13
- await Promise.delay(1000);
14
- }
15
- console.log('Bye!');
16
- }
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const Promise = require('bluebird');
4
- const cli = require('@vbarbarosh/node-helpers/src/cli');
5
- const ping_socket = require('@vbarbarosh/node-helpers/src/ping_socket');
6
-
7
- cli(main);
8
-
9
- async function main()
10
- {
11
- for (let i = 0; i < 100; ++i) {
12
- console.log('[client]', i);
13
- await ping_socket(process.env.WATCHDOG_SOCKET);
14
- await Promise.delay(1000);
15
- }
16
- }
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const Promise = require('bluebird');
4
- const cli = require('@vbarbarosh/node-helpers/src/cli');
5
- const now_human = require('@vbarbarosh/node-helpers/src/now_human');
6
-
7
- cli(main);
8
-
9
- async function main()
10
- {
11
- process.on('SIGTERM', function () {
12
- console.log(`[${now_human()}][ignore-sigterm] SIGTERM, ignoring...`);
13
- });
14
- process.on('SIGINT', function () {
15
- console.log(`[${now_human()}][ignore-sigterm] SIGINT, ignoring...`);
16
- });
17
-
18
- for (let iter = 1, last = 100; iter <= last; ++iter) {
19
- console.log(`[${now_human()}][ignore-sigterm] ${iter} of ${last}`);
20
- await Promise.delay(100);
21
- }
22
- }
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const Promise = require('bluebird');
4
- const cli = require('@vbarbarosh/node-helpers/src/cli');
5
- const now_human = require('@vbarbarosh/node-helpers/src/now_human');
6
-
7
- cli(main);
8
-
9
- async function main()
10
- {
11
- for (let iter = 1, last = 100; iter <= last; ++iter) {
12
- console.log(`[${now_human()}][never-ping] ${iter} of ${last}`);
13
- await Promise.delay(100);
14
- }
15
- }
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ❌ 2. Client that never sends heartbeat (expected: watchdog kills it)
4
-
5
- setInterval(() => {}, 1000); // alive but no PINGs
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ✅ 1. Client that works normally (sends correct PINGs)
4
-
5
- const net = require('net');
6
-
7
- const SOCKET = process.env.WATCHDOG_SOCKET;
8
- const INTERVAL = Number(process.env.WATCHDOG_INTERVAL || 1000);
9
-
10
- if (!SOCKET) throw new Error('WATCHDOG_SOCKET missing');
11
-
12
- setInterval(ping, INTERVAL / 2);
13
-
14
- function ping()
15
- {
16
- const socket = net.connect(SOCKET, () => socket.end('PING'));
17
- }
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const Promise = require('bluebird');
4
- const cli = require('../../cli');
5
- const ping_socket = require('../../ping_socket');
6
-
7
- cli(main);
8
-
9
- async function main()
10
- {
11
- for (let iter = 1, last = 2; iter <= last; ++iter) {
12
- await ping_socket(process.env.WATCHDOG_SOCKET);
13
- await Promise.delay(10);
14
- }
15
- }