@naturalcycles/js-lib 14.277.0 → 15.0.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 (353) hide show
  1. package/cfg/frontend/tsconfig.json +3 -3
  2. package/dist/abort.js +1 -4
  3. package/dist/array/array.util.d.ts +1 -1
  4. package/dist/array/array.util.js +47 -88
  5. package/dist/array/range.d.ts +2 -2
  6. package/dist/array/range.js +7 -12
  7. package/dist/bot.js +6 -10
  8. package/dist/browser/adminService.d.ts +1 -1
  9. package/dist/browser/adminService.js +10 -14
  10. package/dist/browser/analytics.util.js +10 -15
  11. package/dist/browser/i18n/fetchTranslationLoader.d.ts +3 -3
  12. package/dist/browser/i18n/fetchTranslationLoader.js +1 -5
  13. package/dist/browser/i18n/translation.service.d.ts +1 -1
  14. package/dist/browser/i18n/translation.service.js +5 -10
  15. package/dist/browser/imageFitter.js +1 -5
  16. package/dist/browser/script.util.js +8 -12
  17. package/dist/browser/topbar.js +7 -10
  18. package/dist/datetime/dateInterval.d.ts +2 -2
  19. package/dist/datetime/dateInterval.js +7 -11
  20. package/dist/datetime/localDate.d.ts +3 -3
  21. package/dist/datetime/localDate.js +40 -44
  22. package/dist/datetime/localTime.d.ts +3 -3
  23. package/dist/datetime/localTime.js +36 -40
  24. package/dist/datetime/timeInterval.d.ts +2 -2
  25. package/dist/datetime/timeInterval.js +6 -10
  26. package/dist/datetime/wallTime.d.ts +3 -3
  27. package/dist/datetime/wallTime.js +5 -9
  28. package/dist/decorators/asyncMemo.decorator.d.ts +3 -3
  29. package/dist/decorators/asyncMemo.decorator.js +12 -17
  30. package/dist/decorators/createPromiseDecorator.js +3 -6
  31. package/dist/decorators/debounce.d.ts +1 -1
  32. package/dist/decorators/debounce.decorator.d.ts +1 -1
  33. package/dist/decorators/debounce.decorator.js +5 -9
  34. package/dist/decorators/debounce.js +2 -6
  35. package/dist/decorators/decorator.util.d.ts +1 -1
  36. package/dist/decorators/decorator.util.js +3 -8
  37. package/dist/decorators/logMethod.decorator.d.ts +1 -1
  38. package/dist/decorators/logMethod.decorator.js +11 -14
  39. package/dist/decorators/memo.decorator.d.ts +3 -3
  40. package/dist/decorators/memo.decorator.js +11 -16
  41. package/dist/decorators/memo.util.d.ts +2 -2
  42. package/dist/decorators/memo.util.js +11 -17
  43. package/dist/decorators/memoFn.d.ts +3 -3
  44. package/dist/decorators/memoFn.js +3 -6
  45. package/dist/decorators/memoFnAsync.d.ts +3 -3
  46. package/dist/decorators/memoFnAsync.js +5 -8
  47. package/dist/decorators/memoSimple.decorator.d.ts +1 -1
  48. package/dist/decorators/memoSimple.decorator.js +6 -10
  49. package/dist/decorators/retry.decorator.d.ts +1 -1
  50. package/dist/decorators/retry.decorator.js +3 -6
  51. package/dist/decorators/swarmSafe.decorator.js +3 -7
  52. package/dist/decorators/timeout.decorator.d.ts +1 -1
  53. package/dist/decorators/timeout.decorator.js +7 -10
  54. package/dist/define.d.ts +1 -1
  55. package/dist/define.js +11 -19
  56. package/dist/deviceIdService.js +7 -11
  57. package/dist/enum.util.d.ts +1 -1
  58. package/dist/enum.util.js +20 -42
  59. package/dist/env/buildInfo.d.ts +1 -1
  60. package/dist/env/buildInfo.js +3 -6
  61. package/dist/env.js +2 -6
  62. package/dist/error/assert.d.ts +3 -3
  63. package/dist/error/assert.js +30 -44
  64. package/dist/error/error.model.d.ts +2 -2
  65. package/dist/error/error.model.js +1 -2
  66. package/dist/error/error.util.d.ts +1 -1
  67. package/dist/error/error.util.js +25 -44
  68. package/dist/error/errorMode.js +2 -5
  69. package/dist/error/try.d.ts +2 -2
  70. package/dist/error/try.js +15 -23
  71. package/dist/error/tryCatch.d.ts +2 -2
  72. package/dist/error/tryCatch.js +6 -11
  73. package/dist/form.util.d.ts +1 -1
  74. package/dist/form.util.js +2 -6
  75. package/dist/http/fetcher.d.ts +3 -3
  76. package/dist/http/fetcher.js +48 -53
  77. package/dist/http/fetcher.model.d.ts +5 -5
  78. package/dist/http/fetcher.model.js +1 -2
  79. package/dist/http/http.model.js +1 -4
  80. package/dist/index.d.ts +96 -96
  81. package/dist/index.js +96 -99
  82. package/dist/is.util.d.ts +2 -2
  83. package/dist/is.util.js +12 -27
  84. package/dist/iter/asyncIterable2.d.ts +3 -3
  85. package/dist/iter/asyncIterable2.js +8 -12
  86. package/dist/iter/iterable2.d.ts +2 -2
  87. package/dist/iter/iterable2.js +8 -12
  88. package/dist/json-schema/from-data/generateJsonSchemaFromData.d.ts +1 -1
  89. package/dist/json-schema/from-data/generateJsonSchemaFromData.js +5 -8
  90. package/dist/json-schema/jsonSchema.cnst.d.ts +1 -1
  91. package/dist/json-schema/jsonSchema.cnst.js +1 -4
  92. package/dist/json-schema/jsonSchema.model.d.ts +1 -1
  93. package/dist/json-schema/jsonSchema.model.js +1 -2
  94. package/dist/json-schema/jsonSchema.util.d.ts +2 -2
  95. package/dist/json-schema/jsonSchema.util.js +5 -8
  96. package/dist/json-schema/jsonSchemaBuilder.d.ts +2 -2
  97. package/dist/json-schema/jsonSchemaBuilder.js +16 -25
  98. package/dist/json-schema/jsonSchemas.d.ts +2 -2
  99. package/dist/json-schema/jsonSchemas.js +5 -8
  100. package/dist/log/commonLogger.js +14 -21
  101. package/dist/math/accumulatingAverage.js +1 -5
  102. package/dist/math/math.util.js +11 -19
  103. package/dist/math/sma.js +1 -5
  104. package/dist/math/stack.util.js +11 -16
  105. package/dist/nanoid.js +2 -6
  106. package/dist/number/createDeterministicRandom.js +1 -4
  107. package/dist/number/number.util.d.ts +1 -1
  108. package/dist/number/number.util.js +9 -20
  109. package/dist/object/deepEquals.js +3 -8
  110. package/dist/object/map2.js +1 -5
  111. package/dist/object/object.util.d.ts +2 -2
  112. package/dist/object/object.util.js +40 -70
  113. package/dist/object/set2.js +1 -5
  114. package/dist/object/sortObject.d.ts +1 -1
  115. package/dist/object/sortObject.js +1 -4
  116. package/dist/object/sortObjectDeep.js +1 -4
  117. package/dist/polyfill.js +1 -4
  118. package/dist/promise/abortable.d.ts +1 -1
  119. package/dist/promise/abortable.js +2 -7
  120. package/dist/promise/pDefer.js +1 -4
  121. package/dist/promise/pDelay.d.ts +2 -2
  122. package/dist/promise/pDelay.js +4 -8
  123. package/dist/promise/pFilter.d.ts +1 -1
  124. package/dist/promise/pFilter.js +1 -4
  125. package/dist/promise/pHang.js +1 -4
  126. package/dist/promise/pMap.d.ts +2 -2
  127. package/dist/promise/pMap.js +17 -20
  128. package/dist/promise/pProps.js +1 -4
  129. package/dist/promise/pQueue.d.ts +2 -2
  130. package/dist/promise/pQueue.js +7 -11
  131. package/dist/promise/pRetry.d.ts +1 -1
  132. package/dist/promise/pRetry.js +8 -12
  133. package/dist/promise/pState.js +1 -4
  134. package/dist/promise/pTimeout.d.ts +3 -3
  135. package/dist/promise/pTimeout.js +7 -11
  136. package/dist/semver.d.ts +1 -1
  137. package/dist/semver.js +13 -18
  138. package/dist/string/case.js +9 -14
  139. package/dist/string/escape.js +2 -6
  140. package/dist/string/hash.util.d.ts +1 -1
  141. package/dist/string/hash.util.js +4 -10
  142. package/dist/string/json.util.d.ts +1 -1
  143. package/dist/string/json.util.js +5 -10
  144. package/dist/string/leven.js +1 -4
  145. package/dist/string/lodash/unicodeWords.js +1 -4
  146. package/dist/string/lodash/words.js +3 -6
  147. package/dist/string/pupa.d.ts +1 -1
  148. package/dist/string/pupa.js +4 -9
  149. package/dist/string/readingTime.d.ts +1 -1
  150. package/dist/string/readingTime.js +1 -4
  151. package/dist/string/regex.js +1 -4
  152. package/dist/string/safeJsonStringify.d.ts +1 -1
  153. package/dist/string/safeJsonStringify.js +1 -4
  154. package/dist/string/slugify.js +1 -4
  155. package/dist/string/string.util.js +15 -32
  156. package/dist/string/stringify.d.ts +1 -1
  157. package/dist/string/stringify.js +10 -14
  158. package/dist/string/url.util.d.ts +1 -1
  159. package/dist/string/url.util.js +2 -6
  160. package/dist/time/time.util.d.ts +1 -1
  161. package/dist/time/time.util.js +3 -8
  162. package/dist/typeFest.js +1 -2
  163. package/dist/types.d.ts +1 -1
  164. package/dist/types.js +17 -27
  165. package/dist/unit/size.util.js +5 -12
  166. package/dist/web.d.ts +1 -1
  167. package/dist/web.js +1 -5
  168. package/dist/zod/index.d.ts +2 -2
  169. package/dist/zod/index.js +4 -10
  170. package/dist/zod/zod.shared.schemas.js +36 -39
  171. package/dist/zod/zod.util.js +7 -14
  172. package/package.json +18 -30
  173. package/src/array/array.util.ts +3 -3
  174. package/src/array/range.ts +2 -2
  175. package/src/bot.ts +1 -1
  176. package/src/browser/adminService.ts +4 -4
  177. package/src/browser/analytics.util.ts +2 -2
  178. package/src/browser/i18n/fetchTranslationLoader.ts +3 -3
  179. package/src/browser/i18n/translation.service.ts +2 -2
  180. package/src/browser/script.util.ts +2 -2
  181. package/src/datetime/dateInterval.ts +3 -3
  182. package/src/datetime/localDate.ts +5 -5
  183. package/src/datetime/localTime.ts +6 -6
  184. package/src/datetime/timeInterval.ts +3 -3
  185. package/src/datetime/wallTime.ts +4 -4
  186. package/src/decorators/asyncMemo.decorator.ts +7 -7
  187. package/src/decorators/createPromiseDecorator.ts +1 -1
  188. package/src/decorators/debounce.decorator.ts +2 -2
  189. package/src/decorators/debounce.ts +1 -1
  190. package/src/decorators/decorator.util.ts +1 -1
  191. package/src/decorators/logMethod.decorator.ts +4 -4
  192. package/src/decorators/memo.decorator.ts +7 -7
  193. package/src/decorators/memo.util.ts +4 -4
  194. package/src/decorators/memoFn.ts +4 -4
  195. package/src/decorators/memoFnAsync.ts +5 -5
  196. package/src/decorators/memoSimple.decorator.ts +4 -4
  197. package/src/decorators/retry.decorator.ts +2 -2
  198. package/src/decorators/swarmSafe.decorator.ts +2 -2
  199. package/src/decorators/timeout.decorator.ts +4 -4
  200. package/src/define.ts +3 -3
  201. package/src/deviceIdService.ts +3 -3
  202. package/src/enum.util.ts +1 -1
  203. package/src/env/buildInfo.ts +2 -2
  204. package/src/error/assert.ts +7 -7
  205. package/src/error/error.model.ts +2 -2
  206. package/src/error/error.util.ts +5 -5
  207. package/src/error/try.ts +5 -5
  208. package/src/error/tryCatch.ts +3 -3
  209. package/src/form.util.ts +1 -1
  210. package/src/http/fetcher.model.ts +5 -5
  211. package/src/http/fetcher.ts +20 -15
  212. package/src/index.ts +96 -96
  213. package/src/is.util.ts +2 -2
  214. package/src/iter/asyncIterable2.ts +3 -3
  215. package/src/iter/iterable2.ts +2 -2
  216. package/src/json-schema/from-data/generateJsonSchemaFromData.ts +3 -3
  217. package/src/json-schema/jsonSchema.cnst.ts +1 -1
  218. package/src/json-schema/jsonSchema.model.ts +1 -1
  219. package/src/json-schema/jsonSchema.util.ts +4 -4
  220. package/src/json-schema/jsonSchemaBuilder.ts +5 -5
  221. package/src/json-schema/jsonSchemas.ts +2 -2
  222. package/src/math/math.util.ts +2 -2
  223. package/src/math/stack.util.ts +1 -1
  224. package/src/number/number.util.ts +1 -1
  225. package/src/object/object.util.ts +3 -3
  226. package/src/object/sortObject.ts +1 -1
  227. package/src/promise/abortable.ts +1 -1
  228. package/src/promise/pDelay.ts +3 -3
  229. package/src/promise/pFilter.ts +1 -1
  230. package/src/promise/pMap.ts +2 -2
  231. package/src/promise/pQueue.ts +4 -4
  232. package/src/promise/pRetry.ts +2 -2
  233. package/src/promise/pTimeout.ts +4 -4
  234. package/src/semver.ts +3 -3
  235. package/src/string/case.ts +2 -2
  236. package/src/string/hash.util.ts +1 -1
  237. package/src/string/json.util.ts +2 -2
  238. package/src/string/lodash/words.ts +1 -1
  239. package/src/string/pupa.ts +2 -2
  240. package/src/string/readingTime.ts +1 -1
  241. package/src/string/safeJsonStringify.ts +1 -1
  242. package/src/string/stringify.ts +4 -4
  243. package/src/string/url.util.ts +1 -1
  244. package/src/time/time.util.ts +1 -1
  245. package/src/types.ts +2 -2
  246. package/src/web.ts +1 -1
  247. package/src/zod/index.ts +2 -2
  248. package/src/zod/zod.util.ts +1 -1
  249. package/dist-esm/abort.js +0 -12
  250. package/dist-esm/array/array.util.js +0 -458
  251. package/dist-esm/array/range.js +0 -34
  252. package/dist-esm/bot.js +0 -130
  253. package/dist-esm/browser/adminService.js +0 -94
  254. package/dist-esm/browser/analytics.util.js +0 -54
  255. package/dist-esm/browser/i18n/fetchTranslationLoader.js +0 -13
  256. package/dist-esm/browser/i18n/translation.service.js +0 -56
  257. package/dist-esm/browser/imageFitter.js +0 -65
  258. package/dist-esm/browser/script.util.js +0 -46
  259. package/dist-esm/browser/topbar.js +0 -135
  260. package/dist-esm/datetime/dateInterval.js +0 -80
  261. package/dist-esm/datetime/localDate.js +0 -719
  262. package/dist-esm/datetime/localTime.js +0 -996
  263. package/dist-esm/datetime/timeInterval.js +0 -88
  264. package/dist-esm/datetime/wallTime.js +0 -70
  265. package/dist-esm/decorators/asyncMemo.decorator.js +0 -111
  266. package/dist-esm/decorators/createPromiseDecorator.js +0 -82
  267. package/dist-esm/decorators/debounce.decorator.js +0 -17
  268. package/dist-esm/decorators/debounce.js +0 -114
  269. package/dist-esm/decorators/decorator.util.js +0 -31
  270. package/dist-esm/decorators/logMethod.decorator.js +0 -85
  271. package/dist-esm/decorators/memo.decorator.js +0 -80
  272. package/dist-esm/decorators/memo.util.js +0 -97
  273. package/dist-esm/decorators/memoFn.js +0 -29
  274. package/dist-esm/decorators/memoFnAsync.js +0 -35
  275. package/dist-esm/decorators/memoSimple.decorator.js +0 -55
  276. package/dist-esm/decorators/retry.decorator.js +0 -9
  277. package/dist-esm/decorators/swarmSafe.decorator.js +0 -38
  278. package/dist-esm/decorators/timeout.decorator.js +0 -19
  279. package/dist-esm/define.js +0 -109
  280. package/dist-esm/deviceIdService.js +0 -105
  281. package/dist-esm/enum.util.js +0 -157
  282. package/dist-esm/env/buildInfo.js +0 -19
  283. package/dist-esm/env.js +0 -19
  284. package/dist-esm/error/assert.js +0 -122
  285. package/dist-esm/error/error.model.js +0 -1
  286. package/dist-esm/error/error.util.js +0 -337
  287. package/dist-esm/error/errorMode.js +0 -20
  288. package/dist-esm/error/try.js +0 -105
  289. package/dist-esm/error/tryCatch.js +0 -41
  290. package/dist-esm/form.util.js +0 -16
  291. package/dist-esm/http/fetcher.js +0 -704
  292. package/dist-esm/http/fetcher.model.js +0 -3
  293. package/dist-esm/http/http.model.js +0 -1
  294. package/dist-esm/index.js +0 -96
  295. package/dist-esm/is.util.js +0 -70
  296. package/dist-esm/iter/asyncIterable2.js +0 -103
  297. package/dist-esm/iter/iterable2.js +0 -87
  298. package/dist-esm/json-schema/from-data/generateJsonSchemaFromData.js +0 -86
  299. package/dist-esm/json-schema/jsonSchema.cnst.js +0 -38
  300. package/dist-esm/json-schema/jsonSchema.model.js +0 -1
  301. package/dist-esm/json-schema/jsonSchema.util.js +0 -27
  302. package/dist-esm/json-schema/jsonSchemaBuilder.js +0 -352
  303. package/dist-esm/json-schema/jsonSchemas.js +0 -6
  304. package/dist-esm/log/commonLogger.js +0 -78
  305. package/dist-esm/math/accumulatingAverage.js +0 -32
  306. package/dist-esm/math/math.util.js +0 -85
  307. package/dist-esm/math/sma.js +0 -43
  308. package/dist-esm/math/stack.util.js +0 -82
  309. package/dist-esm/nanoid.js +0 -57
  310. package/dist-esm/number/createDeterministicRandom.js +0 -18
  311. package/dist-esm/number/number.util.js +0 -109
  312. package/dist-esm/object/deepEquals.js +0 -170
  313. package/dist-esm/object/map2.js +0 -21
  314. package/dist-esm/object/object.util.js +0 -435
  315. package/dist-esm/object/set2.js +0 -15
  316. package/dist-esm/object/sortObject.js +0 -21
  317. package/dist-esm/object/sortObjectDeep.js +0 -17
  318. package/dist-esm/polyfill.js +0 -6
  319. package/dist-esm/promise/abortable.js +0 -31
  320. package/dist-esm/promise/pDefer.js +0 -17
  321. package/dist-esm/promise/pDelay.js +0 -37
  322. package/dist-esm/promise/pFilter.js +0 -5
  323. package/dist-esm/promise/pHang.js +0 -6
  324. package/dist-esm/promise/pMap.js +0 -174
  325. package/dist-esm/promise/pProps.js +0 -20
  326. package/dist-esm/promise/pQueue.js +0 -101
  327. package/dist-esm/promise/pRetry.js +0 -64
  328. package/dist-esm/promise/pState.js +0 -14
  329. package/dist-esm/promise/pTimeout.js +0 -64
  330. package/dist-esm/semver.js +0 -149
  331. package/dist-esm/string/case.js +0 -24
  332. package/dist-esm/string/escape.js +0 -49
  333. package/dist-esm/string/hash.util.js +0 -67
  334. package/dist-esm/string/json.util.js +0 -46
  335. package/dist-esm/string/leven.js +0 -77
  336. package/dist-esm/string/lodash/unicodeWords.js +0 -68
  337. package/dist-esm/string/lodash/words.js +0 -31
  338. package/dist-esm/string/pupa.js +0 -54
  339. package/dist-esm/string/readingTime.js +0 -102
  340. package/dist-esm/string/regex.js +0 -6
  341. package/dist-esm/string/safeJsonStringify.js +0 -39
  342. package/dist-esm/string/slugify.js +0 -66
  343. package/dist-esm/string/string.util.js +0 -99
  344. package/dist-esm/string/stringify.js +0 -133
  345. package/dist-esm/string/url.util.js +0 -42
  346. package/dist-esm/time/time.util.js +0 -61
  347. package/dist-esm/typeFest.js +0 -2
  348. package/dist-esm/types.js +0 -66
  349. package/dist-esm/unit/size.util.js +0 -43
  350. package/dist-esm/web.js +0 -40
  351. package/dist-esm/zod/index.js +0 -4
  352. package/dist-esm/zod/zod.shared.schemas.js +0 -92
  353. package/dist-esm/zod/zod.util.js +0 -52
@@ -1,3 +0,0 @@
1
- /// <reference lib="es2022" preserve="true" />
2
- /// <reference lib="dom" preserve="true" />
3
- export {};
@@ -1 +0,0 @@
1
- export const HTTP_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'];
package/dist-esm/index.js DELETED
@@ -1,96 +0,0 @@
1
- export * from './abort';
2
- export * from './array/array.util';
3
- export * from './array/range';
4
- export * from './bot';
5
- export * from './browser/adminService';
6
- export * from './browser/analytics.util';
7
- export * from './browser/i18n/fetchTranslationLoader';
8
- export * from './browser/i18n/translation.service';
9
- export * from './browser/imageFitter';
10
- export * from './browser/script.util';
11
- export * from './browser/topbar';
12
- export * from './datetime/dateInterval';
13
- export * from './datetime/localDate';
14
- export * from './datetime/localTime';
15
- export * from './datetime/timeInterval';
16
- export * from './datetime/wallTime';
17
- export * from './decorators/asyncMemo.decorator';
18
- export * from './decorators/createPromiseDecorator';
19
- export * from './decorators/debounce';
20
- export * from './decorators/debounce.decorator';
21
- export * from './decorators/decorator.util';
22
- export * from './decorators/logMethod.decorator';
23
- export * from './decorators/memo.decorator';
24
- export * from './decorators/memo.util';
25
- export * from './decorators/memoFn';
26
- export * from './decorators/memoFnAsync';
27
- export * from './decorators/retry.decorator';
28
- export * from './decorators/timeout.decorator';
29
- export * from './define';
30
- export * from './deviceIdService';
31
- export * from './enum.util';
32
- export * from './env';
33
- export * from './env/buildInfo';
34
- export * from './error/assert';
35
- export * from './error/error.model';
36
- export * from './error/error.util';
37
- export * from './error/errorMode';
38
- export * from './error/try';
39
- export * from './error/tryCatch';
40
- export * from './form.util';
41
- export * from './http/fetcher';
42
- export * from './http/fetcher.model';
43
- export * from './http/http.model';
44
- export * from './is.util';
45
- export * from './iter/asyncIterable2';
46
- export * from './iter/iterable2';
47
- export * from './json-schema/from-data/generateJsonSchemaFromData';
48
- export * from './json-schema/jsonSchema.cnst';
49
- export * from './json-schema/jsonSchema.model';
50
- export * from './json-schema/jsonSchema.util';
51
- export * from './json-schema/jsonSchemaBuilder';
52
- export * from './log/commonLogger';
53
- export * from './math/accumulatingAverage';
54
- export * from './math/math.util';
55
- export * from './math/sma';
56
- export * from './math/stack.util';
57
- export * from './nanoid';
58
- export * from './number/createDeterministicRandom';
59
- export * from './number/number.util';
60
- export * from './object/deepEquals';
61
- export * from './object/map2';
62
- export * from './object/object.util';
63
- export * from './object/set2';
64
- export * from './object/sortObject';
65
- export * from './object/sortObjectDeep';
66
- export * from './polyfill';
67
- export * from './promise/abortable';
68
- export * from './promise/pDefer';
69
- export * from './promise/pDelay';
70
- export * from './promise/pFilter';
71
- export * from './promise/pHang';
72
- export * from './promise/pMap';
73
- export * from './promise/pProps';
74
- export * from './promise/pQueue';
75
- export * from './promise/pRetry';
76
- export * from './promise/pState';
77
- export * from './promise/pTimeout';
78
- export * from './semver';
79
- export * from './string/case';
80
- export * from './string/escape';
81
- export * from './string/hash.util';
82
- export * from './string/json.util';
83
- export * from './string/leven';
84
- export * from './string/pupa';
85
- export * from './string/readingTime';
86
- export * from './string/regex';
87
- export * from './string/safeJsonStringify';
88
- export * from './string/slugify';
89
- export * from './string/string.util';
90
- export * from './string/stringify';
91
- export * from './string/url.util';
92
- export * from './time/time.util';
93
- export * from './typeFest';
94
- export * from './types';
95
- export * from './unit/size.util';
96
- export * from './web';
@@ -1,70 +0,0 @@
1
- export const _isNull = (v) => v === null;
2
- export const _isUndefined = (v) => v === undefined;
3
- export const _isNullish = (v) => v === undefined || v === null;
4
- export const _isNotNullish = (v) => v !== undefined && v !== null;
5
- /**
6
- * Same as Boolean, but with correct type output.
7
- * Related:
8
- * https://github.com/microsoft/TypeScript/issues/16655
9
- * https://www.karltarvas.com/2021/03/11/typescript-array-filter-boolean.html
10
- *
11
- * @example
12
- *
13
- * [1, 2, undefined].filter(_isTruthy)
14
- * // => [1, 2]
15
- */
16
- export const _isTruthy = (v) => !!v;
17
- export const _isFalsy = (v) => !v;
18
- /**
19
- * Returns true if item is Object, not null and not Array.
20
- *
21
- * Currently treats RegEx as Object too, e.g _isObject(/some/) === true
22
- */
23
- export function _isObject(obj) {
24
- return (typeof obj === 'object' && obj !== null && !Array.isArray(obj)) || false;
25
- }
26
- export function _isPrimitive(v) {
27
- return (v === null ||
28
- v === undefined ||
29
- typeof v === 'number' ||
30
- typeof v === 'boolean' ||
31
- typeof v === 'string' ||
32
- typeof v === 'bigint' ||
33
- typeof v === 'symbol');
34
- }
35
- export function _isEmptyObject(obj) {
36
- return Object.keys(obj).length === 0;
37
- }
38
- export function _isNotEmptyObject(obj) {
39
- return Object.keys(obj).length > 0;
40
- }
41
- /**
42
- * Object is considered empty if it's one of:
43
- * undefined
44
- * null
45
- * '' (empty string)
46
- * [] (empty array)
47
- * {} (empty object)
48
- * new Map() (empty Map)
49
- * new Set() (empty Set)
50
- */
51
- export function _isEmpty(obj) {
52
- if (obj === undefined || obj === null)
53
- return true;
54
- if (typeof obj === 'string' || Array.isArray(obj)) {
55
- return obj.length === 0;
56
- }
57
- if (obj instanceof Map || obj instanceof Set) {
58
- return obj.size === 0;
59
- }
60
- if (typeof obj === 'object') {
61
- return Object.keys(obj).length === 0;
62
- }
63
- return false;
64
- }
65
- /**
66
- * @see _isEmpty
67
- */
68
- export function _isNotEmpty(obj) {
69
- return !_isEmpty(obj);
70
- }
@@ -1,103 +0,0 @@
1
- import { END, SKIP } from '../types';
2
- /**
3
- * Similar to Iterable2, but for AsyncIterable.
4
- *
5
- * AsyncIterable2 is a wrapper around AsyncIterable that implements "Iterator Helpers proposal":
6
- * https://github.com/tc39/proposal-iterator-helpers
7
- *
8
- * AsyncIterable2 can be removed after the proposal is widely implemented in Node & browsers.
9
- *
10
- * @experimental
11
- */
12
- export class AsyncIterable2 {
13
- constructor(it) {
14
- this.it = it;
15
- }
16
- static of(it) {
17
- return new AsyncIterable2(it);
18
- }
19
- static ofIterable(it) {
20
- return new AsyncIterable2({
21
- async *[Symbol.asyncIterator]() {
22
- yield* it;
23
- },
24
- });
25
- }
26
- static empty() {
27
- return new AsyncIterable2({
28
- async *[Symbol.asyncIterator]() { },
29
- });
30
- }
31
- [Symbol.asyncIterator]() {
32
- return this.it[Symbol.asyncIterator]();
33
- }
34
- async toArray() {
35
- // todo: Array.fromAsync is not yet available, use that when it's ready
36
- // return await Array.fromAsync(this.it)
37
- const res = [];
38
- for await (const item of this.it) {
39
- res.push(item);
40
- }
41
- return res;
42
- }
43
- async forEach(cb) {
44
- let i = 0;
45
- for await (const v of this.it) {
46
- if ((await cb(v, i++)) === END)
47
- return;
48
- }
49
- }
50
- async some(cb) {
51
- return !!(await this.find(cb));
52
- }
53
- async every(cb) {
54
- let i = 0;
55
- for await (const v of this.it) {
56
- const r = await cb(v, i++);
57
- if (r === END || !r)
58
- return false;
59
- }
60
- return true;
61
- }
62
- async find(cb) {
63
- let i = 0;
64
- for await (const v of this.it) {
65
- const r = await cb(v, i++);
66
- if (r === END)
67
- return;
68
- if (r)
69
- return v;
70
- }
71
- }
72
- filter(cb) {
73
- const { it } = this;
74
- return new AsyncIterable2({
75
- async *[Symbol.asyncIterator]() {
76
- let i = 0;
77
- for await (const v of it) {
78
- const r = await cb(v, i++);
79
- if (r === END)
80
- return;
81
- if (r)
82
- yield v;
83
- }
84
- },
85
- });
86
- }
87
- map(mapper) {
88
- const { it } = this;
89
- return new AsyncIterable2({
90
- async *[Symbol.asyncIterator]() {
91
- let i = 0;
92
- for await (const v of it) {
93
- const r = await mapper(v, i++);
94
- if (r === END)
95
- return;
96
- if (r === SKIP)
97
- continue;
98
- yield r;
99
- }
100
- },
101
- });
102
- }
103
- }
@@ -1,87 +0,0 @@
1
- import { END, SKIP } from '../types';
2
- /**
3
- * Iterable2 is a wrapper around Iterable that implements "Iterator Helpers proposal":
4
- * https://github.com/tc39/proposal-iterator-helpers
5
- *
6
- * Iterable2 can be removed after the proposal is widely implemented in Node & browsers.
7
- *
8
- * @experimental
9
- */
10
- export class Iterable2 {
11
- constructor(it) {
12
- this.it = it;
13
- }
14
- static of(it) {
15
- return new Iterable2(it);
16
- }
17
- static empty() {
18
- return new Iterable2([]);
19
- }
20
- [Symbol.iterator]() {
21
- return this.it[Symbol.iterator]();
22
- }
23
- toArray() {
24
- return [...this.it];
25
- }
26
- forEach(cb) {
27
- let i = 0;
28
- for (const v of this.it) {
29
- if (cb(v, i++) === END)
30
- return;
31
- }
32
- }
33
- some(cb) {
34
- // eslint-disable-next-line unicorn/prefer-array-some
35
- return !!this.find(cb);
36
- }
37
- every(cb) {
38
- let i = 0;
39
- for (const v of this.it) {
40
- const r = cb(v, i++);
41
- if (r === END || !r)
42
- return false;
43
- }
44
- return true;
45
- }
46
- find(cb) {
47
- let i = 0;
48
- for (const v of this.it) {
49
- const r = cb(v, i++);
50
- if (r === END)
51
- return;
52
- if (r)
53
- return v;
54
- }
55
- }
56
- filter(cb) {
57
- const { it } = this;
58
- return new Iterable2({
59
- *[Symbol.iterator]() {
60
- let i = 0;
61
- for (const v of it) {
62
- const r = cb(v, i++);
63
- if (r === END)
64
- return;
65
- if (r)
66
- yield v;
67
- }
68
- },
69
- });
70
- }
71
- map(mapper) {
72
- const { it } = this;
73
- return new Iterable2({
74
- *[Symbol.iterator]() {
75
- let i = 0;
76
- for (const v of it) {
77
- const r = mapper(v, i++);
78
- if (r === END)
79
- return;
80
- if (r === SKIP)
81
- continue;
82
- yield r;
83
- }
84
- },
85
- });
86
- }
87
- }
@@ -1,86 +0,0 @@
1
- import { _stringMapEntries, _uniq } from '../..';
2
- /**
3
- * Each row must be an object (current limitation).
4
- *
5
- * `additionalProperties` is set to `true`, cause it's safer.
6
- */
7
- export function generateJsonSchemaFromData(rows) {
8
- return objectToJsonSchema(rows);
9
- }
10
- function objectToJsonSchema(rows) {
11
- const typesByKey = {};
12
- rows.forEach(r => {
13
- Object.keys(r).forEach(key => {
14
- typesByKey[key] || (typesByKey[key] = new Set());
15
- typesByKey[key].add(getTypeOfValue(r[key]));
16
- });
17
- });
18
- const s = {
19
- type: 'object',
20
- properties: {},
21
- required: [],
22
- additionalProperties: true,
23
- };
24
- _stringMapEntries(typesByKey).forEach(([key, types]) => {
25
- const schema = mergeTypes([...types], rows.map(r => r[key]));
26
- if (!schema)
27
- return;
28
- s.properties[key] = schema;
29
- });
30
- // console.log(typesByKey)
31
- return s;
32
- }
33
- function mergeTypes(types, samples) {
34
- // skip "undefined" types
35
- types = types.filter(t => t !== 'undefined');
36
- if (!types.length)
37
- return undefined;
38
- if (types.length > 1) {
39
- // oneOf
40
- const s = {
41
- oneOf: types.map(type => mergeTypes([type], samples)),
42
- };
43
- return s;
44
- }
45
- const type = types[0];
46
- if (type === 'null') {
47
- return {
48
- type: 'null',
49
- };
50
- }
51
- if (type === 'boolean') {
52
- return {
53
- type: 'boolean',
54
- };
55
- }
56
- if (type === 'string') {
57
- return {
58
- type: 'string',
59
- };
60
- }
61
- if (type === 'number') {
62
- return {
63
- type: 'number',
64
- };
65
- }
66
- if (type === 'object') {
67
- return objectToJsonSchema(samples.filter((r) => r && typeof r === 'object'));
68
- }
69
- if (type === 'array') {
70
- // possible feature: detect if it's a tuple
71
- // currently assume no-tuple
72
- const items = samples.filter(r => Array.isArray(r)).flat(1);
73
- const itemTypes = _uniq(items.map(i => getTypeOfValue(i)));
74
- return {
75
- type: 'array',
76
- items: mergeTypes(itemTypes, items),
77
- };
78
- }
79
- }
80
- function getTypeOfValue(v) {
81
- if (v === null)
82
- return 'null';
83
- if (Array.isArray(v))
84
- return 'array';
85
- return typeof v;
86
- }
@@ -1,38 +0,0 @@
1
- export const JSON_SCHEMA_ORDER = [
2
- '$schema',
3
- '$id',
4
- 'title',
5
- 'description',
6
- 'deprecated',
7
- 'readOnly',
8
- 'writeOnly',
9
- 'type',
10
- 'default',
11
- // Object,
12
- 'properties',
13
- 'required',
14
- 'minProperties',
15
- 'maxProperties',
16
- 'patternProperties',
17
- 'propertyNames',
18
- // Array
19
- 'properties',
20
- 'required',
21
- 'minProperties',
22
- 'maxProperties',
23
- 'patternProperties',
24
- 'propertyNames',
25
- // String
26
- 'pattern',
27
- 'minLength',
28
- 'maxLength',
29
- 'format',
30
- 'transform',
31
- // Number
32
- 'format',
33
- 'multipleOf',
34
- 'minimum',
35
- 'exclusiveMinimum',
36
- 'maximum',
37
- 'exclusiveMaximum',
38
- ];
@@ -1 +0,0 @@
1
- export {};
@@ -1,27 +0,0 @@
1
- import { _uniq } from '../index';
2
- import { _filterNullishValues } from '../object/object.util';
3
- /**
4
- * Merges s2 into s1 (mutates s1) and returns s1.
5
- * Does not mutate s2.
6
- * API similar to Object.assign(s1, s2)
7
- */
8
- export function mergeJsonSchemaObjects(s1, s2) {
9
- // Merge `properties`
10
- Object.entries(s2.properties).forEach(([k, v]) => {
11
- ;
12
- s1.properties[k] = v;
13
- });
14
- // Merge `patternProperties`
15
- Object.entries(s2.patternProperties || {}).forEach(([k, v]) => {
16
- ;
17
- s1.patternProperties[k] = v;
18
- });
19
- s1.propertyNames = s2.propertyNames || s1.propertyNames;
20
- s1.minProperties = s2.minProperties ?? s1.minProperties;
21
- s1.maxProperties = s2.maxProperties ?? s1.maxProperties;
22
- // Merge `required`
23
- s1.required.push(...s2.required);
24
- s1.required = _uniq(s1.required).sort();
25
- // `additionalProperties` remains the same
26
- return _filterNullishValues(s1, true);
27
- }