@sparted/shared-library 1.9.5 → 1.9.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 (478) hide show
  1. package/package.json +3 -6
  2. package/.circleci/config.yml +0 -40
  3. package/.eslintignore +0 -1
  4. package/.eslintrc.json +0 -25
  5. package/.gitignore +0 -37
  6. package/.prettierrc.json +0 -6
  7. package/CHANGELOG.md +0 -457
  8. package/README.md +0 -26
  9. package/dist/package.json +0 -25
  10. package/global.d.ts +0 -2
  11. package/rollup.config.ts +0 -19
  12. package/sparted-shared-library-v1.7.93.tgz +0 -0
  13. package/src/array/__tests__/array-to-map.test.ts +0 -50
  14. package/src/array/__tests__/get-values-from-keys.test.ts +0 -14
  15. package/src/array/__tests__/inner-join.test.ts +0 -55
  16. package/src/array/__tests__/left-outter-join.test.ts +0 -55
  17. package/src/array/array-to-map.ts +0 -32
  18. package/src/array/get-values-from-keys.ts +0 -3
  19. package/src/array/index.ts +0 -4
  20. package/src/array/inner-join.ts +0 -10
  21. package/src/array/left-outter-join.ts +0 -10
  22. package/src/business/campaign/__tests__/compute-current-session.test.ts +0 -189
  23. package/src/business/campaign/__tests__/compute-intense-calendar.test.ts +0 -134
  24. package/src/business/campaign/__tests__/find-next-available-date.test.ts +0 -82
  25. package/src/business/campaign/__tests__/get-calendar-dession-dates-from-campaign.test.ts +0 -123
  26. package/src/business/campaign/index.ts +0 -1
  27. package/src/business/campaign/live-campaign.ts +0 -133
  28. package/src/business/course/index.ts +0 -1
  29. package/src/business/course/microknowledge-max-lengths.ts +0 -12
  30. package/src/business/index.ts +0 -4
  31. package/src/business/picture-spot/index.ts +0 -3
  32. package/src/business/types/achievement.ts +0 -41
  33. package/src/business/types/activity.ts +0 -64
  34. package/src/business/types/audience.ts +0 -23
  35. package/src/business/types/battle.ts +0 -17
  36. package/src/business/types/breaking-news.ts +0 -43
  37. package/src/business/types/campaign.ts +0 -163
  38. package/src/business/types/content.ts +0 -261
  39. package/src/business/types/document.ts +0 -17
  40. package/src/business/types/index.ts +0 -14
  41. package/src/business/types/media.ts +0 -18
  42. package/src/business/types/multilingual.ts +0 -47
  43. package/src/business/types/player.ts +0 -28
  44. package/src/business/types/score.ts +0 -61
  45. package/src/business/types/thematic.ts +0 -12
  46. package/src/business/types/user-engagement.ts +0 -11
  47. package/src/cdn/__tests__/cdn.factory.test.ts +0 -150
  48. package/src/cdn/__tests__/utils.test.ts +0 -528
  49. package/src/cdn/cdn.factory.ts +0 -70
  50. package/src/cdn/index.ts +0 -2
  51. package/src/cdn/types/cdn-factory.type.ts +0 -49
  52. package/src/cdn/types/index.ts +0 -1
  53. package/src/cdn/utils/extract-info-from-url.util.ts +0 -25
  54. package/src/cdn/utils/get-cdn-from-s3-url.util.ts +0 -20
  55. package/src/cdn/utils/get-cdn-url.util.ts +0 -31
  56. package/src/cdn/utils/twicpics-transformations.util.ts +0 -9
  57. package/src/chrono/get-approximated-session-time.ts +0 -27
  58. package/src/chrono/index.ts +0 -1
  59. package/src/color/__tests__/get-contrast-color.test.ts +0 -22
  60. package/src/color/get-contrast-color.ts +0 -18
  61. package/src/color/index.ts +0 -1
  62. package/src/crypto/__tests__/aes256.test.ts +0 -23
  63. package/src/crypto/aes256.ts +0 -22
  64. package/src/crypto/index.ts +0 -1
  65. package/src/date/__tests__/get-iso-day-number.test.ts +0 -34
  66. package/src/date/__tests__/get-remaining-time.test.ts +0 -78
  67. package/src/date/__tests__/get-start-of-day.test.ts +0 -92
  68. package/src/date/__tests__/is-same-date.test.ts +0 -50
  69. package/src/date/__tests__/shift-date-by.test.ts +0 -76
  70. package/src/date/__tests__/to-utc-date-string.test.ts +0 -28
  71. package/src/date/add-days.ts +0 -5
  72. package/src/date/difference-in-days.ts +0 -6
  73. package/src/date/get-iso-day-number.ts +0 -1
  74. package/src/date/get-next-day.ts +0 -6
  75. package/src/date/get-remaining-time.ts +0 -24
  76. package/src/date/get-start-of-day.ts +0 -11
  77. package/src/date/index.ts +0 -10
  78. package/src/date/is-same-date.ts +0 -7
  79. package/src/date/shift-date-by.ts +0 -17
  80. package/src/date/to-plain-date-string.ts +0 -1
  81. package/src/date/to-utc-date-string.ts +0 -3
  82. package/src/formatting/__tests__/format-number.test.ts +0 -11
  83. package/src/formatting/format-number.ts +0 -14
  84. package/src/formatting/index.ts +0 -1
  85. package/src/fp/__tests__/run-while.test.ts +0 -29
  86. package/src/fp/index.ts +0 -1
  87. package/src/fp/run-while.ts +0 -54
  88. package/src/http/__tests__/build-search-params.test.ts +0 -17
  89. package/src/http/__tests__/encode-search-object.test.ts +0 -34
  90. package/src/http/__tests__/fetch-with-timeout.test.ts +0 -50
  91. package/src/http/build-search-params.ts +0 -16
  92. package/src/http/encode-search-object.ts +0 -42
  93. package/src/http/fetch-with-timeout.ts +0 -27
  94. package/src/http/index.ts +0 -3
  95. package/src/index.ts +0 -19
  96. package/src/linked-list/__tests__/apply-diff-linked-list.test.ts +0 -103
  97. package/src/linked-list/__tests__/create-linked-list.test.ts +0 -204
  98. package/src/linked-list/__tests__/find-linked-list.test.ts +0 -40
  99. package/src/linked-list/__tests__/get-linked-list.test.ts +0 -28
  100. package/src/linked-list/__tests__/insert-linked-list.test.ts +0 -186
  101. package/src/linked-list/__tests__/linked-list-utils.test.ts +0 -252
  102. package/src/linked-list/__tests__/reduce-linked-list.test.ts +0 -31
  103. package/src/linked-list/__tests__/remove-linked-list.test.ts +0 -129
  104. package/src/linked-list/__tests__/update-linked-list.test.ts +0 -53
  105. package/src/linked-list/__tests__/while-linked-list.test.ts +0 -58
  106. package/src/linked-list/apply-diff-linked-list.ts +0 -35
  107. package/src/linked-list/create-linked-list.ts +0 -79
  108. package/src/linked-list/find-linked-list.ts +0 -26
  109. package/src/linked-list/get-linked-list.ts +0 -9
  110. package/src/linked-list/index.ts +0 -2
  111. package/src/linked-list/insert-linked-list.ts +0 -50
  112. package/src/linked-list/linked-list-utils.ts +0 -143
  113. package/src/linked-list/reduce-linked-list.ts +0 -18
  114. package/src/linked-list/remove-linked-list.ts +0 -36
  115. package/src/linked-list/type.ts +0 -38
  116. package/src/linked-list/update-linked-list.ts +0 -30
  117. package/src/linked-list/while-linked-list.ts +0 -33
  118. package/src/math/__tests__/clamp-number.test.ts +0 -30
  119. package/src/math/__tests__/interpolate.test.ts +0 -28
  120. package/src/math/__tests__/median.test.ts +0 -27
  121. package/src/math/__tests__/number-range.test.ts +0 -59
  122. package/src/math/__tests__/random-number.test.ts +0 -11
  123. package/src/math/clamp-number.ts +0 -8
  124. package/src/math/index.ts +0 -5
  125. package/src/math/interpolate.ts +0 -18
  126. package/src/math/median.ts +0 -21
  127. package/src/math/number-range.ts +0 -16
  128. package/src/math/random-number.ts +0 -10
  129. package/src/object/__tests__/merge-deep.test.ts +0 -56
  130. package/src/object/__tests__/strip-properties-from-object.test.ts +0 -65
  131. package/src/object/index.ts +0 -2
  132. package/src/object/merge-deep.ts +0 -26
  133. package/src/object/strip-properties-from-object.ts +0 -26
  134. package/src/parsing/__tests__/parse-boolean.test.ts +0 -15
  135. package/src/parsing/__tests__/parse-enum.test.ts +0 -19
  136. package/src/parsing/__tests__/parse-number.test.ts +0 -20
  137. package/src/parsing/index.ts +0 -3
  138. package/src/parsing/parse-boolean.ts +0 -10
  139. package/src/parsing/parse-enum.ts +0 -16
  140. package/src/parsing/parse-number.ts +0 -12
  141. package/src/predicates/__tests__/is-function.test.ts +0 -11
  142. package/src/predicates/__tests__/is-null.test.ts +0 -11
  143. package/src/predicates/__tests__/is-object.test.ts +0 -11
  144. package/src/predicates/__tests__/is-primitive.test.ts +0 -42
  145. package/src/predicates/__tests__/is-undefined.test.ts +0 -11
  146. package/src/predicates/__tests__/is-uuid.test.ts +0 -13
  147. package/src/predicates/index.ts +0 -5
  148. package/src/predicates/is-function.ts +0 -3
  149. package/src/predicates/is-null.ts +0 -1
  150. package/src/predicates/is-object.ts +0 -3
  151. package/src/predicates/is-primitive.ts +0 -19
  152. package/src/predicates/is-undefined.ts +0 -3
  153. package/src/predicates/is-uuid.ts +0 -3
  154. package/src/promise/__tests__/delay.test.ts +0 -13
  155. package/src/promise/__tests__/execute-or-resolve-default.test.ts +0 -25
  156. package/src/promise/__tests__/execute-with-delay.test.ts +0 -24
  157. package/src/promise/delay.ts +0 -3
  158. package/src/promise/execute-or-resolve-default.ts +0 -14
  159. package/src/promise/execute-with-delay.ts +0 -6
  160. package/src/promise/index.ts +0 -3
  161. package/src/string/__tests__/is-string-length-within-range.test.ts +0 -23
  162. package/src/string/__tests__/replace-in-template.test.ts +0 -52
  163. package/src/string/index.ts +0 -2
  164. package/src/string/is-string-length-within-range.ts +0 -10
  165. package/src/string/replace-in-template.ts +0 -45
  166. package/src/time/__tests__/convert.test.ts +0 -14
  167. package/src/time/__tests__/format-minutes.test.ts +0 -10
  168. package/src/time/__tests__/get-time-diff-as-string.test.ts +0 -128
  169. package/src/time/constants.ts +0 -4
  170. package/src/time/convert.ts +0 -5
  171. package/src/time/format-minutes.ts +0 -9
  172. package/src/time/get-time-diff-as-string.ts +0 -196
  173. package/src/time/index.ts +0 -4
  174. package/src/types/function.ts +0 -1
  175. package/src/types/general.ts +0 -15
  176. package/src/types/index.ts +0 -4
  177. package/src/types/object.ts +0 -33
  178. package/src/types/search.ts +0 -36
  179. package/tmp-lib.tgz +0 -0
  180. package/tsconfig.json +0 -25
  181. package/yarn.lock +0 -4280
  182. /package/{dist/_virtual → _virtual}/_tslib.js +0 -0
  183. /package/{dist/_virtual → _virtual}/_tslib.js.map +0 -0
  184. /package/{dist/array → array}/array-to-map.d.ts +0 -0
  185. /package/{dist/array → array}/array-to-map.js +0 -0
  186. /package/{dist/array → array}/array-to-map.js.map +0 -0
  187. /package/{dist/array → array}/get-values-from-keys.d.ts +0 -0
  188. /package/{dist/array → array}/get-values-from-keys.js +0 -0
  189. /package/{dist/array → array}/get-values-from-keys.js.map +0 -0
  190. /package/{dist/array → array}/index.d.ts +0 -0
  191. /package/{dist/array → array}/index.js +0 -0
  192. /package/{dist/array → array}/index.js.map +0 -0
  193. /package/{dist/array → array}/inner-join.d.ts +0 -0
  194. /package/{dist/array → array}/inner-join.js +0 -0
  195. /package/{dist/array → array}/inner-join.js.map +0 -0
  196. /package/{dist/array → array}/left-outter-join.d.ts +0 -0
  197. /package/{dist/array → array}/left-outter-join.js +0 -0
  198. /package/{dist/array → array}/left-outter-join.js.map +0 -0
  199. /package/{dist/business → business}/campaign/index.d.ts +0 -0
  200. /package/{dist/business → business}/campaign/index.js +0 -0
  201. /package/{dist/business → business}/campaign/index.js.map +0 -0
  202. /package/{dist/business → business}/campaign/live-campaign.d.ts +0 -0
  203. /package/{dist/business → business}/campaign/live-campaign.js +0 -0
  204. /package/{dist/business → business}/campaign/live-campaign.js.map +0 -0
  205. /package/{dist/business → business}/course/index.d.ts +0 -0
  206. /package/{dist/business → business}/course/index.js +0 -0
  207. /package/{dist/business → business}/course/index.js.map +0 -0
  208. /package/{dist/business → business}/course/microknowledge-max-lengths.d.ts +0 -0
  209. /package/{dist/business → business}/course/microknowledge-max-lengths.js +0 -0
  210. /package/{dist/business → business}/course/microknowledge-max-lengths.js.map +0 -0
  211. /package/{dist/business → business}/index.d.ts +0 -0
  212. /package/{dist/business → business}/index.js +0 -0
  213. /package/{dist/business → business}/index.js.map +0 -0
  214. /package/{dist/business → business}/picture-spot/index.d.ts +0 -0
  215. /package/{dist/business → business}/picture-spot/index.js +0 -0
  216. /package/{dist/business → business}/picture-spot/index.js.map +0 -0
  217. /package/{dist/business → business}/types/achievement.d.ts +0 -0
  218. /package/{dist/business → business}/types/activity.d.ts +0 -0
  219. /package/{dist/business → business}/types/activity.js +0 -0
  220. /package/{dist/business → business}/types/activity.js.map +0 -0
  221. /package/{dist/business → business}/types/audience.d.ts +0 -0
  222. /package/{dist/business → business}/types/battle.d.ts +0 -0
  223. /package/{dist/business → business}/types/breaking-news.d.ts +0 -0
  224. /package/{dist/business → business}/types/campaign.d.ts +0 -0
  225. /package/{dist/business → business}/types/campaign.js +0 -0
  226. /package/{dist/business → business}/types/campaign.js.map +0 -0
  227. /package/{dist/business → business}/types/content.d.ts +0 -0
  228. /package/{dist/business → business}/types/content.js +0 -0
  229. /package/{dist/business → business}/types/content.js.map +0 -0
  230. /package/{dist/business → business}/types/document.d.ts +0 -0
  231. /package/{dist/business → business}/types/index.d.ts +0 -0
  232. /package/{dist/business → business}/types/index.js +0 -0
  233. /package/{dist/business → business}/types/index.js.map +0 -0
  234. /package/{dist/business → business}/types/media.d.ts +0 -0
  235. /package/{dist/business → business}/types/multilingual.d.ts +0 -0
  236. /package/{dist/business → business}/types/multilingual.js +0 -0
  237. /package/{dist/business → business}/types/multilingual.js.map +0 -0
  238. /package/{dist/business → business}/types/player.d.ts +0 -0
  239. /package/{dist/business → business}/types/score.d.ts +0 -0
  240. /package/{dist/business → business}/types/score.js +0 -0
  241. /package/{dist/business → business}/types/score.js.map +0 -0
  242. /package/{dist/business → business}/types/thematic.d.ts +0 -0
  243. /package/{dist/business → business}/types/user-engagement.d.ts +0 -0
  244. /package/{dist/cdn → cdn}/cdn.factory.d.ts +0 -0
  245. /package/{dist/cdn → cdn}/cdn.factory.js +0 -0
  246. /package/{dist/cdn → cdn}/cdn.factory.js.map +0 -0
  247. /package/{dist/cdn → cdn}/index.d.ts +0 -0
  248. /package/{dist/cdn → cdn}/index.js +0 -0
  249. /package/{dist/cdn → cdn}/index.js.map +0 -0
  250. /package/{dist/cdn → cdn}/types/cdn-factory.type.d.ts +0 -0
  251. /package/{dist/cdn → cdn}/types/index.d.ts +0 -0
  252. /package/{dist/cdn → cdn}/types/index.js +0 -0
  253. /package/{dist/cdn → cdn}/types/index.js.map +0 -0
  254. /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.d.ts +0 -0
  255. /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.js +0 -0
  256. /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.js.map +0 -0
  257. /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.d.ts +0 -0
  258. /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.js +0 -0
  259. /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.js.map +0 -0
  260. /package/{dist/cdn → cdn}/utils/get-cdn-url.util.d.ts +0 -0
  261. /package/{dist/cdn → cdn}/utils/get-cdn-url.util.js +0 -0
  262. /package/{dist/cdn → cdn}/utils/get-cdn-url.util.js.map +0 -0
  263. /package/{dist/cdn → cdn}/utils/twicpics-transformations.util.d.ts +0 -0
  264. /package/{dist/cdn → cdn}/utils/twicpics-transformations.util.js +0 -0
  265. /package/{dist/cdn → cdn}/utils/twicpics-transformations.util.js.map +0 -0
  266. /package/{dist/chrono → chrono}/get-approximated-session-time.d.ts +0 -0
  267. /package/{dist/chrono → chrono}/get-approximated-session-time.js +0 -0
  268. /package/{dist/chrono → chrono}/get-approximated-session-time.js.map +0 -0
  269. /package/{dist/chrono → chrono}/index.d.ts +0 -0
  270. /package/{dist/chrono → chrono}/index.js +0 -0
  271. /package/{dist/chrono → chrono}/index.js.map +0 -0
  272. /package/{dist/color → color}/get-contrast-color.d.ts +0 -0
  273. /package/{dist/color → color}/get-contrast-color.js +0 -0
  274. /package/{dist/color → color}/get-contrast-color.js.map +0 -0
  275. /package/{dist/color → color}/index.d.ts +0 -0
  276. /package/{dist/color → color}/index.js +0 -0
  277. /package/{dist/color → color}/index.js.map +0 -0
  278. /package/{dist/crypto → crypto}/aes256.d.ts +0 -0
  279. /package/{dist/crypto → crypto}/aes256.js +0 -0
  280. /package/{dist/crypto → crypto}/aes256.js.map +0 -0
  281. /package/{dist/crypto → crypto}/index.d.ts +0 -0
  282. /package/{dist/crypto → crypto}/index.js +0 -0
  283. /package/{dist/crypto → crypto}/index.js.map +0 -0
  284. /package/{dist/date → date}/add-days.d.ts +0 -0
  285. /package/{dist/date → date}/add-days.js +0 -0
  286. /package/{dist/date → date}/add-days.js.map +0 -0
  287. /package/{dist/date → date}/difference-in-days.d.ts +0 -0
  288. /package/{dist/date → date}/difference-in-days.js +0 -0
  289. /package/{dist/date → date}/difference-in-days.js.map +0 -0
  290. /package/{dist/date → date}/get-iso-day-number.d.ts +0 -0
  291. /package/{dist/date → date}/get-iso-day-number.js +0 -0
  292. /package/{dist/date → date}/get-iso-day-number.js.map +0 -0
  293. /package/{dist/date → date}/get-next-day.d.ts +0 -0
  294. /package/{dist/date → date}/get-next-day.js +0 -0
  295. /package/{dist/date → date}/get-next-day.js.map +0 -0
  296. /package/{dist/date → date}/get-remaining-time.d.ts +0 -0
  297. /package/{dist/date → date}/get-remaining-time.js +0 -0
  298. /package/{dist/date → date}/get-remaining-time.js.map +0 -0
  299. /package/{dist/date → date}/get-start-of-day.d.ts +0 -0
  300. /package/{dist/date → date}/get-start-of-day.js +0 -0
  301. /package/{dist/date → date}/get-start-of-day.js.map +0 -0
  302. /package/{dist/date → date}/index.d.ts +0 -0
  303. /package/{dist/date → date}/index.js +0 -0
  304. /package/{dist/date → date}/index.js.map +0 -0
  305. /package/{dist/date → date}/is-same-date.d.ts +0 -0
  306. /package/{dist/date → date}/is-same-date.js +0 -0
  307. /package/{dist/date → date}/is-same-date.js.map +0 -0
  308. /package/{dist/date → date}/shift-date-by.d.ts +0 -0
  309. /package/{dist/date → date}/shift-date-by.js +0 -0
  310. /package/{dist/date → date}/shift-date-by.js.map +0 -0
  311. /package/{dist/date → date}/to-plain-date-string.d.ts +0 -0
  312. /package/{dist/date → date}/to-plain-date-string.js +0 -0
  313. /package/{dist/date → date}/to-plain-date-string.js.map +0 -0
  314. /package/{dist/date → date}/to-utc-date-string.d.ts +0 -0
  315. /package/{dist/date → date}/to-utc-date-string.js +0 -0
  316. /package/{dist/date → date}/to-utc-date-string.js.map +0 -0
  317. /package/{dist/formatting → formatting}/format-number.d.ts +0 -0
  318. /package/{dist/formatting → formatting}/format-number.js +0 -0
  319. /package/{dist/formatting → formatting}/format-number.js.map +0 -0
  320. /package/{dist/formatting → formatting}/index.d.ts +0 -0
  321. /package/{dist/formatting → formatting}/index.js +0 -0
  322. /package/{dist/formatting → formatting}/index.js.map +0 -0
  323. /package/{dist/fp → fp}/index.d.ts +0 -0
  324. /package/{dist/fp → fp}/index.js +0 -0
  325. /package/{dist/fp → fp}/index.js.map +0 -0
  326. /package/{dist/fp → fp}/run-while.d.ts +0 -0
  327. /package/{dist/fp → fp}/run-while.js +0 -0
  328. /package/{dist/fp → fp}/run-while.js.map +0 -0
  329. /package/{dist/http → http}/build-search-params.d.ts +0 -0
  330. /package/{dist/http → http}/build-search-params.js +0 -0
  331. /package/{dist/http → http}/build-search-params.js.map +0 -0
  332. /package/{dist/http → http}/encode-search-object.d.ts +0 -0
  333. /package/{dist/http → http}/encode-search-object.js +0 -0
  334. /package/{dist/http → http}/encode-search-object.js.map +0 -0
  335. /package/{dist/http → http}/fetch-with-timeout.d.ts +0 -0
  336. /package/{dist/http → http}/fetch-with-timeout.js +0 -0
  337. /package/{dist/http → http}/fetch-with-timeout.js.map +0 -0
  338. /package/{dist/http → http}/index.d.ts +0 -0
  339. /package/{dist/http → http}/index.js +0 -0
  340. /package/{dist/http → http}/index.js.map +0 -0
  341. /package/{dist/index.d.ts → index.d.ts} +0 -0
  342. /package/{dist/index.js → index.js} +0 -0
  343. /package/{dist/index.js.map → index.js.map} +0 -0
  344. /package/{dist/linked-list → linked-list}/apply-diff-linked-list.d.ts +0 -0
  345. /package/{dist/linked-list → linked-list}/apply-diff-linked-list.js +0 -0
  346. /package/{dist/linked-list → linked-list}/apply-diff-linked-list.js.map +0 -0
  347. /package/{dist/linked-list → linked-list}/create-linked-list.d.ts +0 -0
  348. /package/{dist/linked-list → linked-list}/create-linked-list.js +0 -0
  349. /package/{dist/linked-list → linked-list}/create-linked-list.js.map +0 -0
  350. /package/{dist/linked-list → linked-list}/find-linked-list.d.ts +0 -0
  351. /package/{dist/linked-list → linked-list}/find-linked-list.js +0 -0
  352. /package/{dist/linked-list → linked-list}/find-linked-list.js.map +0 -0
  353. /package/{dist/linked-list → linked-list}/get-linked-list.d.ts +0 -0
  354. /package/{dist/linked-list → linked-list}/get-linked-list.js +0 -0
  355. /package/{dist/linked-list → linked-list}/get-linked-list.js.map +0 -0
  356. /package/{dist/linked-list → linked-list}/index.d.ts +0 -0
  357. /package/{dist/linked-list → linked-list}/index.js +0 -0
  358. /package/{dist/linked-list → linked-list}/index.js.map +0 -0
  359. /package/{dist/linked-list → linked-list}/insert-linked-list.d.ts +0 -0
  360. /package/{dist/linked-list → linked-list}/insert-linked-list.js +0 -0
  361. /package/{dist/linked-list → linked-list}/insert-linked-list.js.map +0 -0
  362. /package/{dist/linked-list → linked-list}/linked-list-utils.d.ts +0 -0
  363. /package/{dist/linked-list → linked-list}/linked-list-utils.js +0 -0
  364. /package/{dist/linked-list → linked-list}/linked-list-utils.js.map +0 -0
  365. /package/{dist/linked-list → linked-list}/reduce-linked-list.d.ts +0 -0
  366. /package/{dist/linked-list → linked-list}/reduce-linked-list.js +0 -0
  367. /package/{dist/linked-list → linked-list}/reduce-linked-list.js.map +0 -0
  368. /package/{dist/linked-list → linked-list}/remove-linked-list.d.ts +0 -0
  369. /package/{dist/linked-list → linked-list}/remove-linked-list.js +0 -0
  370. /package/{dist/linked-list → linked-list}/remove-linked-list.js.map +0 -0
  371. /package/{dist/linked-list → linked-list}/type.d.ts +0 -0
  372. /package/{dist/linked-list → linked-list}/update-linked-list.d.ts +0 -0
  373. /package/{dist/linked-list → linked-list}/update-linked-list.js +0 -0
  374. /package/{dist/linked-list → linked-list}/update-linked-list.js.map +0 -0
  375. /package/{dist/linked-list → linked-list}/while-linked-list.d.ts +0 -0
  376. /package/{dist/linked-list → linked-list}/while-linked-list.js +0 -0
  377. /package/{dist/linked-list → linked-list}/while-linked-list.js.map +0 -0
  378. /package/{dist/math → math}/clamp-number.d.ts +0 -0
  379. /package/{dist/math → math}/clamp-number.js +0 -0
  380. /package/{dist/math → math}/clamp-number.js.map +0 -0
  381. /package/{dist/math → math}/index.d.ts +0 -0
  382. /package/{dist/math → math}/index.js +0 -0
  383. /package/{dist/math → math}/index.js.map +0 -0
  384. /package/{dist/math → math}/interpolate.d.ts +0 -0
  385. /package/{dist/math → math}/interpolate.js +0 -0
  386. /package/{dist/math → math}/interpolate.js.map +0 -0
  387. /package/{dist/math → math}/median.d.ts +0 -0
  388. /package/{dist/math → math}/median.js +0 -0
  389. /package/{dist/math → math}/median.js.map +0 -0
  390. /package/{dist/math → math}/number-range.d.ts +0 -0
  391. /package/{dist/math → math}/number-range.js +0 -0
  392. /package/{dist/math → math}/number-range.js.map +0 -0
  393. /package/{dist/math → math}/random-number.d.ts +0 -0
  394. /package/{dist/math → math}/random-number.js +0 -0
  395. /package/{dist/math → math}/random-number.js.map +0 -0
  396. /package/{dist/object → object}/index.d.ts +0 -0
  397. /package/{dist/object → object}/index.js +0 -0
  398. /package/{dist/object → object}/index.js.map +0 -0
  399. /package/{dist/object → object}/merge-deep.d.ts +0 -0
  400. /package/{dist/object → object}/merge-deep.js +0 -0
  401. /package/{dist/object → object}/merge-deep.js.map +0 -0
  402. /package/{dist/object → object}/strip-properties-from-object.d.ts +0 -0
  403. /package/{dist/object → object}/strip-properties-from-object.js +0 -0
  404. /package/{dist/object → object}/strip-properties-from-object.js.map +0 -0
  405. /package/{dist/parsing → parsing}/index.d.ts +0 -0
  406. /package/{dist/parsing → parsing}/index.js +0 -0
  407. /package/{dist/parsing → parsing}/index.js.map +0 -0
  408. /package/{dist/parsing → parsing}/parse-boolean.d.ts +0 -0
  409. /package/{dist/parsing → parsing}/parse-boolean.js +0 -0
  410. /package/{dist/parsing → parsing}/parse-boolean.js.map +0 -0
  411. /package/{dist/parsing → parsing}/parse-enum.d.ts +0 -0
  412. /package/{dist/parsing → parsing}/parse-enum.js +0 -0
  413. /package/{dist/parsing → parsing}/parse-enum.js.map +0 -0
  414. /package/{dist/parsing → parsing}/parse-number.d.ts +0 -0
  415. /package/{dist/parsing → parsing}/parse-number.js +0 -0
  416. /package/{dist/parsing → parsing}/parse-number.js.map +0 -0
  417. /package/{dist/predicates → predicates}/index.d.ts +0 -0
  418. /package/{dist/predicates → predicates}/index.js +0 -0
  419. /package/{dist/predicates → predicates}/index.js.map +0 -0
  420. /package/{dist/predicates → predicates}/is-function.d.ts +0 -0
  421. /package/{dist/predicates → predicates}/is-function.js +0 -0
  422. /package/{dist/predicates → predicates}/is-function.js.map +0 -0
  423. /package/{dist/predicates → predicates}/is-null.d.ts +0 -0
  424. /package/{dist/predicates → predicates}/is-null.js +0 -0
  425. /package/{dist/predicates → predicates}/is-null.js.map +0 -0
  426. /package/{dist/predicates → predicates}/is-object.d.ts +0 -0
  427. /package/{dist/predicates → predicates}/is-object.js +0 -0
  428. /package/{dist/predicates → predicates}/is-object.js.map +0 -0
  429. /package/{dist/predicates → predicates}/is-primitive.d.ts +0 -0
  430. /package/{dist/predicates → predicates}/is-primitive.js +0 -0
  431. /package/{dist/predicates → predicates}/is-primitive.js.map +0 -0
  432. /package/{dist/predicates → predicates}/is-undefined.d.ts +0 -0
  433. /package/{dist/predicates → predicates}/is-undefined.js +0 -0
  434. /package/{dist/predicates → predicates}/is-undefined.js.map +0 -0
  435. /package/{dist/predicates → predicates}/is-uuid.d.ts +0 -0
  436. /package/{dist/promise → promise}/delay.d.ts +0 -0
  437. /package/{dist/promise → promise}/delay.js +0 -0
  438. /package/{dist/promise → promise}/delay.js.map +0 -0
  439. /package/{dist/promise → promise}/execute-or-resolve-default.d.ts +0 -0
  440. /package/{dist/promise → promise}/execute-or-resolve-default.js +0 -0
  441. /package/{dist/promise → promise}/execute-or-resolve-default.js.map +0 -0
  442. /package/{dist/promise → promise}/execute-with-delay.d.ts +0 -0
  443. /package/{dist/promise → promise}/execute-with-delay.js +0 -0
  444. /package/{dist/promise → promise}/execute-with-delay.js.map +0 -0
  445. /package/{dist/promise → promise}/index.d.ts +0 -0
  446. /package/{dist/promise → promise}/index.js +0 -0
  447. /package/{dist/promise → promise}/index.js.map +0 -0
  448. /package/{dist/string → string}/index.d.ts +0 -0
  449. /package/{dist/string → string}/index.js +0 -0
  450. /package/{dist/string → string}/index.js.map +0 -0
  451. /package/{dist/string → string}/is-string-length-within-range.d.ts +0 -0
  452. /package/{dist/string → string}/is-string-length-within-range.js +0 -0
  453. /package/{dist/string → string}/is-string-length-within-range.js.map +0 -0
  454. /package/{dist/string → string}/replace-in-template.d.ts +0 -0
  455. /package/{dist/string → string}/replace-in-template.js +0 -0
  456. /package/{dist/string → string}/replace-in-template.js.map +0 -0
  457. /package/{dist/time → time}/constants.d.ts +0 -0
  458. /package/{dist/time → time}/constants.js +0 -0
  459. /package/{dist/time → time}/constants.js.map +0 -0
  460. /package/{dist/time → time}/convert.d.ts +0 -0
  461. /package/{dist/time → time}/convert.js +0 -0
  462. /package/{dist/time → time}/convert.js.map +0 -0
  463. /package/{dist/time → time}/format-minutes.d.ts +0 -0
  464. /package/{dist/time → time}/format-minutes.js +0 -0
  465. /package/{dist/time → time}/format-minutes.js.map +0 -0
  466. /package/{dist/time → time}/get-time-diff-as-string.d.ts +0 -0
  467. /package/{dist/time → time}/get-time-diff-as-string.js +0 -0
  468. /package/{dist/time → time}/get-time-diff-as-string.js.map +0 -0
  469. /package/{dist/time → time}/index.d.ts +0 -0
  470. /package/{dist/time → time}/index.js +0 -0
  471. /package/{dist/time → time}/index.js.map +0 -0
  472. /package/{dist/types → types}/function.d.ts +0 -0
  473. /package/{dist/types → types}/general.d.ts +0 -0
  474. /package/{dist/types → types}/index.d.ts +0 -0
  475. /package/{dist/types → types}/index.js +0 -0
  476. /package/{dist/types → types}/index.js.map +0 -0
  477. /package/{dist/types → types}/object.d.ts +0 -0
  478. /package/{dist/types → types}/search.d.ts +0 -0
@@ -1,59 +0,0 @@
1
- import { assertNumberRange, isNumberInRange } from '../number-range';
2
-
3
- describe('assertNumberRange', () => {
4
- it('should throw an error if min is above max', () => {
5
- expect(
6
- () => assertNumberRange({
7
- min: 5,
8
- max: 0,
9
- }),
10
- ).toThrowError('Invalid number range: min must be lower than or equal to max');
11
- });
12
-
13
- it('should not throw an error if the number range is valid', () => {
14
- expect(
15
- () => assertNumberRange({
16
- min: 0,
17
- max: 5,
18
- }),
19
- ).not.toThrowError();
20
- });
21
- });
22
-
23
- describe('isNumberInRange', () => {
24
- it('should throw an error if range is incorrect', () => {
25
- expect(
26
- () => isNumberInRange(2, {
27
- min: 5,
28
- max: 0,
29
- }),
30
- ).toThrowError('Invalid number range: min must be lower than or equal to max');
31
- });
32
-
33
- it('should return true if number is in range', () => {
34
- const set = [
35
- { num: 1, range: { min: 0, max: 1 } },
36
- { num: 0, range: { min: 0, max: 1 } },
37
- { num: 0.5, range: { min: 0, max: 1 } },
38
- { num: -30, range: { min: -1000, max: 1000 } },
39
- ];
40
-
41
- set.forEach(({ num, range }) => {
42
- expect(isNumberInRange(num, range)).toBeTrue();
43
- });
44
- });
45
-
46
- it('should return false if number is not in range', () => {
47
- const set = [
48
- { num: -5, range: { min: 0, max: 1 } },
49
- { num: 1.01, range: { min: 0, max: 1 } },
50
- { num: 10, range: { min: 0, max: 1 } },
51
- { num: -2000, range: { min: -1000, max: 1000 } },
52
- { num: 2000, range: { min: -1000, max: 1000 } },
53
- ];
54
-
55
- set.forEach(({ num, range }) => {
56
- expect(isNumberInRange(num, range)).toBeFalse();
57
- });
58
- });
59
- });
@@ -1,11 +0,0 @@
1
- import { randomNumber } from '../random-number';
2
-
3
- describe('randomNumber', () => {
4
- const satisfyInRange = (min: number, max: number) => (value: number) => value >= min && value <= max;
5
-
6
- it('should return a random number between the range', () => {
7
- expect(randomNumber({ min: 98, max: 110 })).toSatisfy(satisfyInRange(98, 110));
8
- expect(randomNumber({ min: -5, max: 0 })).toSatisfy(satisfyInRange(-5, 0));
9
- expect(randomNumber({ min: 0, max: 10 })).toSatisfy(satisfyInRange(0, 10));
10
- });
11
- });
@@ -1,8 +0,0 @@
1
- import { assertNumberRange } from './number-range';
2
- import type { NumberRange } from './number-range';
3
-
4
- export const clampNumber = (num: number, { min, max }: NumberRange) => {
5
- assertNumberRange({ min, max });
6
-
7
- return Math.min(Math.max(num, min), max);
8
- };
package/src/math/index.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './clamp-number';
2
- export * from './interpolate';
3
- export * from './number-range';
4
- export * from './random-number';
5
- export * from './median';
@@ -1,18 +0,0 @@
1
- import { isNumberInRange } from './number-range';
2
-
3
- export type RangeArray = [number, number];
4
-
5
- export const interpolate = (num: number, inputRange: RangeArray, outputRange: RangeArray) => {
6
- const [x1, x2] = inputRange;
7
- const [y1, y2] = outputRange;
8
-
9
- if (x1 > x2) {
10
- throw new Error('interpolate: inputRange[0] should not be superior to inputRange[1]');
11
- }
12
-
13
- if (!isNumberInRange(num, { min: x1, max: x2 })) {
14
- throw new Error(`interpolate: input number {${num}} is not in range of {${x1}}-{${x2}}`);
15
- }
16
-
17
- return y1 + ((num - x1) / (x2 - x1)) * (y2 - y1);
18
- };
@@ -1,21 +0,0 @@
1
- export function median(arr: number[]): number | null;
2
- export function median(arr: number[], defaultValueIfEmpty: number): number;
3
- export function median(arr: number[], defaultValueIfEmpty?: number) {
4
- if (arr.length === 0) {
5
- if (typeof defaultValueIfEmpty === 'number') {
6
- return defaultValueIfEmpty;
7
- }
8
- return null;
9
- }
10
-
11
- const sorted = [...arr].sort((a, b) => a - b);
12
- const mid = Math.floor(sorted.length / 2);
13
-
14
- // If the length of the array is odd, return the middle element
15
- if (sorted.length % 2 === 1) {
16
- return sorted[mid];
17
- }
18
-
19
- // If the length of the array is even, return the average of the middle two elements
20
- return (sorted[mid - 1] + sorted[mid]) / 2;
21
- }
@@ -1,16 +0,0 @@
1
- export type NumberRange = {
2
- min: number,
3
- max: number,
4
- };
5
-
6
- export const assertNumberRange = (range: NumberRange) => {
7
- if (range.min > range.max) {
8
- throw new Error('Invalid number range: min must be lower than or equal to max');
9
- }
10
- };
11
-
12
- export const isNumberInRange = (num: number, { min, max }: NumberRange) => {
13
- assertNumberRange({ min, max });
14
-
15
- return num >= min && num <= max;
16
- };
@@ -1,10 +0,0 @@
1
- import { assertNumberRange } from './number-range';
2
- import type { NumberRange } from './number-range';
3
-
4
- export const randomNumber = ({ min, max }: NumberRange) => {
5
- assertNumberRange({ min, max });
6
-
7
- return Math.floor(
8
- Math.random() * (max - min) + min,
9
- );
10
- };
@@ -1,56 +0,0 @@
1
- import { mergeDeep } from '../merge-deep';
2
-
3
- type A = {
4
- a: number,
5
- b: {
6
- c: {
7
- c1: string,
8
- c2: number,
9
- },
10
- },
11
- d:ReadonlyArray<number>,
12
- e: boolean,
13
- };
14
-
15
- describe('mergeDeep', () => {
16
- it('should return same object if no update', () => {
17
- const a: A = {
18
- a: 0, b: { c: { c1: 'yo', c2: 0 } }, d: [], e: false,
19
- };
20
- const b = {};
21
-
22
- expect(mergeDeep(a, b)).toBe(a);
23
- });
24
-
25
- it('should leave object unchanged if update does nothing', () => {
26
- const a: A = {
27
- a: 0, b: { c: { c1: 'yo', c2: 0 } }, d: [], e: false,
28
- };
29
- const b = { a: 0 };
30
-
31
- expect(mergeDeep(a, b)).toBe(a);
32
- });
33
-
34
- it('should do an update', () => {
35
- const a: A = {
36
- a: 0, b: { c: { c1: 'yo', c2: 0 } }, d: [], e: false,
37
- };
38
- const b = { a: 1, b: { c: { c1: 'hey' } }, d: [1, 2], e: true };
39
-
40
- expect(mergeDeep(a, b)).toStrictEqual({ a: 1, b: { c: { c1: 'hey', c2: 0 } }, d: [1, 2], e: true });
41
- });
42
-
43
- it('should overwrite arrays', () => {
44
- const a = { a: [1, 2] };
45
- const b = { a: [3, 4] };
46
-
47
- expect(mergeDeep(a, b)).toStrictEqual(b);
48
- });
49
-
50
- it('should not add new keys', () => {
51
- const a = { a: 0, c: 0 };
52
- const b: any = { a: 0, b: 0, c: 0 };
53
-
54
- expect(mergeDeep(a, b)).toBe(a);
55
- });
56
- });
@@ -1,65 +0,0 @@
1
- import { stripPropertiesFromObject } from '../strip-properties-from-object';
2
-
3
- describe('stripPropertiesFromObject', () => {
4
- const obj = {
5
- a: 1,
6
- b: {
7
- b1: 1,
8
- b2: 2,
9
- b3: 3,
10
- b4: {
11
- b41: 1,
12
- b42: 2,
13
- b43: 3,
14
- },
15
- },
16
- c: 3,
17
- };
18
-
19
- it('should remove the properties from the object', () => {
20
- const result = stripPropertiesFromObject(obj, ['c', 'b.b1', 'b.b4.b41']);
21
-
22
- expect(result).toMatchObject({
23
- a: 1,
24
- b: {
25
- b2: 2,
26
- b3: 3,
27
- b4: {
28
- b42: 2,
29
- b43: 3,
30
- },
31
- },
32
- });
33
-
34
- // Check if no mutation on the orignal object
35
- expect(obj).toEqual({
36
- a: 1,
37
- b: {
38
- b1: 1,
39
- b2: 2,
40
- b3: 3,
41
- b4: {
42
- b41: 1,
43
- b42: 2,
44
- b43: 3,
45
- },
46
- },
47
- c: 3,
48
- });
49
- });
50
-
51
- it('should ignore properties that do not exist', () => {
52
- const result = stripPropertiesFromObject(obj, ['d', 'a.b', 'b.b1.b11']);
53
- expect(result).toEqual(obj);
54
- });
55
-
56
- it('should not fail with empty array', () => {
57
- const result = stripPropertiesFromObject(obj, []);
58
- expect(result).toEqual(obj);
59
- });
60
-
61
- it('should handle empty property', () => {
62
- const result = stripPropertiesFromObject(obj, ['']);
63
- expect(result).toEqual(obj);
64
- });
65
- });
@@ -1,2 +0,0 @@
1
- export * from './merge-deep';
2
- export * from './strip-properties-from-object';
@@ -1,26 +0,0 @@
1
- import type { DeepPartial, ValueType } from '../types';
2
-
3
- // https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript/8511350#8511350
4
- const isObject = (a: any) => typeof a === 'object' && a !== null;
5
- const isValueType = (a: any): a is ValueType => !isObject(a) || Array.isArray(a);
6
-
7
- export const mergeDeep = <T>(a: T, b: DeepPartial<T>): T => {
8
- if (isValueType(a) || isValueType(b)) {
9
- return b as T;
10
- }
11
-
12
- return (Object.keys(b) as (keyof T)[]).reduce((acc, key) => {
13
- // @ts-ignore
14
- if (!(key in a)) {
15
- return acc;
16
- }
17
-
18
- if (b[key] === a[key]) {
19
- return acc;
20
- }
21
-
22
- const merged = mergeDeep(a[key], b[key] as DeepPartial<T[keyof T]>);
23
-
24
- return { ...acc, [key]: merged };
25
- }, a);
26
- };
@@ -1,26 +0,0 @@
1
- import structuredClone from '@ungap/structured-clone';
2
-
3
- export const stripPropertiesFromObject = <Output extends Record<any, any>, Input extends Record<any, any>>(
4
- obj: Input,
5
- properties: string[],
6
- ): Output => {
7
- const copy = structuredClone(obj);
8
-
9
- properties.forEach((nestedPropertyStr) => {
10
- const nestedProperties = nestedPropertyStr.split('.');
11
- const propertyToRemove = nestedProperties[nestedProperties.length - 1];
12
-
13
- const nestedObject =
14
- nestedProperties.length === 1
15
- ? copy
16
- : nestedProperties
17
- .slice(0, nestedProperties.length - 1)
18
- .reduce((acc, property) => acc[property], copy);
19
-
20
- if (nestedObject) {
21
- delete nestedObject[propertyToRemove];
22
- }
23
- });
24
-
25
- return copy;
26
- };
@@ -1,15 +0,0 @@
1
- import { parseBoolean } from '../parse-boolean';
2
-
3
- describe('parseBoolean', () => {
4
- it('should return true if value is "true"', () => {
5
- expect(parseBoolean('true')).toStrictEqual(true);
6
- });
7
-
8
- it('should return false if value is "false"', () => {
9
- expect(parseBoolean('false')).toStrictEqual(false);
10
- });
11
-
12
- it('should throw an exception if value is neither "true" nor "false"', () => {
13
- expect(() => parseBoolean('value')).toThrow();
14
- });
15
- });
@@ -1,19 +0,0 @@
1
- import { createEnumParser } from '../parse-enum';
2
-
3
- enum TestEnum {
4
- FirstValue = 'first',
5
- SecondValue = 'second',
6
- ThirdValue = 'third',
7
- }
8
-
9
- describe('createEnumParser', () => {
10
- const parseTestEnum = createEnumParser(TestEnum);
11
-
12
- it('should return a valid enum parser', () => {
13
- expect(parseTestEnum('second')).toStrictEqual(TestEnum.SecondValue);
14
- });
15
-
16
- it('should throw an error if the parsing did not work', () => {
17
- expect(() => parseTestEnum('fourth')).toThrowError();
18
- });
19
- });
@@ -1,20 +0,0 @@
1
- import { parseNumber } from '../parse-number';
2
-
3
- describe('parseNumber', () => {
4
- it('should return number 10 if value is "10', () => {
5
- expect(parseNumber('10')).toStrictEqual(10);
6
- });
7
-
8
- it('should return -10 if value is "-10"', () => {
9
- expect(parseNumber('-10')).toStrictEqual(-10);
10
- });
11
-
12
- it('should return 0 if value is "0"', () => {
13
- expect(parseNumber('0')).toStrictEqual(0);
14
- });
15
-
16
- it('should throw an exception if value is not a number', () => {
17
- expect(() => parseNumber('number')).toThrow();
18
- expect(() => parseNumber('false')).toThrow();
19
- });
20
- });
@@ -1,3 +0,0 @@
1
- export * from './parse-boolean';
2
- export * from './parse-enum';
3
- export * from './parse-number';
@@ -1,10 +0,0 @@
1
- /**
2
- * Parse a string to a boolean. Throw error if string is neither "true" nor "false"
3
- */
4
- export const parseBoolean = (value: string): boolean => {
5
- if (value !== 'true' && value !== 'false') {
6
- throw new Error('Cannot parse value');
7
- }
8
-
9
- return value === 'true';
10
- };
@@ -1,16 +0,0 @@
1
- import type { Primitive } from '../types';
2
-
3
- /**
4
- * Factory to build enum to parse a string to an enum. Throw error if string is not an enum value
5
- */
6
- export const createEnumParser = <E extends Record<string, Primitive>>(enumType: E) => (
7
- (value: string) => {
8
- const enumValues = Object.values(enumType);
9
-
10
- if (!enumValues.includes(value as any)) {
11
- throw new Error('Can\'t parse this value');
12
- }
13
-
14
- return value as unknown as E;
15
- }
16
- );
@@ -1,12 +0,0 @@
1
- /**
2
- * Parse a string to a number. Throw error if string is NaN
3
- */
4
- export const parseNumber = (value: string): number => {
5
- const number = parseInt(value, 10);
6
-
7
- if (Number.isNaN(number)) {
8
- throw new Error('Cannot parse value');
9
- }
10
-
11
- return number;
12
- };
@@ -1,11 +0,0 @@
1
- import { isFunction } from '../is-function';
2
-
3
- describe('isFunction', () => {
4
- it('should return true if value is a function', () => {
5
- expect(isFunction(() => {})).toBeTrue();
6
- });
7
-
8
- it('should return false if value is not a function', () => {
9
- expect(isFunction('')).toBeFalse();
10
- });
11
- });
@@ -1,11 +0,0 @@
1
- import { isNull } from '../is-null';
2
-
3
- describe('isNull', () => {
4
- it('should return true if value is null', () => {
5
- expect(isNull(null)).toBeTrue();
6
- });
7
-
8
- it('should return false if value is not null', () => {
9
- expect(isNull('')).toBeFalse();
10
- });
11
- });
@@ -1,11 +0,0 @@
1
- import { isObject } from '../is-object';
2
-
3
- describe('isObject', () => {
4
- it('should return true if value is an object', () => {
5
- expect(isObject({})).toBeTrue();
6
- });
7
-
8
- it('should return false if value is not an object', () => {
9
- expect(isObject('')).toBeFalse();
10
- });
11
- });
@@ -1,42 +0,0 @@
1
- import { isPrimitive, isArrayOfPrimitive } from '../is-primitive';
2
-
3
- describe('isPrimitive', () => {
4
- it('should return true if value is a primitive', () => {
5
- expect(isPrimitive('a value')).toBeTrue();
6
- expect(isPrimitive(6)).toBeTrue();
7
- expect(isPrimitive(true)).toBeTrue();
8
- });
9
-
10
- it('should return false if value is not a primitive', () => {
11
- expect(isPrimitive({})).toBeFalse();
12
- expect(isPrimitive(new Date())).toBeFalse();
13
- expect(isPrimitive([])).toBeFalse();
14
- });
15
- });
16
-
17
- describe('isArrayOfPrimitive', () => {
18
- it('should return false if value not an array', () => {
19
- expect(isArrayOfPrimitive({})).toBeFalse();
20
- expect(isArrayOfPrimitive(1)).toBeFalse();
21
- });
22
-
23
- it('should return false if not every value in the array is primitive', () => {
24
- expect(isArrayOfPrimitive([
25
- 1,
26
- 'test',
27
- true,
28
- false,
29
- [],
30
- {},
31
- ])).toBeFalse();
32
- });
33
-
34
- it('should return true if every value in the array is a primitive', () => {
35
- expect(isArrayOfPrimitive([
36
- 1,
37
- 'test',
38
- true,
39
- false,
40
- ])).toBeTrue();
41
- });
42
- });
@@ -1,11 +0,0 @@
1
- import { isUndefined } from '../is-undefined';
2
-
3
- describe('isUndefined', () => {
4
- it('should return true if value is undefined', () => {
5
- expect(isUndefined(undefined)).toBeTrue();
6
- });
7
-
8
- it('should return false if value is not undefined', () => {
9
- expect(isUndefined('')).toBeFalse();
10
- });
11
- });
@@ -1,13 +0,0 @@
1
- import { isUuidV4 } from '../is-uuid';
2
-
3
- describe('isUuidV4', () => {
4
- it('returns true if the string is uuid v4', () => {
5
- expect(isUuidV4('dd819894-70f3-4629-8712-430445f93c5d')).toBeTrue();
6
- });
7
- it('returns false if argument is not a string', () => {
8
- expect(isUuidV4(4)).toBeFalse();
9
- });
10
- it('returns false if argument is uuid V1', () => {
11
- expect(isUuidV4('4dfde9e2-3988-11ed-a261-0242ac120002')).toBeFalse();
12
- });
13
- });
@@ -1,5 +0,0 @@
1
- export * from './is-function';
2
- export * from './is-null';
3
- export * from './is-object';
4
- export * from './is-primitive';
5
- export * from './is-undefined';
@@ -1,3 +0,0 @@
1
- export const isFunction = (value: any): value is Function => (
2
- typeof value === 'function'
3
- );
@@ -1 +0,0 @@
1
- export const isNull = (value: any): value is null => value === null;
@@ -1,3 +0,0 @@
1
- export const isObject = (value: any): value is Object => (
2
- typeof value === 'object'
3
- );
@@ -1,19 +0,0 @@
1
- import { Primitive } from '../types/general';
2
-
3
- const PRIMITIVE_TYPES = [
4
- 'string',
5
- 'boolean',
6
- 'number',
7
- ];
8
-
9
- export const isPrimitive = (value: any): value is Primitive => (
10
- PRIMITIVE_TYPES.includes(typeof value)
11
- );
12
-
13
- export const isArrayOfPrimitive = (value: any): value is Array<Primitive> => {
14
- if (!Array.isArray(value)) {
15
- return false;
16
- }
17
-
18
- return value.every((arrayValue) => isPrimitive(arrayValue));
19
- };
@@ -1,3 +0,0 @@
1
- export const isUndefined = (value: any): value is undefined => (
2
- value === undefined
3
- );
@@ -1,3 +0,0 @@
1
- const UUID_REGEX = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
2
-
3
- export const isUuidV4 = (arg: any): arg is string => UUID_REGEX.test(arg);
@@ -1,13 +0,0 @@
1
- import { delay } from '../delay';
2
-
3
- jest.useFakeTimers();
4
- jest.spyOn(global, 'setTimeout');
5
-
6
- describe('delay.ts', () => {
7
- it('waits ', () => {
8
- delay(500);
9
-
10
- expect(setTimeout).toHaveBeenCalledOnce();
11
- expect(setTimeout).toHaveBeenCalledWith(expect.any(Function), 500);
12
- });
13
- });
@@ -1,25 +0,0 @@
1
- import { executeOrResolveDefault } from '../execute-or-resolve-default';
2
-
3
- describe('executeOrResolveDefault', () => {
4
- it('should execute the function', async () => {
5
- const cb = jest.fn().mockResolvedValue(8);
6
- const res = await executeOrResolveDefault(cb, {
7
- execute: true,
8
- defaultValue: undefined,
9
- });
10
-
11
- expect(res).toStrictEqual(8);
12
- expect(cb).toHaveBeenCalledTimes(1);
13
- });
14
-
15
- it('should not execute the function', async () => {
16
- const cb = jest.fn().mockResolvedValue(8);
17
- const res = await executeOrResolveDefault(cb, {
18
- execute: false,
19
- defaultValue: 'sup m8',
20
- });
21
-
22
- expect(res).toStrictEqual('sup m8');
23
- expect(cb).toHaveBeenCalledTimes(0);
24
- });
25
- });
@@ -1,24 +0,0 @@
1
- import { executeWithDelay } from '../execute-with-delay';
2
-
3
- describe('executeWithDelay', () => {
4
- beforeAll(() => {
5
- jest.useFakeTimers();
6
- });
7
-
8
- afterAll(() => {
9
- jest.useRealTimers();
10
- });
11
-
12
- it('should execute the promise with a delay', async () => {
13
- const setTimeoutSpy = jest.spyOn(global, 'setTimeout');
14
- const res = executeWithDelay(() => Promise.resolve(1), 500);
15
-
16
- expect(setTimeoutSpy).toHaveBeenCalledWith(expect.toBeFunction(), 500);
17
-
18
- jest.advanceTimersByTime(501);
19
-
20
- expect(await res).toStrictEqual(1);
21
-
22
- setTimeoutSpy.mockRestore();
23
- });
24
- });