@wener/utils 1.1.51 → 1.1.53

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 (499) hide show
  1. package/lib/arrays/MaybeArray.js +58 -8
  2. package/lib/arrays/arrayFromAsync.js +254 -6
  3. package/lib/asyncs/AsyncInterval.js +145 -9
  4. package/lib/asyncs/MaybePromise.js +0 -2
  5. package/lib/asyncs/Promises.js +95 -48
  6. package/lib/asyncs/createAsyncIterator.js +313 -23
  7. package/lib/asyncs/createLazyPromise.js +72 -31
  8. package/lib/asyncs/createLazyPromise.test.js +367 -0
  9. package/lib/asyncs/firstOfAsyncIterator.js +6 -6
  10. package/lib/asyncs/generatorOfStream.js +125 -14
  11. package/lib/asyncs/isIterator.js +1 -3
  12. package/lib/asyncs/isPromise.js +2 -4
  13. package/lib/asyncs/isThenable.js +0 -2
  14. package/lib/asyncs/nextOfAsyncIterator.js +15 -9
  15. package/lib/asyncs/promiseOfCallback.js +2 -4
  16. package/lib/asyncs/timeout.js +122 -13
  17. package/lib/browsers/copy.js +7 -8
  18. package/lib/browsers/download.js +215 -40
  19. package/lib/browsers/getFileFromDataTransfer.js +17 -14
  20. package/lib/browsers/loaders.js +251 -18
  21. package/lib/crypto/base.js +3 -3
  22. package/lib/crypto/getNodeCrypto.js +3 -5
  23. package/lib/crypto/hashing.js +236 -30
  24. package/lib/crypto/hashing.test.js +323 -0
  25. package/lib/crypto/md5.bench.js +11 -11
  26. package/lib/crypto/md5.d.js +0 -2
  27. package/lib/crypto/md5.js +0 -2
  28. package/lib/crypto/md5.test.js +7 -0
  29. package/lib/crypto/pem/pem.js +197 -35
  30. package/lib/crypto/pem/pem.test.js +104 -0
  31. package/lib/crypto/randomUUIDv7.js +0 -2
  32. package/lib/crypto/ulid.js +84 -48
  33. package/lib/crypto/ulid.test.js +115 -0
  34. package/lib/emitter/types.js +0 -2
  35. package/lib/errors/DetailError.js +297 -0
  36. package/lib/errors/Errors.js +2 -202
  37. package/lib/errors/Errors.mod.js +206 -0
  38. package/lib/errors/Errors.test.js +24 -0
  39. package/lib/fetch/HttpStatus.js +1 -3
  40. package/lib/fetch/createFetchWith.js +188 -19
  41. package/lib/fetch/createFetchWithLogging.js +17 -16
  42. package/lib/fetch/createFetchWithRetry.js +40 -24
  43. package/lib/fetch/dumpRequest.js +467 -41
  44. package/lib/fetch/dumpRequest.test.js +384 -0
  45. package/lib/fetch/dumpResponse.js +271 -16
  46. package/lib/fetch/dumpResponse.test.js +393 -0
  47. package/lib/fetch/http.types.js +0 -2
  48. package/lib/fetch/index.js +5 -7
  49. package/lib/fetch/isTextContentType.js +5 -0
  50. package/lib/fetch/resolveRequest.js +7 -0
  51. package/lib/fetch/types.js +0 -2
  52. package/lib/i18n/createTranslate.js +40 -20
  53. package/lib/i18n/createTranslate.test.js +177 -0
  54. package/lib/index.js +74 -76
  55. package/lib/io/AbstractEncoding.js +0 -2
  56. package/lib/io/ArrayBuffer.test-d.js +4 -6
  57. package/lib/io/ArrayBuffers.base64.test.js +60 -0
  58. package/lib/io/ArrayBuffers.js +2 -334
  59. package/lib/io/ArrayBuffers.mod.js +531 -0
  60. package/lib/io/ArrayBuffers.test.js +77 -0
  61. package/lib/io/Buffer.js +190 -20
  62. package/lib/io/Buffer.test.js +22 -0
  63. package/lib/io/ByteBuffer.js +752 -441
  64. package/lib/io/ByteBuffer.test.js +184 -0
  65. package/lib/io/base64.js +17 -19
  66. package/lib/io/dump.js +16 -16
  67. package/lib/io/isBuffer.js +2 -3
  68. package/lib/io/isBuffer.test.js +8 -0
  69. package/lib/io/isTransferable.js +16 -8
  70. package/lib/io/isTransferable.test.js +17 -0
  71. package/lib/io/parseDataUri.js +288 -40
  72. package/lib/io/parseDataUri.test.js +286 -0
  73. package/lib/io/types.js +1 -0
  74. package/lib/langs/AsyncCloser.js +270 -34
  75. package/lib/langs/Closer.js +95 -29
  76. package/lib/langs/MaybeFunction.js +38 -5
  77. package/lib/langs/classOf.js +0 -2
  78. package/lib/langs/deepEqual.js +82 -22
  79. package/lib/langs/deepEqual.test.js +11 -0
  80. package/lib/langs/deepFreeze.js +28 -9
  81. package/lib/langs/getGlobalStates.js +14 -10
  82. package/lib/langs/getObjectId.js +4 -6
  83. package/lib/langs/ifPresent.js +0 -2
  84. package/lib/langs/isClass.js +0 -2
  85. package/lib/langs/isDefined.js +0 -2
  86. package/lib/langs/isEmptyObject.js +1 -3
  87. package/lib/langs/isFunction.js +0 -2
  88. package/lib/langs/isNil.js +3 -0
  89. package/lib/langs/isPlainObject.js +2 -4
  90. package/lib/langs/langs.test.js +126 -0
  91. package/lib/langs/memoize.js +11 -7
  92. package/lib/langs/mixin.js +7 -4
  93. package/lib/langs/mixin.test.js +135 -0
  94. package/lib/langs/parseBoolean.js +11 -8
  95. package/lib/langs/shallowClone.js +5 -3
  96. package/lib/langs/shallowEqual.js +8 -6
  97. package/lib/libs/ms.js +28 -26
  98. package/lib/libs/ms.test.js +301 -0
  99. package/lib/logger/const.js +15 -0
  100. package/lib/logger/index.js +1 -0
  101. package/lib/logger/types.js +1 -0
  102. package/lib/maths/clamp.js +81 -12
  103. package/lib/maths/clamp.test.js +186 -0
  104. package/lib/maths/createRandom.test.js +36 -0
  105. package/lib/maths/random.js +162 -13
  106. package/lib/modules/isModule.js +0 -2
  107. package/lib/modules/parseModuleId.js +14 -15
  108. package/lib/modules/parseModuleId.test.js +153 -0
  109. package/lib/objects/computeIfAbsent.js +8 -3
  110. package/lib/objects/get.js +26 -8
  111. package/lib/objects/get.test-d.js +23 -25
  112. package/lib/objects/merge/index.js +1 -3
  113. package/lib/objects/merge/isMergeableObject.js +5 -3
  114. package/lib/objects/merge/merge.js +82 -26
  115. package/lib/objects/merge/merge.test.js +1397 -0
  116. package/lib/objects/parseObjectPath.js +47 -15
  117. package/lib/objects/parseObjectPath.test.js +138 -0
  118. package/lib/objects/set.js +25 -19
  119. package/lib/objects/set.test.js +522 -0
  120. package/lib/schema/typebox/index.js +2 -3
  121. package/lib/schema/typebox/typebox.js +6 -6
  122. package/lib/scripts/getGenerateContext.js +386 -77
  123. package/lib/server/crypto/md5.js +0 -2
  124. package/lib/server/fetch/createFetchWithProxy.js +2 -4
  125. package/lib/server/fetch/createFetchWithProxyByNodeFetch.js +258 -31
  126. package/lib/server/fetch/createFetchWithProxyByUndici.js +307 -49
  127. package/lib/server/getPackageDir.js +2 -3
  128. package/lib/server/index.js +5 -7
  129. package/lib/server/jsdom.js +1 -3
  130. package/lib/server/node-fetch.js +2 -4
  131. package/lib/server/polyfill/polyfillBrowser.js +163 -9
  132. package/lib/server/polyfill/polyfillBrowser.test.js +164 -0
  133. package/lib/server/polyfill/polyfillCrypto.js +157 -9
  134. package/lib/server/polyfill/polyfillFetch.js +13 -13
  135. package/lib/server/polyfill/polyfillJsDom.js +264 -58
  136. package/lib/server/polyfill/polyfillWebSocket.js +11 -11
  137. package/lib/server/ws.js +1 -3
  138. package/lib/strings/bytes.test.js +327 -0
  139. package/lib/strings/camelCase.js +23 -14
  140. package/lib/strings/formatBytes.js +29 -20
  141. package/lib/strings/parseBytes.js +54 -0
  142. package/lib/strings/renderTemplate.js +17 -12
  143. package/lib/strings/renderTemplate.test.js +104 -0
  144. package/lib/typedoc.js +2 -4
  145. package/lib/types.d.js +0 -2
  146. package/lib/validations/asserts.js +0 -2
  147. package/lib/validations/isUUID.js +0 -2
  148. package/lib/validations/isUUID.test.js +87 -0
  149. package/lib/validations/parseTimestamp.js +12 -7
  150. package/lib/validations/parseTimestamp.test.js +6 -0
  151. package/lib/web/getGlobalThis.js +3 -4
  152. package/lib/web/getRandomValues.js +28 -20
  153. package/lib/web/randomUUID.js +7 -8
  154. package/lib/web/requestIdleCallback.js +13 -9
  155. package/lib/web/structuredClone.js +35 -28
  156. package/lib/web/structuredClone.test.js +81 -0
  157. package/package.json +9 -14
  158. package/src/arrays/MaybeArray.ts +22 -22
  159. package/src/arrays/arrayFromAsync.ts +3 -3
  160. package/src/asyncs/AsyncInterval.ts +8 -8
  161. package/src/asyncs/Promises.ts +51 -51
  162. package/src/asyncs/createAsyncIterator.ts +33 -33
  163. package/src/asyncs/createLazyPromise.test.ts +73 -73
  164. package/src/asyncs/createLazyPromise.ts +68 -73
  165. package/src/asyncs/firstOfAsyncIterator.ts +5 -5
  166. package/src/asyncs/generatorOfStream.ts +12 -12
  167. package/src/asyncs/isIterator.ts +1 -1
  168. package/src/asyncs/isThenable.ts +2 -2
  169. package/src/asyncs/nextOfAsyncIterator.ts +20 -20
  170. package/src/asyncs/promiseOfCallback.ts +13 -13
  171. package/src/asyncs/timeout.ts +23 -23
  172. package/src/browsers/copy.ts +48 -48
  173. package/src/browsers/download.ts +38 -36
  174. package/src/browsers/getFileFromDataTransfer.ts +35 -35
  175. package/src/browsers/loaders.ts +49 -49
  176. package/src/crypto/base.ts +3 -3
  177. package/src/crypto/getNodeCrypto.ts +2 -2
  178. package/src/crypto/hashing.test.ts +33 -47
  179. package/src/crypto/hashing.ts +67 -67
  180. package/src/crypto/md5.bench.ts +20 -24
  181. package/src/crypto/md5.test.ts +3 -3
  182. package/src/crypto/pem/pem.test.ts +26 -42
  183. package/src/crypto/pem/pem.ts +65 -65
  184. package/src/crypto/ulid.test.ts +31 -31
  185. package/src/crypto/ulid.ts +116 -116
  186. package/src/emitter/types.ts +6 -6
  187. package/src/errors/DetailError.ts +151 -0
  188. package/src/errors/Errors.mod.ts +104 -0
  189. package/src/errors/Errors.test.ts +15 -15
  190. package/src/errors/Errors.ts +1 -247
  191. package/src/fetch/HttpStatus.ts +77 -77
  192. package/src/fetch/createFetchWith.ts +25 -25
  193. package/src/fetch/createFetchWithLogging.ts +12 -15
  194. package/src/fetch/createFetchWithRetry.ts +79 -79
  195. package/src/fetch/dumpRequest.test.ts +176 -0
  196. package/src/fetch/dumpRequest.ts +149 -52
  197. package/src/fetch/dumpResponse.test.ts +160 -0
  198. package/src/fetch/dumpResponse.ts +48 -20
  199. package/src/fetch/http.types.ts +35 -35
  200. package/src/fetch/isTextContentType.ts +12 -0
  201. package/src/fetch/resolveRequest.ts +1 -0
  202. package/src/fetch/types.ts +2 -2
  203. package/src/i18n/createTranslate.test.ts +90 -113
  204. package/src/i18n/createTranslate.ts +55 -55
  205. package/src/index.ts +17 -19
  206. package/src/io/AbstractEncoding.ts +12 -12
  207. package/src/io/ArrayBuffer.test-d.ts +1 -1
  208. package/src/io/ArrayBuffers.base64.test.ts +52 -52
  209. package/src/io/ArrayBuffers.mod.ts +670 -0
  210. package/src/io/ArrayBuffers.test.ts +14 -14
  211. package/src/io/ArrayBuffers.ts +1 -446
  212. package/src/io/Buffer.test.ts +17 -17
  213. package/src/io/Buffer.ts +17 -17
  214. package/src/io/ByteBuffer.test.ts +37 -37
  215. package/src/io/ByteBuffer.ts +574 -566
  216. package/src/io/base64.ts +46 -44
  217. package/src/io/dump.ts +22 -22
  218. package/src/io/isBuffer.test.ts +2 -2
  219. package/src/io/isBuffer.ts +1 -1
  220. package/src/io/isTransferable.test.ts +4 -4
  221. package/src/io/isTransferable.ts +29 -29
  222. package/src/io/parseDataUri.test.ts +22 -27
  223. package/src/io/parseDataUri.ts +57 -57
  224. package/src/io/types.ts +13 -0
  225. package/src/langs/AsyncCloser.ts +34 -34
  226. package/src/langs/Closer.ts +28 -28
  227. package/src/langs/MaybeFunction.ts +5 -5
  228. package/src/langs/classOf.ts +1 -1
  229. package/src/langs/deepEqual.test.ts +1 -12
  230. package/src/langs/deepEqual.ts +82 -82
  231. package/src/langs/deepFreeze.ts +11 -11
  232. package/src/langs/getGlobalStates.ts +16 -16
  233. package/src/langs/getObjectId.ts +10 -13
  234. package/src/langs/ifPresent.ts +2 -2
  235. package/src/langs/isClass.ts +1 -1
  236. package/src/langs/isDefined.ts +1 -1
  237. package/src/langs/isEmptyObject.ts +1 -1
  238. package/src/langs/isFunction.ts +1 -1
  239. package/src/langs/isNil.ts +3 -0
  240. package/src/langs/isPlainObject.ts +4 -4
  241. package/src/langs/langs.test.ts +18 -18
  242. package/src/langs/memoize.ts +21 -21
  243. package/src/langs/mixin.test.ts +22 -26
  244. package/src/langs/mixin.ts +6 -9
  245. package/src/langs/parseBoolean.ts +30 -26
  246. package/src/langs/shallowClone.ts +11 -11
  247. package/src/langs/shallowEqual.ts +19 -19
  248. package/src/libs/ms.test.ts +274 -274
  249. package/src/libs/ms.ts +137 -137
  250. package/src/logger/const.ts +18 -0
  251. package/src/logger/index.ts +2 -0
  252. package/src/logger/types.ts +10 -0
  253. package/src/maths/clamp.test.ts +18 -18
  254. package/src/maths/clamp.ts +17 -17
  255. package/src/maths/createRandom.test.ts +12 -0
  256. package/src/maths/random.ts +50 -14
  257. package/src/modules/isModule.ts +4 -4
  258. package/src/modules/parseModuleId.test.ts +61 -68
  259. package/src/modules/parseModuleId.ts +29 -43
  260. package/src/objects/computeIfAbsent.ts +10 -10
  261. package/src/objects/get.test-d.ts +33 -51
  262. package/src/objects/get.ts +31 -31
  263. package/src/objects/merge/isMergeableObject.ts +5 -5
  264. package/src/objects/merge/merge.test.ts +658 -880
  265. package/src/objects/merge/merge.ts +84 -84
  266. package/src/objects/parseObjectPath.test.ts +13 -13
  267. package/src/objects/parseObjectPath.ts +25 -25
  268. package/src/objects/set.test.ts +271 -366
  269. package/src/objects/set.ts +36 -36
  270. package/src/schema/typebox/typebox.ts +20 -26
  271. package/src/scripts/getGenerateContext.ts +79 -79
  272. package/src/server/crypto/md5.ts +1 -1
  273. package/src/server/fetch/createFetchWithProxyByNodeFetch.ts +28 -31
  274. package/src/server/fetch/createFetchWithProxyByUndici.ts +63 -69
  275. package/src/server/getPackageDir.ts +7 -7
  276. package/src/server/polyfill/polyfillBrowser.test.ts +10 -10
  277. package/src/server/polyfill/polyfillBrowser.ts +3 -3
  278. package/src/server/polyfill/polyfillCrypto.ts +6 -6
  279. package/src/server/polyfill/polyfillFetch.ts +11 -21
  280. package/src/server/polyfill/polyfillJsDom.ts +59 -71
  281. package/src/server/polyfill/polyfillWebSocket.ts +14 -14
  282. package/src/strings/bytes.test.ts +69 -0
  283. package/src/strings/camelCase.ts +58 -63
  284. package/src/strings/formatBytes.ts +50 -29
  285. package/src/strings/parseBytes.ts +66 -0
  286. package/src/strings/renderTemplate.test.ts +10 -17
  287. package/src/strings/renderTemplate.ts +19 -22
  288. package/src/types.d.ts +9 -9
  289. package/src/validations/asserts.ts +8 -8
  290. package/src/validations/isUUID.test.ts +8 -8
  291. package/src/validations/isUUID.ts +1 -1
  292. package/src/validations/parseTimestamp.test.ts +2 -2
  293. package/src/validations/parseTimestamp.ts +21 -21
  294. package/src/web/getGlobalThis.ts +6 -6
  295. package/src/web/getRandomValues.ts +29 -29
  296. package/src/web/randomUUID.ts +5 -5
  297. package/src/web/requestIdleCallback.ts +7 -10
  298. package/src/web/structuredClone.test.ts +8 -8
  299. package/src/web/structuredClone.ts +62 -62
  300. package/tsconfig.json +35 -34
  301. package/lib/arrays/MaybeArray.js.map +0 -1
  302. package/lib/arrays/arrayFromAsync.js.map +0 -1
  303. package/lib/asyncs/AsyncInterval.js.map +0 -1
  304. package/lib/asyncs/MaybePromise.js.map +0 -1
  305. package/lib/asyncs/Promises.js.map +0 -1
  306. package/lib/asyncs/createAsyncIterator.js.map +0 -1
  307. package/lib/asyncs/createLazyPromise.js.map +0 -1
  308. package/lib/asyncs/firstOfAsyncIterator.js.map +0 -1
  309. package/lib/asyncs/generatorOfStream.js.map +0 -1
  310. package/lib/asyncs/isIterator.js.map +0 -1
  311. package/lib/asyncs/isPromise.js.map +0 -1
  312. package/lib/asyncs/isThenable.js.map +0 -1
  313. package/lib/asyncs/nextOfAsyncIterator.js.map +0 -1
  314. package/lib/asyncs/promiseOfCallback.js.map +0 -1
  315. package/lib/asyncs/timeout.js.map +0 -1
  316. package/lib/browsers/copy.js.map +0 -1
  317. package/lib/browsers/download.js.map +0 -1
  318. package/lib/browsers/getFileFromDataTransfer.js.map +0 -1
  319. package/lib/browsers/loaders.js.map +0 -1
  320. package/lib/cn/division/DivisionCode.js +0 -215
  321. package/lib/cn/division/DivisionCode.js.map +0 -1
  322. package/lib/cn/division/binarySearch.js +0 -27
  323. package/lib/cn/division/binarySearch.js.map +0 -1
  324. package/lib/cn/formatChineseAmount.js +0 -77
  325. package/lib/cn/formatChineseAmount.js.map +0 -1
  326. package/lib/cn/id/Mod11.js +0 -43
  327. package/lib/cn/id/Mod11.js.map +0 -1
  328. package/lib/cn/id/ResidentIdNumber.js +0 -98
  329. package/lib/cn/id/ResidentIdNumber.js.map +0 -1
  330. package/lib/cn/id/types.js +0 -8
  331. package/lib/cn/id/types.js.map +0 -1
  332. package/lib/cn/index.js +0 -14
  333. package/lib/cn/index.js.map +0 -1
  334. package/lib/cn/parseChineseNumber.js +0 -94
  335. package/lib/cn/parseChineseNumber.js.map +0 -1
  336. package/lib/cn/pinyin/cartesianProduct.js +0 -22
  337. package/lib/cn/pinyin/cartesianProduct.js.map +0 -1
  338. package/lib/cn/pinyin/data.json +0 -413
  339. package/lib/cn/pinyin/loader.js +0 -15
  340. package/lib/cn/pinyin/loader.js.map +0 -1
  341. package/lib/cn/pinyin/preload.js +0 -4
  342. package/lib/cn/pinyin/preload.js.map +0 -1
  343. package/lib/cn/pinyin/toPinyinPure.js +0 -32
  344. package/lib/cn/pinyin/toPinyinPure.js.map +0 -1
  345. package/lib/cn/pinyin/transform.js +0 -14
  346. package/lib/cn/pinyin/transform.js.map +0 -1
  347. package/lib/cn/types.js +0 -3
  348. package/lib/cn/types.js.map +0 -1
  349. package/lib/cn/uscc/Mod31.js +0 -49
  350. package/lib/cn/uscc/Mod31.js.map +0 -1
  351. package/lib/cn/uscc/USCC.js +0 -94
  352. package/lib/cn/uscc/USCC.js.map +0 -1
  353. package/lib/cn/uscc/isUSCC.js +0 -8
  354. package/lib/cn/uscc/isUSCC.js.map +0 -1
  355. package/lib/crypto/base.js.map +0 -1
  356. package/lib/crypto/getNodeCrypto.js.map +0 -1
  357. package/lib/crypto/hashing.js.map +0 -1
  358. package/lib/crypto/md5.bench.js.map +0 -1
  359. package/lib/crypto/md5.d.js.map +0 -1
  360. package/lib/crypto/md5.js.map +0 -1
  361. package/lib/crypto/pem/pem.js.map +0 -1
  362. package/lib/crypto/randomUUIDv7.js.map +0 -1
  363. package/lib/crypto/ulid.js.map +0 -1
  364. package/lib/emitter/types.js.map +0 -1
  365. package/lib/errors/Errors.js.map +0 -1
  366. package/lib/fetch/HttpStatus.js.map +0 -1
  367. package/lib/fetch/createFetchWith.js.map +0 -1
  368. package/lib/fetch/createFetchWithLogging.js.map +0 -1
  369. package/lib/fetch/createFetchWithRetry.js.map +0 -1
  370. package/lib/fetch/dumpRequest.js.map +0 -1
  371. package/lib/fetch/dumpResponse.js.map +0 -1
  372. package/lib/fetch/http.types.js.map +0 -1
  373. package/lib/fetch/index.js.map +0 -1
  374. package/lib/fetch/types.js.map +0 -1
  375. package/lib/i18n/createTranslate.js.map +0 -1
  376. package/lib/index.js.map +0 -1
  377. package/lib/io/AbstractEncoding.js.map +0 -1
  378. package/lib/io/ArrayBuffer.test-d.js.map +0 -1
  379. package/lib/io/ArrayBuffers.js.map +0 -1
  380. package/lib/io/Buffer.js.map +0 -1
  381. package/lib/io/ByteBuffer.js.map +0 -1
  382. package/lib/io/base64.js.map +0 -1
  383. package/lib/io/dump.js.map +0 -1
  384. package/lib/io/isBuffer.js.map +0 -1
  385. package/lib/io/isTransferable.js.map +0 -1
  386. package/lib/io/parseDataUri.js.map +0 -1
  387. package/lib/langs/AsyncCloser.js.map +0 -1
  388. package/lib/langs/Closer.js.map +0 -1
  389. package/lib/langs/MaybeFunction.js.map +0 -1
  390. package/lib/langs/classOf.js.map +0 -1
  391. package/lib/langs/deepEqual.js.map +0 -1
  392. package/lib/langs/deepFreeze.js.map +0 -1
  393. package/lib/langs/getGlobalStates.js.map +0 -1
  394. package/lib/langs/getObjectId.js.map +0 -1
  395. package/lib/langs/ifPresent.js.map +0 -1
  396. package/lib/langs/isClass.js.map +0 -1
  397. package/lib/langs/isDefined.js.map +0 -1
  398. package/lib/langs/isEmptyObject.js.map +0 -1
  399. package/lib/langs/isFunction.js.map +0 -1
  400. package/lib/langs/isNullish.js +0 -5
  401. package/lib/langs/isNullish.js.map +0 -1
  402. package/lib/langs/isPlainObject.js.map +0 -1
  403. package/lib/langs/memoize.js.map +0 -1
  404. package/lib/langs/mixin.js.map +0 -1
  405. package/lib/langs/parseBoolean.js.map +0 -1
  406. package/lib/langs/shallowClone.js.map +0 -1
  407. package/lib/langs/shallowEqual.js.map +0 -1
  408. package/lib/libs/ms.js.map +0 -1
  409. package/lib/logging/Logger.js +0 -5
  410. package/lib/logging/Logger.js.map +0 -1
  411. package/lib/logging/createChildLogger.js +0 -16
  412. package/lib/logging/createChildLogger.js.map +0 -1
  413. package/lib/logging/createLogger.js +0 -63
  414. package/lib/logging/createLogger.js.map +0 -1
  415. package/lib/logging/createNoopLogger.js +0 -13
  416. package/lib/logging/createNoopLogger.js.map +0 -1
  417. package/lib/logging/slog.js +0 -143
  418. package/lib/logging/slog.js.map +0 -1
  419. package/lib/maths/clamp.js.map +0 -1
  420. package/lib/maths/random.js.map +0 -1
  421. package/lib/mitt/index.js +0 -77
  422. package/lib/mitt/index.js.map +0 -1
  423. package/lib/modules/isModule.js.map +0 -1
  424. package/lib/modules/parseModuleId.js.map +0 -1
  425. package/lib/objects/computeIfAbsent.js.map +0 -1
  426. package/lib/objects/get.js.map +0 -1
  427. package/lib/objects/get.test-d.js.map +0 -1
  428. package/lib/objects/merge/index.js.map +0 -1
  429. package/lib/objects/merge/isMergeableObject.js.map +0 -1
  430. package/lib/objects/merge/merge.js.map +0 -1
  431. package/lib/objects/parseObjectPath.js.map +0 -1
  432. package/lib/objects/set.js.map +0 -1
  433. package/lib/schema/typebox/index.js.map +0 -1
  434. package/lib/schema/typebox/typebox.js.map +0 -1
  435. package/lib/scripts/getGenerateContext.js.map +0 -1
  436. package/lib/server/crypto/md5.js.map +0 -1
  437. package/lib/server/fetch/createFetchWithProxy.js.map +0 -1
  438. package/lib/server/fetch/createFetchWithProxyByNodeFetch.js.map +0 -1
  439. package/lib/server/fetch/createFetchWithProxyByUndici.js.map +0 -1
  440. package/lib/server/getPackageDir.js.map +0 -1
  441. package/lib/server/index.js.map +0 -1
  442. package/lib/server/jsdom.js.map +0 -1
  443. package/lib/server/node-fetch.js.map +0 -1
  444. package/lib/server/polyfill/polyfillBrowser.js.map +0 -1
  445. package/lib/server/polyfill/polyfillCrypto.js.map +0 -1
  446. package/lib/server/polyfill/polyfillFetch.js.map +0 -1
  447. package/lib/server/polyfill/polyfillJsDom.js.map +0 -1
  448. package/lib/server/polyfill/polyfillWebSocket.js.map +0 -1
  449. package/lib/server/ws.js.map +0 -1
  450. package/lib/strings/camelCase.js.map +0 -1
  451. package/lib/strings/formatBytes.js.map +0 -1
  452. package/lib/strings/renderTemplate.js.map +0 -1
  453. package/lib/typedoc.js.map +0 -1
  454. package/lib/types.d.js.map +0 -1
  455. package/lib/validations/asserts.js.map +0 -1
  456. package/lib/validations/isUUID.js.map +0 -1
  457. package/lib/validations/parseTimestamp.js.map +0 -1
  458. package/lib/web/getGlobalThis.js.map +0 -1
  459. package/lib/web/getRandomValues.js.map +0 -1
  460. package/lib/web/randomUUID.js.map +0 -1
  461. package/lib/web/requestIdleCallback.js.map +0 -1
  462. package/lib/web/structuredClone.js.map +0 -1
  463. package/src/cn/README.md +0 -3
  464. package/src/cn/division/DivisionCode.ts +0 -173
  465. package/src/cn/division/binarySearch.test.ts +0 -64
  466. package/src/cn/division/binarySearch.ts +0 -25
  467. package/src/cn/division/division.test.ts +0 -22
  468. package/src/cn/formatChineseAmount.ts +0 -61
  469. package/src/cn/id/Mod11.ts +0 -26
  470. package/src/cn/id/ResidentIdNumber.ts +0 -126
  471. package/src/cn/id/id.test.ts +0 -20
  472. package/src/cn/id/types.ts +0 -26
  473. package/src/cn/index.ts +0 -17
  474. package/src/cn/parseChineseNumber.test.ts +0 -159
  475. package/src/cn/parseChineseNumber.ts +0 -97
  476. package/src/cn/pinyin/cartesianProduct.test.ts +0 -64
  477. package/src/cn/pinyin/cartesianProduct.ts +0 -24
  478. package/src/cn/pinyin/data.json +0 -413
  479. package/src/cn/pinyin/loader.ts +0 -12
  480. package/src/cn/pinyin/preload.ts +0 -3
  481. package/src/cn/pinyin/toPinyin.test.ts +0 -12
  482. package/src/cn/pinyin/toPinyinPure.ts +0 -43
  483. package/src/cn/pinyin/transform.ts +0 -12
  484. package/src/cn/scripts/gen.test.ts +0 -131
  485. package/src/cn/types.ts +0 -11
  486. package/src/cn/uscc/Mod31.ts +0 -38
  487. package/src/cn/uscc/USCC.ts +0 -94
  488. package/src/cn/uscc/isUSCC.ts +0 -8
  489. package/src/cn/uscc/uscc.test.ts +0 -16
  490. package/src/langs/isNullish.ts +0 -3
  491. package/src/logging/Logger.ts +0 -25
  492. package/src/logging/createChildLogger.ts +0 -16
  493. package/src/logging/createLogger.ts +0 -50
  494. package/src/logging/createNoopLogger.ts +0 -13
  495. package/src/logging/logger.test.ts +0 -36
  496. package/src/logging/slog.test.ts +0 -8
  497. package/src/logging/slog.ts +0 -221
  498. package/src/mitt/README.md +0 -1
  499. package/src/mitt/index.ts +0 -114
package/lib/libs/ms.js CHANGED
@@ -1,20 +1,24 @@
1
1
  // Helpers.
2
- const s = 1000;
3
- const m = s * 60;
4
- const h = m * 60;
5
- const d = h * 24;
6
- const w = d * 7;
7
- const y = d * 365.25;
2
+ function _type_of(obj) {
3
+ "@swc/helpers - typeof";
4
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
5
+ }
6
+ var s = 1000;
7
+ var m = s * 60;
8
+ var h = m * 60;
9
+ var d = h * 24;
10
+ var w = d * 7;
11
+ var y = d * 365.25;
8
12
  function msFn(value, options) {
9
13
  try {
10
14
  if (typeof value === 'string' && value.length > 0) {
11
15
  return parse(value);
12
16
  } else if (typeof value === 'number' && isFinite(value)) {
13
- return options?.long ? fmtLong(value) : fmtShort(value);
17
+ return (options === null || options === void 0 ? void 0 : options.long) ? fmtLong(value) : fmtShort(value);
14
18
  }
15
19
  throw new Error('Value is not a string or number.');
16
20
  } catch (error) {
17
- const message = isError(error) ? `${error.message}. value=${JSON.stringify(value)}` : 'An unknown error has occurred.';
21
+ var message = isError(error) ? "".concat(error.message, ". value=").concat(JSON.stringify(value)) : 'An unknown error has occurred.';
18
22
  throw new Error(message);
19
23
  }
20
24
  }
@@ -28,15 +32,15 @@ function msFn(value, options) {
28
32
  if (str.length > 100) {
29
33
  throw new Error('Value exceeds the maximum length of 100 characters.');
30
34
  }
31
- const match = /^(?<value>-?(?:\d+)?\.?\d+) *(?<type>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
35
+ var match = RegExp("^(?<value>-?(?:\\d+)?\\.?\\d+) *(?<type>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$", "i").exec(str);
32
36
  // Named capture groups need to be manually typed today.
33
37
  // https://github.com/microsoft/TypeScript/issues/32098
34
- const groups = match?.groups;
38
+ var groups = match === null || match === void 0 ? void 0 : match.groups;
35
39
  if (!groups) {
36
40
  return NaN;
37
41
  }
38
- const n = parseFloat(groups.value);
39
- const type = (groups.type || 'ms').toLowerCase();
42
+ var n = parseFloat(groups.value);
43
+ var type = (groups.type || 'ms').toLowerCase();
40
44
  switch(type){
41
45
  case 'years':
42
46
  case 'year':
@@ -78,7 +82,7 @@ function msFn(value, options) {
78
82
  return n;
79
83
  default:
80
84
  // This should never occur.
81
- throw new Error(`The unit ${type} was matched, but no matching case exists.`);
85
+ throw new Error("The unit ".concat(type, " was matched, but no matching case exists."));
82
86
  }
83
87
  }
84
88
  // eslint-disable-next-line import/no-default-export
@@ -86,25 +90,25 @@ export default msFn;
86
90
  /**
87
91
  * Short format for `ms`.
88
92
  */ function fmtShort(ms) {
89
- const msAbs = Math.abs(ms);
93
+ var msAbs = Math.abs(ms);
90
94
  if (msAbs >= d) {
91
- return `${Math.round(ms / d)}d`;
95
+ return "".concat(Math.round(ms / d), "d");
92
96
  }
93
97
  if (msAbs >= h) {
94
- return `${Math.round(ms / h)}h`;
98
+ return "".concat(Math.round(ms / h), "h");
95
99
  }
96
100
  if (msAbs >= m) {
97
- return `${Math.round(ms / m)}m`;
101
+ return "".concat(Math.round(ms / m), "m");
98
102
  }
99
103
  if (msAbs >= s) {
100
- return `${Math.round(ms / s)}s`;
104
+ return "".concat(Math.round(ms / s), "s");
101
105
  }
102
- return `${ms}ms`;
106
+ return "".concat(ms, "ms");
103
107
  }
104
108
  /**
105
109
  * Long format for `ms`.
106
110
  */ function fmtLong(ms) {
107
- const msAbs = Math.abs(ms);
111
+ var msAbs = Math.abs(ms);
108
112
  if (msAbs >= d) {
109
113
  return plural(ms, msAbs, d, 'day');
110
114
  }
@@ -117,13 +121,13 @@ export default msFn;
117
121
  if (msAbs >= s) {
118
122
  return plural(ms, msAbs, s, 'second');
119
123
  }
120
- return `${ms} ms`;
124
+ return "".concat(ms, " ms");
121
125
  }
122
126
  /**
123
127
  * Pluralization helper.
124
128
  */ function plural(ms, msAbs, n, name) {
125
- const isPlural = msAbs >= n * 1.5;
126
- return `${Math.round(ms / n)} ${name}${isPlural ? 's' : ''}`;
129
+ var isPlural = msAbs >= n * 1.5;
130
+ return "".concat(Math.round(ms / n), " ").concat(name).concat(isPlural ? 's' : '');
127
131
  }
128
132
  /**
129
133
  * A type guard for errors.
@@ -131,7 +135,5 @@ export default msFn;
131
135
  * @param value - The value to test
132
136
  * @returns A boolean `true` if the provided value is an Error-like object
133
137
  */ function isError(value) {
134
- return typeof value === 'object' && value !== null && 'message' in value;
138
+ return (typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && value !== null && 'message' in value;
135
139
  }
136
-
137
- //# sourceMappingURL=ms.js.map
@@ -0,0 +1,301 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import ms from "./ms.js";
3
+ describe("ms(string)", function () {
4
+ it("should not throw an error", function () {
5
+ expect(function () {
6
+ ms("1m");
7
+ }).not.toThrowError();
8
+ });
9
+ it("should preserve ms", function () {
10
+ expect(ms("100")).toBe(100);
11
+ });
12
+ it("should convert from m to ms", function () {
13
+ expect(ms("1m")).toBe(60000);
14
+ });
15
+ it("should convert from h to ms", function () {
16
+ expect(ms("1h")).toBe(3600000);
17
+ });
18
+ it("should convert d to ms", function () {
19
+ expect(ms("2d")).toBe(172800000);
20
+ });
21
+ it("should convert w to ms", function () {
22
+ expect(ms("3w")).toBe(1814400000);
23
+ });
24
+ it("should convert s to ms", function () {
25
+ expect(ms("1s")).toBe(1000);
26
+ });
27
+ it("should convert ms to ms", function () {
28
+ expect(ms("100ms")).toBe(100);
29
+ });
30
+ it("should convert y to ms", function () {
31
+ expect(ms("1y")).toBe(31557600000);
32
+ });
33
+ it("should work with decimals", function () {
34
+ expect(ms("1.5h")).toBe(5400000);
35
+ });
36
+ it("should work with multiple spaces", function () {
37
+ expect(ms("1 s")).toBe(1000);
38
+ });
39
+ it("should return NaN if invalid", function () {
40
+ // @ts-expect-error - We expect this to fail.
41
+ expect(isNaN(ms("\u2603"))).toBe(true);
42
+ // @ts-expect-error - We expect this to fail.
43
+ expect(isNaN(ms("10-.5"))).toBe(true);
44
+ // @ts-expect-error - We expect this to fail.
45
+ expect(isNaN(ms("ms"))).toBe(true);
46
+ });
47
+ it("should be case-insensitive", function () {
48
+ expect(ms("1.5H")).toBe(5400000);
49
+ });
50
+ it("should work with numbers starting with .", function () {
51
+ expect(ms(".5ms")).toBe(0.5);
52
+ });
53
+ it("should work with negative integers", function () {
54
+ expect(ms("-100ms")).toBe(-100);
55
+ });
56
+ it("should work with negative decimals", function () {
57
+ expect(ms("-1.5h")).toBe(-5400000);
58
+ expect(ms("-10.5h")).toBe(-37800000);
59
+ });
60
+ it("should work with negative decimals starting with \".\"", function () {
61
+ expect(ms("-.5h")).toBe(-1800000);
62
+ });
63
+ });
64
+ // long strings
65
+ describe("ms(long string)", function () {
66
+ it("should not throw an error", function () {
67
+ expect(function () {
68
+ ms("53 milliseconds");
69
+ }).not.toThrowError();
70
+ });
71
+ it("should convert milliseconds to ms", function () {
72
+ expect(ms("53 milliseconds")).toBe(53);
73
+ });
74
+ it("should convert msecs to ms", function () {
75
+ expect(ms("17 msecs")).toBe(17);
76
+ });
77
+ it("should convert sec to ms", function () {
78
+ expect(ms("1 sec")).toBe(1000);
79
+ });
80
+ it("should convert from min to ms", function () {
81
+ expect(ms("1 min")).toBe(60000);
82
+ });
83
+ it("should convert from hr to ms", function () {
84
+ expect(ms("1 hr")).toBe(3600000);
85
+ });
86
+ it("should convert days to ms", function () {
87
+ expect(ms("2 days")).toBe(172800000);
88
+ });
89
+ it("should convert weeks to ms", function () {
90
+ expect(ms("1 week")).toBe(604800000);
91
+ });
92
+ it("should convert years to ms", function () {
93
+ expect(ms("1 year")).toBe(31557600000);
94
+ });
95
+ it("should work with decimals", function () {
96
+ expect(ms("1.5 hours")).toBe(5400000);
97
+ });
98
+ it("should work with negative integers", function () {
99
+ expect(ms("-100 milliseconds")).toBe(-100);
100
+ });
101
+ it("should work with negative decimals", function () {
102
+ expect(ms("-1.5 hours")).toBe(-5400000);
103
+ });
104
+ it("should work with negative decimals starting with \".\"", function () {
105
+ expect(ms("-.5 hr")).toBe(-1800000);
106
+ });
107
+ });
108
+ // numbers
109
+ describe("ms(number, { long: true })", function () {
110
+ it("should not throw an error", function () {
111
+ expect(function () {
112
+ ms(500, {
113
+ long: true
114
+ });
115
+ }).not.toThrowError();
116
+ });
117
+ it("should support milliseconds", function () {
118
+ expect(ms(500, {
119
+ long: true
120
+ })).toBe("500 ms");
121
+ expect(ms(-500, {
122
+ long: true
123
+ })).toBe("-500 ms");
124
+ });
125
+ it("should support seconds", function () {
126
+ expect(ms(1000, {
127
+ long: true
128
+ })).toBe("1 second");
129
+ expect(ms(1200, {
130
+ long: true
131
+ })).toBe("1 second");
132
+ expect(ms(10000, {
133
+ long: true
134
+ })).toBe("10 seconds");
135
+ expect(ms(-1000, {
136
+ long: true
137
+ })).toBe("-1 second");
138
+ expect(ms(-1200, {
139
+ long: true
140
+ })).toBe("-1 second");
141
+ expect(ms(-10000, {
142
+ long: true
143
+ })).toBe("-10 seconds");
144
+ });
145
+ it("should support minutes", function () {
146
+ expect(ms(60 * 1000, {
147
+ long: true
148
+ })).toBe("1 minute");
149
+ expect(ms(60 * 1200, {
150
+ long: true
151
+ })).toBe("1 minute");
152
+ expect(ms(60 * 10000, {
153
+ long: true
154
+ })).toBe("10 minutes");
155
+ expect(ms(-1 * 60 * 1000, {
156
+ long: true
157
+ })).toBe("-1 minute");
158
+ expect(ms(-1 * 60 * 1200, {
159
+ long: true
160
+ })).toBe("-1 minute");
161
+ expect(ms(-1 * 60 * 10000, {
162
+ long: true
163
+ })).toBe("-10 minutes");
164
+ });
165
+ it("should support hours", function () {
166
+ expect(ms(60 * 60 * 1000, {
167
+ long: true
168
+ })).toBe("1 hour");
169
+ expect(ms(60 * 60 * 1200, {
170
+ long: true
171
+ })).toBe("1 hour");
172
+ expect(ms(60 * 60 * 10000, {
173
+ long: true
174
+ })).toBe("10 hours");
175
+ expect(ms(-1 * 60 * 60 * 1000, {
176
+ long: true
177
+ })).toBe("-1 hour");
178
+ expect(ms(-1 * 60 * 60 * 1200, {
179
+ long: true
180
+ })).toBe("-1 hour");
181
+ expect(ms(-1 * 60 * 60 * 10000, {
182
+ long: true
183
+ })).toBe("-10 hours");
184
+ });
185
+ it("should support days", function () {
186
+ expect(ms(24 * 60 * 60 * 1000, {
187
+ long: true
188
+ })).toBe("1 day");
189
+ expect(ms(24 * 60 * 60 * 1200, {
190
+ long: true
191
+ })).toBe("1 day");
192
+ expect(ms(24 * 60 * 60 * 10000, {
193
+ long: true
194
+ })).toBe("10 days");
195
+ expect(ms(-1 * 24 * 60 * 60 * 1000, {
196
+ long: true
197
+ })).toBe("-1 day");
198
+ expect(ms(-1 * 24 * 60 * 60 * 1200, {
199
+ long: true
200
+ })).toBe("-1 day");
201
+ expect(ms(-1 * 24 * 60 * 60 * 10000, {
202
+ long: true
203
+ })).toBe("-10 days");
204
+ });
205
+ it("should round", function () {
206
+ expect(ms(234234234, {
207
+ long: true
208
+ })).toBe("3 days");
209
+ expect(ms(-234234234, {
210
+ long: true
211
+ })).toBe("-3 days");
212
+ });
213
+ });
214
+ // numbers
215
+ describe("ms(number)", function () {
216
+ it("should not throw an error", function () {
217
+ expect(function () {
218
+ ms(500);
219
+ }).not.toThrowError();
220
+ });
221
+ it("should support milliseconds", function () {
222
+ expect(ms(500)).toBe("500ms");
223
+ expect(ms(-500)).toBe("-500ms");
224
+ });
225
+ it("should support seconds", function () {
226
+ expect(ms(1000)).toBe("1s");
227
+ expect(ms(10000)).toBe("10s");
228
+ expect(ms(-1000)).toBe("-1s");
229
+ expect(ms(-10000)).toBe("-10s");
230
+ });
231
+ it("should support minutes", function () {
232
+ expect(ms(60 * 1000)).toBe("1m");
233
+ expect(ms(60 * 10000)).toBe("10m");
234
+ expect(ms(-1 * 60 * 1000)).toBe("-1m");
235
+ expect(ms(-1 * 60 * 10000)).toBe("-10m");
236
+ });
237
+ it("should support hours", function () {
238
+ expect(ms(60 * 60 * 1000)).toBe("1h");
239
+ expect(ms(60 * 60 * 10000)).toBe("10h");
240
+ expect(ms(-1 * 60 * 60 * 1000)).toBe("-1h");
241
+ expect(ms(-1 * 60 * 60 * 10000)).toBe("-10h");
242
+ });
243
+ it("should support days", function () {
244
+ expect(ms(24 * 60 * 60 * 1000)).toBe("1d");
245
+ expect(ms(24 * 60 * 60 * 10000)).toBe("10d");
246
+ expect(ms(-1 * 24 * 60 * 60 * 1000)).toBe("-1d");
247
+ expect(ms(-1 * 24 * 60 * 60 * 10000)).toBe("-10d");
248
+ });
249
+ it("should round", function () {
250
+ expect(ms(234234234)).toBe("3d");
251
+ expect(ms(-234234234)).toBe("-3d");
252
+ });
253
+ });
254
+ // invalid inputs
255
+ describe("ms(invalid inputs)", function () {
256
+ it("should throw an error, when ms(\"\")", function () {
257
+ expect(function () {
258
+ // @ts-expect-error - We expect this to throw.
259
+ ms("");
260
+ }).toThrowError();
261
+ });
262
+ it("should throw an error, when ms(undefined)", function () {
263
+ expect(function () {
264
+ // @ts-expect-error - We expect this to throw.
265
+ ms(undefined);
266
+ }).toThrowError();
267
+ });
268
+ it("should throw an error, when ms(null)", function () {
269
+ expect(function () {
270
+ // @ts-expect-error - We expect this to throw.
271
+ ms(null);
272
+ }).toThrowError();
273
+ });
274
+ it("should throw an error, when ms([])", function () {
275
+ expect(function () {
276
+ // @ts-expect-error - We expect this to throw.
277
+ ms([]);
278
+ }).toThrowError();
279
+ });
280
+ it("should throw an error, when ms({})", function () {
281
+ expect(function () {
282
+ // @ts-expect-error - We expect this to throw.
283
+ ms({});
284
+ }).toThrowError();
285
+ });
286
+ it("should throw an error, when ms(NaN)", function () {
287
+ expect(function () {
288
+ ms(NaN);
289
+ }).toThrowError();
290
+ });
291
+ it("should throw an error, when ms(Infinity)", function () {
292
+ expect(function () {
293
+ ms(Infinity);
294
+ }).toThrowError();
295
+ });
296
+ it("should throw an error, when ms(-Infinity)", function () {
297
+ expect(function () {
298
+ ms(-Infinity);
299
+ }).toThrowError();
300
+ });
301
+ });
@@ -0,0 +1,15 @@
1
+ export var logger = console;
2
+ export function setLogger(l) {
3
+ logger = l;
4
+ }
5
+ export function createNoopLogger() {
6
+ var noop = function() {};
7
+ return {
8
+ log: noop,
9
+ info: noop,
10
+ warn: noop,
11
+ error: noop,
12
+ debug: noop,
13
+ trace: noop
14
+ };
15
+ }
@@ -0,0 +1 @@
1
+ export { logger, setLogger, createNoopLogger } from "./const.js";
@@ -0,0 +1 @@
1
+ export { };
@@ -1,13 +1,84 @@
1
- import { isDefined } from '../langs/isDefined.js';
2
- import { isNullish } from '../langs/isNullish.js';
3
- export function clamp(value, ...o) {
4
- let min, max, def;
5
- if (o.length === 1 && o[0] && typeof o[0] === 'object') {
6
- ({ min, max, default: def = min } = o[0]);
7
- } else {
8
- [min, max, def = min] = o;
9
- }
10
- if (isNullish(value)) {
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length)
3
+ len = arr.length;
4
+ for (var i = 0, arr2 = new Array(len); i < len; i++)
5
+ arr2[i] = arr[i];
6
+ return arr2;
7
+ }
8
+ function _array_with_holes(arr) {
9
+ if (Array.isArray(arr))
10
+ return arr;
11
+ }
12
+ function _iterable_to_array_limit(arr, i) {
13
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
14
+ if (_i == null)
15
+ return;
16
+ var _arr = [];
17
+ var _n = true;
18
+ var _d = false;
19
+ var _s, _e;
20
+ try {
21
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
22
+ _arr.push(_s.value);
23
+ if (i && _arr.length === i)
24
+ break;
25
+ }
26
+ }
27
+ catch (err) {
28
+ _d = true;
29
+ _e = err;
30
+ }
31
+ finally {
32
+ try {
33
+ if (!_n && _i["return"] != null)
34
+ _i["return"]();
35
+ }
36
+ finally {
37
+ if (_d)
38
+ throw _e;
39
+ }
40
+ }
41
+ return _arr;
42
+ }
43
+ function _non_iterable_rest() {
44
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
45
+ }
46
+ function _sliced_to_array(arr, i) {
47
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
48
+ }
49
+ function _type_of(obj) {
50
+ "@swc/helpers - typeof";
51
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
52
+ }
53
+ function _unsupported_iterable_to_array(o, minLen) {
54
+ if (!o)
55
+ return;
56
+ if (typeof o === "string")
57
+ return _array_like_to_array(o, minLen);
58
+ var n = Object.prototype.toString.call(o).slice(8, -1);
59
+ if (n === "Object" && o.constructor)
60
+ n = o.constructor.name;
61
+ if (n === "Map" || n === "Set")
62
+ return Array.from(n);
63
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
64
+ return _array_like_to_array(o, minLen);
65
+ }
66
+ import { isDefined } from "../langs/isDefined.js";
67
+ import { isNil } from "../langs/isNil.js";
68
+ export function clamp(value) {
69
+ for (var _len = arguments.length, o = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
70
+ o[_key - 1] = arguments[_key];
71
+ }
72
+ var min, max, def;
73
+ if (o.length === 1 && o[0] && _type_of(o[0]) === "object") {
74
+ var ref, ref1;
75
+ ref = o[0], min = ref.min, max = ref.max, ref1 = ref.default, def = ref1 === void 0 ? min : ref1, ref;
76
+ }
77
+ else {
78
+ var ref2, ref3;
79
+ ref2 = _sliced_to_array(o, 3), min = ref2[0], max = ref2[1], ref3 = ref2[2], def = ref3 === void 0 ? min : ref3, ref2;
80
+ }
81
+ if (isNil(value)) {
11
82
  return def;
12
83
  }
13
84
  if (isDefined(min) && value < min) {
@@ -18,5 +89,3 @@ export function clamp(value, ...o) {
18
89
  }
19
90
  return value;
20
91
  }
21
-
22
- //# sourceMappingURL=clamp.js.map