yummies 5.4.4 → 5.4.6

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 (510) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +11 -0
  3. package/.github/FUNDING.yml +1 -0
  4. package/.github/workflows/main.yml +34 -0
  5. package/.github/workflows/version-or-publish.yml +45 -0
  6. package/.nvmrc +1 -0
  7. package/.vscode/settings.json +19 -0
  8. package/CHANGELOG.md +215 -0
  9. package/CONTRIBUTING.md +8 -0
  10. package/Makefile +7 -0
  11. package/assets/logo.png +0 -0
  12. package/assets/logo.pxz +0 -0
  13. package/biome.json +3 -0
  14. package/commitfmt.toml +18 -0
  15. package/lefthook.yml +14 -0
  16. package/package.json +3 -389
  17. package/scripts/post-build.ts +71 -0
  18. package/src/async.ts +86 -0
  19. package/src/common.ts +26 -0
  20. package/src/complex/counter.test.ts +41 -0
  21. package/src/complex/counter.ts +40 -0
  22. package/src/complex/global-config.ts +55 -0
  23. package/src/complex/index.ts +3 -0
  24. package/src/complex/modules-factory.ts +65 -0
  25. package/src/cookie.ts +11 -0
  26. package/src/css.ts +60 -0
  27. package/src/data.test.ts +99 -0
  28. package/src/data.ts +65 -0
  29. package/src/date-time.test.ts +119 -0
  30. package/src/date-time.ts +236 -0
  31. package/src/device.ts +42 -0
  32. package/src/encodings.ts +270 -0
  33. package/src/errors.ts +40 -0
  34. package/src/file.ts +25 -0
  35. package/src/format/_exports.ts +4 -0
  36. package/{dist/format/constants.js → src/format/constants.ts} +2 -0
  37. package/{dist/format/index.js → src/format/index.ts} +2 -1
  38. package/src/format/number.test.ts +16 -0
  39. package/src/format/number.ts +96 -0
  40. package/src/format/percent.ts +40 -0
  41. package/src/format/skip-spaces.ts +4 -0
  42. package/src/html.ts +238 -0
  43. package/{dist/id.js → src/id.ts} +16 -6
  44. package/src/imports.ts +52 -0
  45. package/src/math.ts +20 -0
  46. package/src/media.ts +134 -0
  47. package/src/mobx/apply-observable.ts +20 -0
  48. package/src/mobx/create-enhanced-atom.ts +28 -0
  49. package/src/mobx/deep-observable-struct.test.ts +69 -0
  50. package/src/mobx/deep-observable-struct.ts +69 -0
  51. package/src/mobx/get-mobx-administration.ts +10 -0
  52. package/src/mobx/index.ts +5 -0
  53. package/src/mobx/lazy-observe.ts +59 -0
  54. package/src/ms.ts +20 -0
  55. package/src/number.ts +14 -0
  56. package/src/parser/_exports.ts +3 -0
  57. package/{dist/parser/index.js → src/parser/index.ts} +2 -1
  58. package/src/parser/number.test.ts +38 -0
  59. package/src/parser/number.ts +73 -0
  60. package/src/parser/percent.ts +11 -0
  61. package/src/parser/string.ts +29 -0
  62. package/src/price.ts +33 -0
  63. package/src/random.ts +27 -0
  64. package/src/react/hooks/index.ts +21 -0
  65. package/src/react/hooks/use-abort-controller.ts +15 -0
  66. package/src/react/hooks/use-abort-signal.ts +5 -0
  67. package/src/react/hooks/use-click-outside.ts +27 -0
  68. package/{dist/react/hooks/use-constant.js → src/react/hooks/use-constant.ts} +9 -6
  69. package/{dist/react/hooks/use-define-ref.js → src/react/hooks/use-define-ref.ts} +10 -7
  70. package/src/react/hooks/use-element-ref.ts +11 -0
  71. package/src/react/hooks/use-event-listener.ts +29 -0
  72. package/src/react/hooks/use-event.ts +23 -0
  73. package/src/react/hooks/use-flag.ts +27 -0
  74. package/src/react/hooks/use-force-update.ts +9 -0
  75. package/src/react/hooks/use-initial-height.ts +16 -0
  76. package/{dist/react/hooks/use-instance.js → src/react/hooks/use-instance.ts} +31 -9
  77. package/src/react/hooks/use-intersection-observer.ts +18 -0
  78. package/src/react/hooks/use-last-defined-value.ts +9 -0
  79. package/src/react/hooks/use-last-value-ref.ts +11 -0
  80. package/src/react/hooks/use-life-cycle.ts +17 -0
  81. package/src/react/hooks/use-resize-observer.ts +14 -0
  82. package/src/react/hooks/use-sync-ref.ts +7 -0
  83. package/src/react/hooks/use-toggle.ts +9 -0
  84. package/src/react/hooks/use-value.ts +10 -0
  85. package/src/react/hooks/use-visibility-state.ts +19 -0
  86. package/src/react/index.ts +1 -0
  87. package/src/sound.ts +15 -0
  88. package/src/storage.ts +137 -0
  89. package/src/text.test.ts +91 -0
  90. package/src/text.ts +60 -0
  91. package/src/type-guard/_exports.ts +154 -0
  92. package/src/type-guard/index.test.ts +127 -0
  93. package/{dist/type-guard/index.js → src/type-guard/index.ts} +2 -1
  94. package/src/vibrate.ts +8 -0
  95. package/tsconfig.json +26 -0
  96. package/tsconfig.test.json +33 -0
  97. package/vitest.config.ts +20 -0
  98. package/dist/async.cjs +0 -70
  99. package/dist/async.d.cts +0 -28
  100. package/dist/async.d.cts.map +0 -1
  101. package/dist/async.d.ts +0 -28
  102. package/dist/async.d.ts.map +0 -1
  103. package/dist/async.js +0 -62
  104. package/dist/common.cjs +0 -18
  105. package/dist/common.d.cts +0 -15
  106. package/dist/common.d.cts.map +0 -1
  107. package/dist/common.d.ts +0 -15
  108. package/dist/common.d.ts.map +0 -1
  109. package/dist/common.js +0 -14
  110. package/dist/complex/counter.cjs +0 -21
  111. package/dist/complex/counter.d.cts +0 -15
  112. package/dist/complex/counter.d.cts.map +0 -1
  113. package/dist/complex/counter.d.ts +0 -15
  114. package/dist/complex/counter.d.ts.map +0 -1
  115. package/dist/complex/counter.js +0 -17
  116. package/dist/complex/global-config.cjs +0 -46
  117. package/dist/complex/global-config.d.cts +0 -11
  118. package/dist/complex/global-config.d.cts.map +0 -1
  119. package/dist/complex/global-config.d.ts +0 -11
  120. package/dist/complex/global-config.d.ts.map +0 -1
  121. package/dist/complex/global-config.js +0 -41
  122. package/dist/complex/index.cjs +0 -19
  123. package/dist/complex/index.d.cts +0 -4
  124. package/dist/complex/index.d.cts.map +0 -1
  125. package/dist/complex/index.d.ts +0 -4
  126. package/dist/complex/index.d.ts.map +0 -1
  127. package/dist/complex/index.js +0 -3
  128. package/dist/complex/modules-factory.cjs +0 -50
  129. package/dist/complex/modules-factory.d.cts +0 -49
  130. package/dist/complex/modules-factory.d.cts.map +0 -1
  131. package/dist/complex/modules-factory.d.ts +0 -49
  132. package/dist/complex/modules-factory.d.ts.map +0 -1
  133. package/dist/complex/modules-factory.js +0 -46
  134. package/dist/cookie.cjs +0 -13
  135. package/dist/cookie.d.cts +0 -3
  136. package/dist/cookie.d.cts.map +0 -1
  137. package/dist/cookie.d.ts +0 -3
  138. package/dist/cookie.d.ts.map +0 -1
  139. package/dist/cookie.js +0 -9
  140. package/dist/css.cjs +0 -28
  141. package/dist/css.d.cts +0 -36
  142. package/dist/css.d.cts.map +0 -1
  143. package/dist/css.d.ts +0 -36
  144. package/dist/css.d.ts.map +0 -1
  145. package/dist/css.js +0 -20
  146. package/dist/data.cjs +0 -58
  147. package/dist/data.d.cts +0 -4
  148. package/dist/data.d.cts.map +0 -1
  149. package/dist/data.d.ts +0 -4
  150. package/dist/data.d.ts.map +0 -1
  151. package/dist/data.js +0 -52
  152. package/dist/date-time.cjs +0 -171
  153. package/dist/date-time.d.cts +0 -28
  154. package/dist/date-time.d.cts.map +0 -1
  155. package/dist/date-time.d.ts +0 -28
  156. package/dist/date-time.d.ts.map +0 -1
  157. package/dist/date-time.js +0 -160
  158. package/dist/device.cjs +0 -28
  159. package/dist/device.d.cts +0 -8
  160. package/dist/device.d.cts.map +0 -1
  161. package/dist/device.d.ts +0 -8
  162. package/dist/device.d.ts.map +0 -1
  163. package/dist/device.js +0 -21
  164. package/dist/encodings.cjs +0 -270
  165. package/dist/encodings.d.cts +0 -2
  166. package/dist/encodings.d.cts.map +0 -1
  167. package/dist/encodings.d.ts +0 -2
  168. package/dist/encodings.d.ts.map +0 -1
  169. package/dist/encodings.js +0 -267
  170. package/dist/errors.cjs +0 -34
  171. package/dist/errors.d.cts +0 -19
  172. package/dist/errors.d.cts.map +0 -1
  173. package/dist/errors.d.ts +0 -19
  174. package/dist/errors.d.ts.map +0 -1
  175. package/dist/errors.js +0 -30
  176. package/dist/file.cjs +0 -29
  177. package/dist/file.d.cts +0 -3
  178. package/dist/file.d.cts.map +0 -1
  179. package/dist/file.d.ts +0 -3
  180. package/dist/file.d.ts.map +0 -1
  181. package/dist/file.js +0 -24
  182. package/dist/format/_exports.cjs +0 -20
  183. package/dist/format/_exports.d.cts +0 -5
  184. package/dist/format/_exports.d.cts.map +0 -1
  185. package/dist/format/_exports.d.ts +0 -5
  186. package/dist/format/_exports.d.ts.map +0 -1
  187. package/dist/format/_exports.js +0 -4
  188. package/dist/format/constants.cjs +0 -6
  189. package/dist/format/constants.d.cts +0 -4
  190. package/dist/format/constants.d.cts.map +0 -1
  191. package/dist/format/constants.d.ts +0 -4
  192. package/dist/format/constants.d.ts.map +0 -1
  193. package/dist/format/index.cjs +0 -40
  194. package/dist/format/index.d.cts +0 -3
  195. package/dist/format/index.d.cts.map +0 -1
  196. package/dist/format/index.d.ts +0 -3
  197. package/dist/format/index.d.ts.map +0 -1
  198. package/dist/format/number.cjs +0 -48
  199. package/dist/format/number.d.cts +0 -36
  200. package/dist/format/number.d.cts.map +0 -1
  201. package/dist/format/number.d.ts +0 -36
  202. package/dist/format/number.d.ts.map +0 -1
  203. package/dist/format/number.js +0 -44
  204. package/dist/format/percent.cjs +0 -27
  205. package/dist/format/percent.d.cts +0 -15
  206. package/dist/format/percent.d.cts.map +0 -1
  207. package/dist/format/percent.d.ts +0 -15
  208. package/dist/format/percent.d.ts.map +0 -1
  209. package/dist/format/percent.js +0 -23
  210. package/dist/format/skip-spaces.cjs +0 -8
  211. package/dist/format/skip-spaces.d.cts +0 -5
  212. package/dist/format/skip-spaces.d.cts.map +0 -1
  213. package/dist/format/skip-spaces.d.ts +0 -5
  214. package/dist/format/skip-spaces.d.ts.map +0 -1
  215. package/dist/format/skip-spaces.js +0 -4
  216. package/dist/html.cjs +0 -202
  217. package/dist/html.d.cts +0 -44
  218. package/dist/html.d.cts.map +0 -1
  219. package/dist/html.d.ts +0 -44
  220. package/dist/html.d.ts.map +0 -1
  221. package/dist/html.js +0 -182
  222. package/dist/id.cjs +0 -76
  223. package/dist/id.d.cts +0 -63
  224. package/dist/id.d.cts.map +0 -1
  225. package/dist/id.d.ts +0 -63
  226. package/dist/id.d.ts.map +0 -1
  227. package/dist/imports.cjs +0 -45
  228. package/dist/imports.d.cts +0 -15
  229. package/dist/imports.d.cts.map +0 -1
  230. package/dist/imports.d.ts +0 -15
  231. package/dist/imports.d.ts.map +0 -1
  232. package/dist/imports.js +0 -40
  233. package/dist/math.cjs +0 -23
  234. package/dist/math.d.cts +0 -13
  235. package/dist/math.d.cts.map +0 -1
  236. package/dist/math.d.ts +0 -13
  237. package/dist/math.d.ts.map +0 -1
  238. package/dist/math.js +0 -17
  239. package/dist/media.cjs +0 -115
  240. package/dist/media.d.cts +0 -20
  241. package/dist/media.d.cts.map +0 -1
  242. package/dist/media.d.ts +0 -20
  243. package/dist/media.d.ts.map +0 -1
  244. package/dist/media.js +0 -103
  245. package/dist/mobx/apply-observable.cjs +0 -16
  246. package/dist/mobx/apply-observable.d.cts +0 -4
  247. package/dist/mobx/apply-observable.d.cts.map +0 -1
  248. package/dist/mobx/apply-observable.d.ts +0 -4
  249. package/dist/mobx/apply-observable.d.ts.map +0 -1
  250. package/dist/mobx/apply-observable.js +0 -12
  251. package/dist/mobx/create-enhanced-atom.cjs +0 -16
  252. package/dist/mobx/create-enhanced-atom.d.cts +0 -11
  253. package/dist/mobx/create-enhanced-atom.d.cts.map +0 -1
  254. package/dist/mobx/create-enhanced-atom.d.ts +0 -11
  255. package/dist/mobx/create-enhanced-atom.d.ts.map +0 -1
  256. package/dist/mobx/create-enhanced-atom.js +0 -12
  257. package/dist/mobx/deep-observable-struct.cjs +0 -61
  258. package/dist/mobx/deep-observable-struct.d.cts +0 -7
  259. package/dist/mobx/deep-observable-struct.d.cts.map +0 -1
  260. package/dist/mobx/deep-observable-struct.d.ts +0 -7
  261. package/dist/mobx/deep-observable-struct.d.ts.map +0 -1
  262. package/dist/mobx/deep-observable-struct.js +0 -57
  263. package/dist/mobx/get-mobx-administration.cjs +0 -6
  264. package/dist/mobx/get-mobx-administration.d.cts +0 -6
  265. package/dist/mobx/get-mobx-administration.d.cts.map +0 -1
  266. package/dist/mobx/get-mobx-administration.d.ts +0 -6
  267. package/dist/mobx/get-mobx-administration.d.ts.map +0 -1
  268. package/dist/mobx/get-mobx-administration.js +0 -2
  269. package/dist/mobx/index.cjs +0 -21
  270. package/dist/mobx/index.d.cts +0 -6
  271. package/dist/mobx/index.d.cts.map +0 -1
  272. package/dist/mobx/index.d.ts +0 -6
  273. package/dist/mobx/index.d.ts.map +0 -1
  274. package/dist/mobx/index.js +0 -5
  275. package/dist/mobx/lazy-observe.cjs +0 -47
  276. package/dist/mobx/lazy-observe.d.cts +0 -8
  277. package/dist/mobx/lazy-observe.d.cts.map +0 -1
  278. package/dist/mobx/lazy-observe.d.ts +0 -8
  279. package/dist/mobx/lazy-observe.d.ts.map +0 -1
  280. package/dist/mobx/lazy-observe.js +0 -43
  281. package/dist/ms.cjs +0 -22
  282. package/dist/ms.d.cts +0 -19
  283. package/dist/ms.d.cts.map +0 -1
  284. package/dist/ms.d.ts +0 -19
  285. package/dist/ms.d.ts.map +0 -1
  286. package/dist/ms.js +0 -18
  287. package/dist/number.cjs +0 -16
  288. package/dist/number.d.cts +0 -8
  289. package/dist/number.d.cts.map +0 -1
  290. package/dist/number.d.ts +0 -8
  291. package/dist/number.d.ts.map +0 -1
  292. package/dist/number.js +0 -13
  293. package/dist/parser/_exports.cjs +0 -19
  294. package/dist/parser/_exports.d.cts +0 -4
  295. package/dist/parser/_exports.d.cts.map +0 -1
  296. package/dist/parser/_exports.d.ts +0 -4
  297. package/dist/parser/_exports.d.ts.map +0 -1
  298. package/dist/parser/_exports.js +0 -3
  299. package/dist/parser/index.cjs +0 -40
  300. package/dist/parser/index.d.cts +0 -3
  301. package/dist/parser/index.d.cts.map +0 -1
  302. package/dist/parser/index.d.ts +0 -3
  303. package/dist/parser/index.d.ts.map +0 -1
  304. package/dist/parser/number.cjs +0 -48
  305. package/dist/parser/number.d.cts +0 -21
  306. package/dist/parser/number.d.cts.map +0 -1
  307. package/dist/parser/number.d.ts +0 -21
  308. package/dist/parser/number.d.ts.map +0 -1
  309. package/dist/parser/number.js +0 -44
  310. package/dist/parser/percent.cjs +0 -8
  311. package/dist/parser/percent.d.cts +0 -4
  312. package/dist/parser/percent.d.cts.map +0 -1
  313. package/dist/parser/percent.d.ts +0 -4
  314. package/dist/parser/percent.d.ts.map +0 -1
  315. package/dist/parser/percent.js +0 -4
  316. package/dist/parser/string.cjs +0 -18
  317. package/dist/parser/string.d.cts +0 -7
  318. package/dist/parser/string.d.cts.map +0 -1
  319. package/dist/parser/string.d.ts +0 -7
  320. package/dist/parser/string.d.ts.map +0 -1
  321. package/dist/parser/string.js +0 -14
  322. package/dist/price.cjs +0 -21
  323. package/dist/price.d.cts +0 -6
  324. package/dist/price.d.cts.map +0 -1
  325. package/dist/price.d.ts +0 -6
  326. package/dist/price.d.ts.map +0 -1
  327. package/dist/price.js +0 -17
  328. package/dist/random.cjs +0 -25
  329. package/dist/random.d.cts +0 -9
  330. package/dist/random.d.cts.map +0 -1
  331. package/dist/random.d.ts +0 -9
  332. package/dist/random.d.ts.map +0 -1
  333. package/dist/random.js +0 -14
  334. package/dist/react/hooks/index.cjs +0 -37
  335. package/dist/react/hooks/index.d.cts +0 -22
  336. package/dist/react/hooks/index.d.cts.map +0 -1
  337. package/dist/react/hooks/index.d.ts +0 -22
  338. package/dist/react/hooks/index.d.ts.map +0 -1
  339. package/dist/react/hooks/index.js +0 -21
  340. package/dist/react/hooks/use-abort-controller.cjs +0 -15
  341. package/dist/react/hooks/use-abort-controller.d.cts +0 -2
  342. package/dist/react/hooks/use-abort-controller.d.cts.map +0 -1
  343. package/dist/react/hooks/use-abort-controller.d.ts +0 -2
  344. package/dist/react/hooks/use-abort-controller.d.ts.map +0 -1
  345. package/dist/react/hooks/use-abort-controller.js +0 -11
  346. package/dist/react/hooks/use-abort-signal.cjs +0 -8
  347. package/dist/react/hooks/use-abort-signal.d.cts +0 -2
  348. package/dist/react/hooks/use-abort-signal.d.cts.map +0 -1
  349. package/dist/react/hooks/use-abort-signal.d.ts +0 -2
  350. package/dist/react/hooks/use-abort-signal.d.ts.map +0 -1
  351. package/dist/react/hooks/use-abort-signal.js +0 -4
  352. package/dist/react/hooks/use-click-outside.cjs +0 -17
  353. package/dist/react/hooks/use-click-outside.d.cts +0 -9
  354. package/dist/react/hooks/use-click-outside.d.cts.map +0 -1
  355. package/dist/react/hooks/use-click-outside.d.ts +0 -9
  356. package/dist/react/hooks/use-click-outside.d.ts.map +0 -1
  357. package/dist/react/hooks/use-click-outside.js +0 -13
  358. package/dist/react/hooks/use-constant.cjs +0 -19
  359. package/dist/react/hooks/use-constant.d.cts +0 -9
  360. package/dist/react/hooks/use-constant.d.cts.map +0 -1
  361. package/dist/react/hooks/use-constant.d.ts +0 -9
  362. package/dist/react/hooks/use-constant.d.ts.map +0 -1
  363. package/dist/react/hooks/use-define-ref.cjs +0 -19
  364. package/dist/react/hooks/use-define-ref.d.cts +0 -10
  365. package/dist/react/hooks/use-define-ref.d.cts.map +0 -1
  366. package/dist/react/hooks/use-define-ref.d.ts +0 -10
  367. package/dist/react/hooks/use-define-ref.d.ts.map +0 -1
  368. package/dist/react/hooks/use-element-ref.cjs +0 -12
  369. package/dist/react/hooks/use-element-ref.d.cts +0 -2
  370. package/dist/react/hooks/use-element-ref.d.cts.map +0 -1
  371. package/dist/react/hooks/use-element-ref.d.ts +0 -2
  372. package/dist/react/hooks/use-element-ref.d.ts.map +0 -1
  373. package/dist/react/hooks/use-element-ref.js +0 -8
  374. package/dist/react/hooks/use-event-listener.cjs +0 -17
  375. package/dist/react/hooks/use-event-listener.d.cts +0 -8
  376. package/dist/react/hooks/use-event-listener.d.cts.map +0 -1
  377. package/dist/react/hooks/use-event-listener.d.ts +0 -8
  378. package/dist/react/hooks/use-event-listener.d.ts.map +0 -1
  379. package/dist/react/hooks/use-event-listener.js +0 -13
  380. package/dist/react/hooks/use-event.cjs +0 -23
  381. package/dist/react/hooks/use-event.d.cts +0 -3
  382. package/dist/react/hooks/use-event.d.cts.map +0 -1
  383. package/dist/react/hooks/use-event.d.ts +0 -3
  384. package/dist/react/hooks/use-event.d.ts.map +0 -1
  385. package/dist/react/hooks/use-event.js +0 -19
  386. package/dist/react/hooks/use-flag.cjs +0 -19
  387. package/dist/react/hooks/use-flag.d.cts +0 -8
  388. package/dist/react/hooks/use-flag.d.cts.map +0 -1
  389. package/dist/react/hooks/use-flag.d.ts +0 -8
  390. package/dist/react/hooks/use-flag.d.ts.map +0 -1
  391. package/dist/react/hooks/use-flag.js +0 -15
  392. package/dist/react/hooks/use-force-update.cjs +0 -11
  393. package/dist/react/hooks/use-force-update.d.cts +0 -2
  394. package/dist/react/hooks/use-force-update.d.cts.map +0 -1
  395. package/dist/react/hooks/use-force-update.d.ts +0 -2
  396. package/dist/react/hooks/use-force-update.d.ts.map +0 -1
  397. package/dist/react/hooks/use-force-update.js +0 -7
  398. package/dist/react/hooks/use-initial-height.cjs +0 -15
  399. package/dist/react/hooks/use-initial-height.d.cts +0 -5
  400. package/dist/react/hooks/use-initial-height.d.cts.map +0 -1
  401. package/dist/react/hooks/use-initial-height.d.ts +0 -5
  402. package/dist/react/hooks/use-initial-height.d.ts.map +0 -1
  403. package/dist/react/hooks/use-initial-height.js +0 -11
  404. package/dist/react/hooks/use-instance.cjs +0 -31
  405. package/dist/react/hooks/use-instance.d.cts +0 -27
  406. package/dist/react/hooks/use-instance.d.cts.map +0 -1
  407. package/dist/react/hooks/use-instance.d.ts +0 -27
  408. package/dist/react/hooks/use-instance.d.ts.map +0 -1
  409. package/dist/react/hooks/use-intersection-observer.cjs +0 -14
  410. package/dist/react/hooks/use-intersection-observer.d.cts +0 -2
  411. package/dist/react/hooks/use-intersection-observer.d.cts.map +0 -1
  412. package/dist/react/hooks/use-intersection-observer.d.ts +0 -2
  413. package/dist/react/hooks/use-intersection-observer.d.ts.map +0 -1
  414. package/dist/react/hooks/use-intersection-observer.js +0 -10
  415. package/dist/react/hooks/use-last-defined-value.cjs +0 -12
  416. package/dist/react/hooks/use-last-defined-value.d.cts +0 -2
  417. package/dist/react/hooks/use-last-defined-value.d.cts.map +0 -1
  418. package/dist/react/hooks/use-last-defined-value.d.ts +0 -2
  419. package/dist/react/hooks/use-last-defined-value.d.ts.map +0 -1
  420. package/dist/react/hooks/use-last-defined-value.js +0 -8
  421. package/dist/react/hooks/use-last-value-ref.cjs +0 -12
  422. package/dist/react/hooks/use-last-value-ref.d.cts +0 -2
  423. package/dist/react/hooks/use-last-value-ref.d.cts.map +0 -1
  424. package/dist/react/hooks/use-last-value-ref.d.ts +0 -2
  425. package/dist/react/hooks/use-last-value-ref.d.ts.map +0 -1
  426. package/dist/react/hooks/use-last-value-ref.js +0 -8
  427. package/dist/react/hooks/use-life-cycle.cjs +0 -14
  428. package/dist/react/hooks/use-life-cycle.d.cts +0 -5
  429. package/dist/react/hooks/use-life-cycle.d.cts.map +0 -1
  430. package/dist/react/hooks/use-life-cycle.d.ts +0 -5
  431. package/dist/react/hooks/use-life-cycle.d.ts.map +0 -1
  432. package/dist/react/hooks/use-life-cycle.js +0 -10
  433. package/dist/react/hooks/use-resize-observer.cjs +0 -15
  434. package/dist/react/hooks/use-resize-observer.d.cts +0 -2
  435. package/dist/react/hooks/use-resize-observer.d.cts.map +0 -1
  436. package/dist/react/hooks/use-resize-observer.d.ts +0 -2
  437. package/dist/react/hooks/use-resize-observer.d.ts.map +0 -1
  438. package/dist/react/hooks/use-resize-observer.js +0 -11
  439. package/dist/react/hooks/use-sync-ref.cjs +0 -10
  440. package/dist/react/hooks/use-sync-ref.d.cts +0 -2
  441. package/dist/react/hooks/use-sync-ref.d.cts.map +0 -1
  442. package/dist/react/hooks/use-sync-ref.d.ts +0 -2
  443. package/dist/react/hooks/use-sync-ref.d.ts.map +0 -1
  444. package/dist/react/hooks/use-sync-ref.js +0 -6
  445. package/dist/react/hooks/use-toggle.cjs +0 -10
  446. package/dist/react/hooks/use-toggle.d.cts +0 -2
  447. package/dist/react/hooks/use-toggle.d.cts.map +0 -1
  448. package/dist/react/hooks/use-toggle.d.ts +0 -2
  449. package/dist/react/hooks/use-toggle.d.ts.map +0 -1
  450. package/dist/react/hooks/use-toggle.js +0 -6
  451. package/dist/react/hooks/use-value.cjs +0 -12
  452. package/dist/react/hooks/use-value.d.cts +0 -5
  453. package/dist/react/hooks/use-value.d.cts.map +0 -1
  454. package/dist/react/hooks/use-value.d.ts +0 -5
  455. package/dist/react/hooks/use-value.d.ts.map +0 -1
  456. package/dist/react/hooks/use-value.js +0 -8
  457. package/dist/react/hooks/use-visibility-state.cjs +0 -18
  458. package/dist/react/hooks/use-visibility-state.d.cts +0 -2
  459. package/dist/react/hooks/use-visibility-state.d.cts.map +0 -1
  460. package/dist/react/hooks/use-visibility-state.d.ts +0 -2
  461. package/dist/react/hooks/use-visibility-state.d.ts.map +0 -1
  462. package/dist/react/hooks/use-visibility-state.js +0 -14
  463. package/dist/react/index.cjs +0 -17
  464. package/dist/react/index.d.cts +0 -2
  465. package/dist/react/index.d.cts.map +0 -1
  466. package/dist/react/index.d.ts +0 -2
  467. package/dist/react/index.d.ts.map +0 -1
  468. package/dist/react/index.js +0 -1
  469. package/dist/sound.cjs +0 -16
  470. package/dist/sound.d.cts +0 -7
  471. package/dist/sound.d.cts.map +0 -1
  472. package/dist/sound.d.ts +0 -7
  473. package/dist/sound.d.ts.map +0 -1
  474. package/dist/sound.js +0 -12
  475. package/dist/storage.cjs +0 -48
  476. package/dist/storage.d.cts +0 -39
  477. package/dist/storage.d.cts.map +0 -1
  478. package/dist/storage.d.ts +0 -39
  479. package/dist/storage.d.ts.map +0 -1
  480. package/dist/storage.js +0 -43
  481. package/dist/text.cjs +0 -53
  482. package/dist/text.d.cts +0 -15
  483. package/dist/text.d.cts.map +0 -1
  484. package/dist/text.d.ts +0 -15
  485. package/dist/text.d.ts.map +0 -1
  486. package/dist/text.js +0 -48
  487. package/dist/type-guard/_exports.cjs +0 -129
  488. package/dist/type-guard/_exports.d.cts +0 -86
  489. package/dist/type-guard/_exports.d.cts.map +0 -1
  490. package/dist/type-guard/_exports.d.ts +0 -86
  491. package/dist/type-guard/_exports.d.ts.map +0 -1
  492. package/dist/type-guard/_exports.js +0 -125
  493. package/dist/type-guard/index.cjs +0 -40
  494. package/dist/type-guard/index.d.cts +0 -3
  495. package/dist/type-guard/index.d.cts.map +0 -1
  496. package/dist/type-guard/index.d.ts +0 -3
  497. package/dist/type-guard/index.d.ts.map +0 -1
  498. package/dist/utils/types.cjs +0 -2
  499. package/dist/utils/types.d.cts +0 -395
  500. package/dist/utils/types.d.cts.map +0 -1
  501. package/dist/utils/types.d.ts +0 -395
  502. package/dist/utils/types.d.ts.map +0 -1
  503. package/dist/utils/types.js +0 -1
  504. package/dist/vibrate.cjs +0 -12
  505. package/dist/vibrate.d.cts +0 -5
  506. package/dist/vibrate.d.cts.map +0 -1
  507. package/dist/vibrate.d.ts +0 -5
  508. package/dist/vibrate.d.ts.map +0 -1
  509. package/dist/vibrate.js +0 -8
  510. package/utility-types.d.ts +0 -395
@@ -0,0 +1,236 @@
1
+ import dayjs, { type Dayjs, type ManipulateType } from 'dayjs';
2
+ import duration from 'dayjs/plugin/duration.js';
3
+ import relativeTime from 'dayjs/plugin/relativeTime.js';
4
+
5
+ import { format } from './format/index.js';
6
+ import { unitsToMs } from './ms.js';
7
+ import { declension } from './text.js';
8
+ import { typeGuard } from './type-guard/index.js';
9
+ import type { Maybe } from './utils/types.js';
10
+
11
+ import 'dayjs/locale/ru.js';
12
+
13
+ dayjs.extend(relativeTime);
14
+ dayjs.extend(duration);
15
+ dayjs.locale('ru');
16
+
17
+ const toLibFormat = (
18
+ value: Maybe<RawDateToFormat>,
19
+ asTime?: boolean,
20
+ ): Dayjs => {
21
+ if (typeGuard.isNumber(value)) {
22
+ if (asTime) {
23
+ return dayjs.duration(value) as unknown as Dayjs;
24
+ }
25
+ return dayjs(value);
26
+ } else if (dayjs.isDayjs(value)) {
27
+ return value;
28
+ } else {
29
+ return dayjs(value);
30
+ }
31
+ };
32
+
33
+ export type RawDateToFormat = Date | string | number | Dayjs;
34
+
35
+ export const formatDate = (
36
+ value: Maybe<RawDateToFormat>,
37
+ settings?: Maybe<{
38
+ format?:
39
+ | 'human'
40
+ | 'full'
41
+ | 'short'
42
+ | 'day'
43
+ | 'day-only'
44
+ | 'date'
45
+ | 'month'
46
+ | 'spent-time'
47
+ | 'time'
48
+ | 'time-short';
49
+ pattern?: string;
50
+ asTime?: boolean;
51
+ }>,
52
+ ) => {
53
+ const dateFormat = settings?.format;
54
+ const datePattern = settings?.pattern;
55
+ const asTime = settings?.asTime;
56
+
57
+ value = toLibFormat(value, asTime);
58
+
59
+ if (typeGuard.isUndefined(value) || !value.isValid()) {
60
+ return format.NO_VALUE;
61
+ }
62
+
63
+ if (datePattern) {
64
+ return value.format(datePattern);
65
+ }
66
+
67
+ switch (dateFormat) {
68
+ case 'human': {
69
+ return value.fromNow();
70
+ }
71
+ case 'spent-time': {
72
+ return value.fromNow(true);
73
+ }
74
+ case 'full': {
75
+ return value.format('DD MMM YYYY HH:mm:ss');
76
+ }
77
+ case 'short': {
78
+ return value.format('DD MMM HH:mm');
79
+ }
80
+ case 'time': {
81
+ return value.format('HH:mm:ss');
82
+ }
83
+ case 'time-short': {
84
+ return value.format('HH:mm');
85
+ }
86
+ case 'day': {
87
+ return value.format('DD MMM YYYY');
88
+ }
89
+ case 'month': {
90
+ return value.format('MMMM YYYY');
91
+ }
92
+ default: {
93
+ return value.format('DD.MM.YYYY');
94
+ }
95
+ }
96
+ };
97
+
98
+ export const dayTimeDuration = (timeInMs: number) => {
99
+ let left = Math.max(timeInMs, 0);
100
+
101
+ const days = Math.floor(left / unitsToMs.day);
102
+ left = left % unitsToMs.day;
103
+
104
+ const hours = Math.floor(left / unitsToMs.hour);
105
+ left = left % unitsToMs.hour;
106
+
107
+ const minutes = Math.floor(left / unitsToMs.min);
108
+ left = left % unitsToMs.min;
109
+
110
+ const seconds = Math.floor(left / unitsToMs.sec);
111
+ left = left % unitsToMs.sec;
112
+
113
+ const milliseconds = Math.floor(left);
114
+
115
+ return {
116
+ days,
117
+ hours,
118
+ minutes,
119
+ seconds,
120
+ milliseconds,
121
+ };
122
+ };
123
+
124
+ type DateChangeParam = [amount: number, unit?: Maybe<ManipulateType>];
125
+
126
+ export const changeDate = (
127
+ date: Maybe<RawDateToFormat>,
128
+ ...args: [
129
+ ...DateChangeParam,
130
+ ...Partial<DateChangeParam>,
131
+ ...Partial<DateChangeParam>,
132
+ ...Partial<DateChangeParam>,
133
+ ...Partial<DateChangeParam>,
134
+ ...Partial<DateChangeParam>,
135
+ ]
136
+ ) => {
137
+ let wrappedDate = toLibFormat(date);
138
+
139
+ for (let i = 0; i < args.length; i += 2) {
140
+ const amount = args[i] as DateChangeParam[0];
141
+ const unit = args[i + 1] as DateChangeParam[1];
142
+ if (unit != null) {
143
+ wrappedDate = wrappedDate.add(amount, unit);
144
+ }
145
+ }
146
+
147
+ return wrappedDate.toDate();
148
+ };
149
+
150
+ export const timeDuration = (timeInMs: number) => {
151
+ const { days, hours, milliseconds, minutes, seconds } =
152
+ dayTimeDuration(timeInMs);
153
+
154
+ return {
155
+ hours: hours + unitsToMs.day * days,
156
+ milliseconds,
157
+ minutes,
158
+ seconds,
159
+ };
160
+ };
161
+
162
+ const durationFormatLabels = {
163
+ days: { compact: 'д', full: ['день', 'дня', 'дней'] },
164
+ hours: { compact: 'ч', full: ['час', 'часа', 'часов'] },
165
+ minutes: { compact: 'мин', full: ['минута', 'минуты', 'минут'] },
166
+ seconds: { compact: 'сек', full: ['секунда', 'секунды', 'секунд'] },
167
+ } as const;
168
+
169
+ export function getFormatDuration(
170
+ dateA: Date,
171
+ dateB: Date,
172
+ compact?: boolean,
173
+ ): string;
174
+ export function getFormatDuration(ms: number, compact?: boolean): string;
175
+
176
+ export function getFormatDuration(...args: any[]): string {
177
+ let compact = false;
178
+ let diff = 0;
179
+
180
+ if (args[0] instanceof Date) {
181
+ const startedDate = dayjs(args[0]);
182
+ const endedDate = dayjs(args[1]);
183
+
184
+ diff = endedDate.diff(startedDate, 'ms');
185
+ compact = args[2] === true;
186
+ } else {
187
+ diff = args[0];
188
+ compact = args[1] === true;
189
+ }
190
+
191
+ const { days, hours, minutes, seconds } = dayTimeDuration(diff);
192
+
193
+ const formattedParts: string[] = [];
194
+
195
+ if (days) {
196
+ if (compact) {
197
+ formattedParts.push(`${days} ${durationFormatLabels.days.compact}`);
198
+ } else {
199
+ formattedParts.push(
200
+ `${days} ${declension(days, durationFormatLabels.days.full)}`,
201
+ );
202
+ }
203
+ }
204
+
205
+ if (hours) {
206
+ if (compact) {
207
+ formattedParts.push(`${hours} ${durationFormatLabels.hours.compact}`);
208
+ } else {
209
+ formattedParts.push(
210
+ `${hours} ${declension(hours, durationFormatLabels.hours.full)}`,
211
+ );
212
+ }
213
+ }
214
+
215
+ if (minutes) {
216
+ if (compact) {
217
+ formattedParts.push(`${minutes} ${durationFormatLabels.minutes.compact}`);
218
+ } else {
219
+ formattedParts.push(
220
+ `${minutes} ${declension(minutes, durationFormatLabels.minutes.full)}`,
221
+ );
222
+ }
223
+ }
224
+
225
+ if (seconds) {
226
+ if (compact) {
227
+ formattedParts.push(`${seconds} ${durationFormatLabels.seconds.compact}`);
228
+ } else {
229
+ formattedParts.push(
230
+ `${seconds} ${declension(seconds, durationFormatLabels.seconds.full)}`,
231
+ );
232
+ }
233
+ }
234
+
235
+ return formattedParts.join(' ');
236
+ }
package/src/device.ts ADDED
@@ -0,0 +1,42 @@
1
+ export const getUserAgent = () =>
2
+ (
3
+ navigator.userAgent ||
4
+ navigator.vendor ||
5
+ // @ts-expect-error skip opera
6
+ globalThis.opera ||
7
+ ''
8
+ ).toLowerCase();
9
+
10
+ export const checkIsMobileDevice = () => {
11
+ const userAgent = getUserAgent();
12
+
13
+ if (
14
+ /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(
15
+ userAgent || '',
16
+ ) ||
17
+ /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(
18
+ (userAgent || '').slice(0, 4),
19
+ )
20
+ ) {
21
+ return true;
22
+ }
23
+
24
+ return false;
25
+ };
26
+
27
+ export const checkIsTabletDevice = () => {
28
+ const userAgent = getUserAgent();
29
+
30
+ return /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(
31
+ userAgent,
32
+ );
33
+ };
34
+
35
+ export const checkIsTouchDevice = () =>
36
+ checkIsMobileDevice() || checkIsTabletDevice();
37
+
38
+ export const isMobileDevice = checkIsMobileDevice();
39
+
40
+ export const isTabletDevice = checkIsTabletDevice();
41
+
42
+ export const isTouchDevice = isMobileDevice || isTabletDevice;
@@ -0,0 +1,270 @@
1
+ import type { AnyObject } from './utils/types.js';
2
+
3
+ const DMap: AnyObject = {
4
+ 0: 0,
5
+ 1: 1,
6
+ 2: 2,
7
+ 3: 3,
8
+ 4: 4,
9
+ 5: 5,
10
+ 6: 6,
11
+ 7: 7,
12
+ 8: 8,
13
+ 9: 9,
14
+ 10: 10,
15
+ 11: 11,
16
+ 12: 12,
17
+ 13: 13,
18
+ 14: 14,
19
+ 15: 15,
20
+ 16: 16,
21
+ 17: 17,
22
+ 18: 18,
23
+ 19: 19,
24
+ 20: 20,
25
+ 21: 21,
26
+ 22: 22,
27
+ 23: 23,
28
+ 24: 24,
29
+ 25: 25,
30
+ 26: 26,
31
+ 27: 27,
32
+ 28: 28,
33
+ 29: 29,
34
+ 30: 30,
35
+ 31: 31,
36
+ 32: 32,
37
+ 33: 33,
38
+ 34: 34,
39
+ 35: 35,
40
+ 36: 36,
41
+ 37: 37,
42
+ 38: 38,
43
+ 39: 39,
44
+ 40: 40,
45
+ 41: 41,
46
+ 42: 42,
47
+ 43: 43,
48
+ 44: 44,
49
+ 45: 45,
50
+ 46: 46,
51
+ 47: 47,
52
+ 48: 48,
53
+ 49: 49,
54
+ 50: 50,
55
+ 51: 51,
56
+ 52: 52,
57
+ 53: 53,
58
+ 54: 54,
59
+ 55: 55,
60
+ 56: 56,
61
+ 57: 57,
62
+ 58: 58,
63
+ 59: 59,
64
+ 60: 60,
65
+ 61: 61,
66
+ 62: 62,
67
+ 63: 63,
68
+ 64: 64,
69
+ 65: 65,
70
+ 66: 66,
71
+ 67: 67,
72
+ 68: 68,
73
+ 69: 69,
74
+ 70: 70,
75
+ 71: 71,
76
+ 72: 72,
77
+ 73: 73,
78
+ 74: 74,
79
+ 75: 75,
80
+ 76: 76,
81
+ 77: 77,
82
+ 78: 78,
83
+ 79: 79,
84
+ 80: 80,
85
+ 81: 81,
86
+ 82: 82,
87
+ 83: 83,
88
+ 84: 84,
89
+ 85: 85,
90
+ 86: 86,
91
+ 87: 87,
92
+ 88: 88,
93
+ 89: 89,
94
+ 90: 90,
95
+ 91: 91,
96
+ 92: 92,
97
+ 93: 93,
98
+ 94: 94,
99
+ 95: 95,
100
+ 96: 96,
101
+ 97: 97,
102
+ 98: 98,
103
+ 99: 99,
104
+ 100: 100,
105
+ 101: 101,
106
+ 102: 102,
107
+ 103: 103,
108
+ 104: 104,
109
+ 105: 105,
110
+ 106: 106,
111
+ 107: 107,
112
+ 108: 108,
113
+ 109: 109,
114
+ 110: 110,
115
+ 111: 111,
116
+ 112: 112,
117
+ 113: 113,
118
+ 114: 114,
119
+ 115: 115,
120
+ 116: 116,
121
+ 117: 117,
122
+ 118: 118,
123
+ 119: 119,
124
+ 120: 120,
125
+ 121: 121,
126
+ 122: 122,
127
+ 123: 123,
128
+ 124: 124,
129
+ 125: 125,
130
+ 126: 126,
131
+ 127: 127,
132
+ 1027: 129,
133
+ 8225: 135,
134
+ 1046: 198,
135
+ 8222: 132,
136
+ 1047: 199,
137
+ 1168: 165,
138
+ 1048: 200,
139
+ 1113: 154,
140
+ 1049: 201,
141
+ 1045: 197,
142
+ 1050: 202,
143
+ 1028: 170,
144
+ 160: 160,
145
+ 1040: 192,
146
+ 1051: 203,
147
+ 164: 164,
148
+ 166: 166,
149
+ 167: 167,
150
+ 169: 169,
151
+ 171: 171,
152
+ 172: 172,
153
+ 173: 173,
154
+ 174: 174,
155
+ 1053: 205,
156
+ 176: 176,
157
+ 177: 177,
158
+ 1114: 156,
159
+ 181: 181,
160
+ 182: 182,
161
+ 183: 183,
162
+ 8221: 148,
163
+ 187: 187,
164
+ 1029: 189,
165
+ 1056: 208,
166
+ 1057: 209,
167
+ 1058: 210,
168
+ 8364: 136,
169
+ 1112: 188,
170
+ 1115: 158,
171
+ 1059: 211,
172
+ 1060: 212,
173
+ 1030: 178,
174
+ 1061: 213,
175
+ 1062: 214,
176
+ 1063: 215,
177
+ 1116: 157,
178
+ 1064: 216,
179
+ 1065: 217,
180
+ 1031: 175,
181
+ 1066: 218,
182
+ 1067: 219,
183
+ 1068: 220,
184
+ 1069: 221,
185
+ 1070: 222,
186
+ 1032: 163,
187
+ 8226: 149,
188
+ 1071: 223,
189
+ 1072: 224,
190
+ 8482: 153,
191
+ 1073: 225,
192
+ 8240: 137,
193
+ 1118: 162,
194
+ 1074: 226,
195
+ 1110: 179,
196
+ 8230: 133,
197
+ 1075: 227,
198
+ 1033: 138,
199
+ 1076: 228,
200
+ 1077: 229,
201
+ 8211: 150,
202
+ 1078: 230,
203
+ 1119: 159,
204
+ 1079: 231,
205
+ 1042: 194,
206
+ 1080: 232,
207
+ 1034: 140,
208
+ 1025: 168,
209
+ 1081: 233,
210
+ 1082: 234,
211
+ 8212: 151,
212
+ 1083: 235,
213
+ 1169: 180,
214
+ 1084: 236,
215
+ 1052: 204,
216
+ 1085: 237,
217
+ 1035: 142,
218
+ 1086: 238,
219
+ 1087: 239,
220
+ 1088: 240,
221
+ 1089: 241,
222
+ 1090: 242,
223
+ 1036: 141,
224
+ 1041: 193,
225
+ 1091: 243,
226
+ 1092: 244,
227
+ 8224: 134,
228
+ 1093: 245,
229
+ 8470: 185,
230
+ 1094: 246,
231
+ 1054: 206,
232
+ 1095: 247,
233
+ 1096: 248,
234
+ 8249: 139,
235
+ 1097: 249,
236
+ 1098: 250,
237
+ 1044: 196,
238
+ 1099: 251,
239
+ 1111: 191,
240
+ 1055: 207,
241
+ 1100: 252,
242
+ 1038: 161,
243
+ 8220: 147,
244
+ 1101: 253,
245
+ 8250: 155,
246
+ 1102: 254,
247
+ 8216: 145,
248
+ 1103: 255,
249
+ 1043: 195,
250
+ 1105: 184,
251
+ 1039: 143,
252
+ 1026: 128,
253
+ 1106: 144,
254
+ 8218: 130,
255
+ 1107: 131,
256
+ 8217: 146,
257
+ 1108: 186,
258
+ 1109: 190,
259
+ };
260
+
261
+ export function unicodeToWin1251(s: string) {
262
+ const L = [];
263
+ for (let i = 0; i < s.length; i++) {
264
+ const ord = s.charCodeAt(i);
265
+ if (!(ord in DMap))
266
+ throw new Error(`Character ${s.charAt(i)} isn't supported by win1251!`);
267
+ L.push(String.fromCharCode(DMap[ord]));
268
+ }
269
+ return L.join('');
270
+ }
package/src/errors.ts ADDED
@@ -0,0 +1,40 @@
1
+ import { typeGuard } from './type-guard/index.js';
2
+ import type { Maybe } from './utils/types.js';
3
+
4
+ type GetErrorTextEnhancer = (error: any) => string;
5
+ type GetErrorTextFormatErrorFn = (error: Error) => string;
6
+
7
+ /**
8
+ * Universal function for transforming any errors into readable error text
9
+ *
10
+ * This function can be enhanced with custom handlers using:
11
+ * - `getErrorText.unknownErrorText`
12
+ * - `getErrorText.formatError`
13
+ * - `getErrorText.enhance`
14
+ */
15
+ export const getErrorText = (error: unknown) => {
16
+ if (!error) {
17
+ return getErrorText.unknownErrorText;
18
+ }
19
+
20
+ if (typeGuard.isString(error)) {
21
+ return error || getErrorText.unknownErrorText;
22
+ }
23
+
24
+ if (error instanceof Error) {
25
+ return (
26
+ (getErrorText.formatError?.(error) ?? error.message) ||
27
+ getErrorText.unknownErrorText
28
+ );
29
+ }
30
+
31
+ if (getErrorText.enhance) {
32
+ return getErrorText.enhance(error) ?? getErrorText.unknownErrorText;
33
+ } else {
34
+ return getErrorText.unknownErrorText;
35
+ }
36
+ };
37
+
38
+ getErrorText.unknownErrorText = '';
39
+ getErrorText.formatError = null as Maybe<GetErrorTextFormatErrorFn>;
40
+ getErrorText.enhance = null as Maybe<GetErrorTextEnhancer>;
package/src/file.ts ADDED
@@ -0,0 +1,25 @@
1
+ export const getBase64FromFile = (file: File) => {
2
+ return new Promise<string>((resolve, reject) => {
3
+ const reader = new FileReader();
4
+ reader.readAsDataURL(file);
5
+ reader.onload = () => {
6
+ resolve(reader.result!.toString());
7
+ };
8
+ reader.onerror = (error) => {
9
+ reject(error);
10
+ };
11
+ });
12
+ };
13
+
14
+ export const getTextFromFile = (file: File, encoding?: string) => {
15
+ return new Promise<string>((resolve, reject) => {
16
+ const reader = new FileReader();
17
+ reader.readAsText(file, encoding);
18
+ reader.onload = () => {
19
+ resolve(reader.result!.toString());
20
+ };
21
+ reader.onerror = (error) => {
22
+ reject(error);
23
+ };
24
+ });
25
+ };
@@ -0,0 +1,4 @@
1
+ export * from './constants.js';
2
+ export * from './number.js';
3
+ export * from './percent.js';
4
+ export * from './skip-spaces.js';
@@ -1,3 +1,5 @@
1
1
  export const NO_VALUE = '–'; // en-dash
2
+
2
3
  export const HYPHEN = '-';
4
+
3
5
  export const INFINITY = '∞';
@@ -1,4 +1,5 @@
1
1
  // This way is more treeshakable than collecting
2
2
  // it into one exportable object export const format
3
- import * as format from "./_exports.js";
3
+ import * as format from './_exports.js';
4
+
4
5
  export { format };
@@ -0,0 +1,16 @@
1
+ import { describe, expect, test } from 'vitest';
2
+
3
+ import { number } from './number';
4
+
5
+ describe('format.number', () => {
6
+ test('[BUG] Infinite formatting of the number 23162 with an empty delimiter', () => {
7
+ expect(number(23_162, { digits: 4, cutZeros: true, delimiter: '' })).toBe(
8
+ '23162',
9
+ );
10
+ });
11
+ test('Formatting the number 23162', () => {
12
+ expect(number(23_162, { digits: 4, cutZeros: true, delimiter: '_' })).toBe(
13
+ '23_162',
14
+ );
15
+ });
16
+ });