@sparted/shared-library 1.2.0 → 1.2.2

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 (374) hide show
  1. package/business/picture-spot/index.d.ts +37 -0
  2. package/business/types/campaign.d.ts +12 -0
  3. package/{dist/business → business}/types/content.d.ts +7 -8
  4. package/business/types/content.js.map +1 -0
  5. package/{src/business/types/index.ts → business/types/index.d.ts} +5 -5
  6. package/package.json +1 -1
  7. package/.circleci/config.yml +0 -40
  8. package/.eslintignore +0 -1
  9. package/.eslintrc.json +0 -25
  10. package/.gitignore +0 -37
  11. package/.idea/.gitignore +0 -8
  12. package/.idea/codeStyles/Project.xml +0 -35
  13. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  14. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  15. package/.idea/jsLinters/eslint.xml +0 -6
  16. package/.idea/misc.xml +0 -6
  17. package/.idea/modules.xml +0 -8
  18. package/.idea/shared-library.iml +0 -11
  19. package/.idea/vcs.xml +0 -6
  20. package/.idea/workspace.xml +0 -108
  21. package/.prettierrc.json +0 -6
  22. package/CHANGELOG.md +0 -130
  23. package/README.md +0 -26
  24. package/dist/business/picture-spot/index.d.ts +0 -2
  25. package/dist/business/types/content.js.map +0 -1
  26. package/dist/business/types/index.d.ts +0 -4
  27. package/dist/package.json +0 -66
  28. package/global.d.ts +0 -2
  29. package/rollup.config.ts +0 -19
  30. package/src/array/__tests__/array-to-map.test.ts +0 -50
  31. package/src/array/__tests__/get-values-from-keys.test.ts +0 -14
  32. package/src/array/__tests__/inner-join.test.ts +0 -55
  33. package/src/array/__tests__/left-outter-join.test.ts +0 -55
  34. package/src/array/array-to-map.ts +0 -32
  35. package/src/array/get-values-from-keys.ts +0 -3
  36. package/src/array/index.ts +0 -4
  37. package/src/array/inner-join.ts +0 -10
  38. package/src/array/left-outter-join.ts +0 -10
  39. package/src/business/picture-spot/index.ts +0 -3
  40. package/src/business/types/campaign.ts +0 -14
  41. package/src/business/types/content.ts +0 -155
  42. package/src/business/types/media.ts +0 -18
  43. package/src/business/types/multilingual.ts +0 -46
  44. package/src/business/types/thematic.ts +0 -10
  45. package/src/cdn/__tests__/cdn.factory.test.ts +0 -150
  46. package/src/cdn/__tests__/utils.test.ts +0 -528
  47. package/src/cdn/cdn.factory.ts +0 -70
  48. package/src/cdn/index.ts +0 -2
  49. package/src/cdn/types/cdn-factory.type.ts +0 -49
  50. package/src/cdn/types/index.ts +0 -1
  51. package/src/cdn/utils/extract-info-from-url.util.ts +0 -25
  52. package/src/cdn/utils/get-cdn-from-s3-url.util.ts +0 -20
  53. package/src/cdn/utils/get-cdn-url.util.ts +0 -31
  54. package/src/cdn/utils/twicpics-transformations.util.ts +0 -9
  55. package/src/color/__tests__/get-contrast-color.test.ts +0 -22
  56. package/src/color/get-contrast-color.ts +0 -18
  57. package/src/color/index.ts +0 -1
  58. package/src/formatting/__tests__/format-number.test.ts +0 -11
  59. package/src/formatting/format-number.ts +0 -14
  60. package/src/formatting/index.ts +0 -1
  61. package/src/fp/__tests__/run-while.test.ts +0 -29
  62. package/src/fp/index.ts +0 -1
  63. package/src/fp/run-while.ts +0 -54
  64. package/src/http/__tests__/build-search-params.test.ts +0 -17
  65. package/src/http/__tests__/encode-search-object.test.ts +0 -34
  66. package/src/http/__tests__/fetch-with-timeout.test.ts +0 -50
  67. package/src/http/build-search-params.ts +0 -18
  68. package/src/http/encode-search-object.ts +0 -39
  69. package/src/http/fetch-with-timeout.ts +0 -24
  70. package/src/http/index.ts +0 -3
  71. package/src/index.ts +0 -15
  72. package/src/linked-list/__tests__/apply-diff-linked-list.test.ts +0 -103
  73. package/src/linked-list/__tests__/create-linked-list.test.ts +0 -204
  74. package/src/linked-list/__tests__/find-linked-list.test.ts +0 -40
  75. package/src/linked-list/__tests__/get-linked-list.test.ts +0 -28
  76. package/src/linked-list/__tests__/insert-linked-list.test.ts +0 -186
  77. package/src/linked-list/__tests__/linked-list-utils.test.ts +0 -252
  78. package/src/linked-list/__tests__/reduce-linked-list.test.ts +0 -31
  79. package/src/linked-list/__tests__/remove-linked-list.test.ts +0 -129
  80. package/src/linked-list/__tests__/update-linked-list.test.ts +0 -53
  81. package/src/linked-list/__tests__/while-linked-list.test.ts +0 -58
  82. package/src/linked-list/apply-diff-linked-list.ts +0 -35
  83. package/src/linked-list/create-linked-list.ts +0 -79
  84. package/src/linked-list/find-linked-list.ts +0 -26
  85. package/src/linked-list/get-linked-list.ts +0 -9
  86. package/src/linked-list/index.ts +0 -2
  87. package/src/linked-list/insert-linked-list.ts +0 -50
  88. package/src/linked-list/linked-list-utils.ts +0 -143
  89. package/src/linked-list/reduce-linked-list.ts +0 -18
  90. package/src/linked-list/remove-linked-list.ts +0 -36
  91. package/src/linked-list/type.ts +0 -38
  92. package/src/linked-list/update-linked-list.ts +0 -30
  93. package/src/linked-list/while-linked-list.ts +0 -33
  94. package/src/math/__tests__/clamp-number.test.ts +0 -30
  95. package/src/math/__tests__/interpolate.test.ts +0 -28
  96. package/src/math/__tests__/median.test.ts +0 -27
  97. package/src/math/__tests__/number-range.test.ts +0 -59
  98. package/src/math/__tests__/random-number.test.ts +0 -11
  99. package/src/math/clamp-number.ts +0 -8
  100. package/src/math/index.ts +0 -5
  101. package/src/math/interpolate.ts +0 -18
  102. package/src/math/median.ts +0 -21
  103. package/src/math/number-range.ts +0 -16
  104. package/src/math/random-number.ts +0 -10
  105. package/src/object/__tests__/merge-deep.test.ts +0 -56
  106. package/src/object/__tests__/strip-properties-from-object.test.ts +0 -65
  107. package/src/object/index.ts +0 -2
  108. package/src/object/merge-deep.ts +0 -26
  109. package/src/object/strip-properties-from-object.ts +0 -26
  110. package/src/parsing/__tests__/parse-boolean.test.ts +0 -15
  111. package/src/parsing/__tests__/parse-enum.test.ts +0 -19
  112. package/src/parsing/__tests__/parse-number.test.ts +0 -20
  113. package/src/parsing/index.ts +0 -3
  114. package/src/parsing/parse-boolean.ts +0 -10
  115. package/src/parsing/parse-enum.ts +0 -16
  116. package/src/parsing/parse-number.ts +0 -12
  117. package/src/predicates/__tests__/is-function.test.ts +0 -11
  118. package/src/predicates/__tests__/is-null.test.ts +0 -11
  119. package/src/predicates/__tests__/is-object.test.ts +0 -11
  120. package/src/predicates/__tests__/is-primitive.test.ts +0 -42
  121. package/src/predicates/__tests__/is-undefined.test.ts +0 -11
  122. package/src/predicates/__tests__/is-uuid.test.ts +0 -13
  123. package/src/predicates/index.ts +0 -5
  124. package/src/predicates/is-function.ts +0 -3
  125. package/src/predicates/is-null.ts +0 -1
  126. package/src/predicates/is-object.ts +0 -3
  127. package/src/predicates/is-primitive.ts +0 -19
  128. package/src/predicates/is-undefined.ts +0 -3
  129. package/src/predicates/is-uuid.ts +0 -3
  130. package/src/promise/__tests__/delay.test.ts +0 -13
  131. package/src/promise/__tests__/execute-or-resolve-default.test.ts +0 -25
  132. package/src/promise/__tests__/execute-with-delay.test.ts +0 -24
  133. package/src/promise/delay.ts +0 -3
  134. package/src/promise/execute-or-resolve-default.ts +0 -14
  135. package/src/promise/execute-with-delay.ts +0 -6
  136. package/src/promise/index.ts +0 -3
  137. package/src/string/__tests__/is-string-length-within-range.test.ts +0 -23
  138. package/src/string/__tests__/replace-in-template.test.ts +0 -52
  139. package/src/string/index.ts +0 -2
  140. package/src/string/is-string-length-within-range.ts +0 -10
  141. package/src/string/replace-in-template.ts +0 -45
  142. package/src/time/__tests__/convert.test.ts +0 -14
  143. package/src/time/__tests__/format-minutes.test.ts +0 -10
  144. package/src/time/__tests__/get-time-diff-as-string.test.ts +0 -128
  145. package/src/time/constants.ts +0 -4
  146. package/src/time/convert.ts +0 -5
  147. package/src/time/format-minutes.ts +0 -9
  148. package/src/time/get-time-diff-as-string.ts +0 -196
  149. package/src/time/index.ts +0 -4
  150. package/src/types/function.ts +0 -1
  151. package/src/types/general.ts +0 -15
  152. package/src/types/index.ts +0 -4
  153. package/src/types/object.ts +0 -33
  154. package/src/types/search.ts +0 -29
  155. package/tsconfig.json +0 -25
  156. package/yarn-error.log +0 -4133
  157. package/yarn.lock +0 -4045
  158. /package/{dist/_virtual → _virtual}/_tslib.js +0 -0
  159. /package/{dist/_virtual → _virtual}/_tslib.js.map +0 -0
  160. /package/{dist/array → array}/array-to-map.d.ts +0 -0
  161. /package/{dist/array → array}/array-to-map.js +0 -0
  162. /package/{dist/array → array}/array-to-map.js.map +0 -0
  163. /package/{dist/array → array}/get-values-from-keys.d.ts +0 -0
  164. /package/{dist/array → array}/get-values-from-keys.js +0 -0
  165. /package/{dist/array → array}/get-values-from-keys.js.map +0 -0
  166. /package/{dist/array → array}/index.d.ts +0 -0
  167. /package/{dist/array → array}/index.js +0 -0
  168. /package/{dist/array → array}/index.js.map +0 -0
  169. /package/{dist/array → array}/inner-join.d.ts +0 -0
  170. /package/{dist/array → array}/inner-join.js +0 -0
  171. /package/{dist/array → array}/inner-join.js.map +0 -0
  172. /package/{dist/array → array}/left-outter-join.d.ts +0 -0
  173. /package/{dist/array → array}/left-outter-join.js +0 -0
  174. /package/{dist/array → array}/left-outter-join.js.map +0 -0
  175. /package/{dist/business → business}/picture-spot/index.js +0 -0
  176. /package/{dist/business → business}/picture-spot/index.js.map +0 -0
  177. /package/{dist/business → business}/types/content.js +0 -0
  178. /package/{dist/business → business}/types/index.js +0 -0
  179. /package/{dist/business → business}/types/index.js.map +0 -0
  180. /package/{dist/business → business}/types/media.d.ts +0 -0
  181. /package/{dist/business → business}/types/multilingual.d.ts +0 -0
  182. /package/{dist/business → business}/types/multilingual.js +0 -0
  183. /package/{dist/business → business}/types/multilingual.js.map +0 -0
  184. /package/{dist/business → business}/types/thematic.d.ts +0 -0
  185. /package/{dist/cdn → cdn}/cdn.factory.d.ts +0 -0
  186. /package/{dist/cdn → cdn}/cdn.factory.js +0 -0
  187. /package/{dist/cdn → cdn}/cdn.factory.js.map +0 -0
  188. /package/{dist/cdn → cdn}/index.d.ts +0 -0
  189. /package/{dist/cdn → cdn}/index.js +0 -0
  190. /package/{dist/cdn → cdn}/index.js.map +0 -0
  191. /package/{dist/cdn → cdn}/types/cdn-factory.type.d.ts +0 -0
  192. /package/{dist/cdn → cdn}/types/index.d.ts +0 -0
  193. /package/{dist/cdn → cdn}/types/index.js +0 -0
  194. /package/{dist/cdn → cdn}/types/index.js.map +0 -0
  195. /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.d.ts +0 -0
  196. /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.js +0 -0
  197. /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.js.map +0 -0
  198. /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.d.ts +0 -0
  199. /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.js +0 -0
  200. /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.js.map +0 -0
  201. /package/{dist/cdn → cdn}/utils/get-cdn-url.util.d.ts +0 -0
  202. /package/{dist/cdn → cdn}/utils/get-cdn-url.util.js +0 -0
  203. /package/{dist/cdn → cdn}/utils/get-cdn-url.util.js.map +0 -0
  204. /package/{dist/cdn → cdn}/utils/twicpics-transformations.util.d.ts +0 -0
  205. /package/{dist/cdn → cdn}/utils/twicpics-transformations.util.js +0 -0
  206. /package/{dist/cdn → cdn}/utils/twicpics-transformations.util.js.map +0 -0
  207. /package/{dist/color → color}/get-contrast-color.d.ts +0 -0
  208. /package/{dist/color → color}/get-contrast-color.js +0 -0
  209. /package/{dist/color → color}/get-contrast-color.js.map +0 -0
  210. /package/{dist/color → color}/index.d.ts +0 -0
  211. /package/{dist/color → color}/index.js +0 -0
  212. /package/{dist/color → color}/index.js.map +0 -0
  213. /package/{dist/formatting → formatting}/format-number.d.ts +0 -0
  214. /package/{dist/formatting → formatting}/format-number.js +0 -0
  215. /package/{dist/formatting → formatting}/format-number.js.map +0 -0
  216. /package/{dist/formatting → formatting}/index.d.ts +0 -0
  217. /package/{dist/formatting → formatting}/index.js +0 -0
  218. /package/{dist/formatting → formatting}/index.js.map +0 -0
  219. /package/{dist/fp → fp}/index.d.ts +0 -0
  220. /package/{dist/fp → fp}/index.js +0 -0
  221. /package/{dist/fp → fp}/index.js.map +0 -0
  222. /package/{dist/fp → fp}/run-while.d.ts +0 -0
  223. /package/{dist/fp → fp}/run-while.js +0 -0
  224. /package/{dist/fp → fp}/run-while.js.map +0 -0
  225. /package/{dist/http → http}/build-search-params.d.ts +0 -0
  226. /package/{dist/http → http}/build-search-params.js +0 -0
  227. /package/{dist/http → http}/build-search-params.js.map +0 -0
  228. /package/{dist/http → http}/encode-search-object.d.ts +0 -0
  229. /package/{dist/http → http}/encode-search-object.js +0 -0
  230. /package/{dist/http → http}/encode-search-object.js.map +0 -0
  231. /package/{dist/http → http}/fetch-with-timeout.d.ts +0 -0
  232. /package/{dist/http → http}/fetch-with-timeout.js +0 -0
  233. /package/{dist/http → http}/fetch-with-timeout.js.map +0 -0
  234. /package/{dist/http → http}/index.d.ts +0 -0
  235. /package/{dist/http → http}/index.js +0 -0
  236. /package/{dist/http → http}/index.js.map +0 -0
  237. /package/{dist/index.d.ts → index.d.ts} +0 -0
  238. /package/{dist/index.js → index.js} +0 -0
  239. /package/{dist/index.js.map → index.js.map} +0 -0
  240. /package/{dist/linked-list → linked-list}/apply-diff-linked-list.d.ts +0 -0
  241. /package/{dist/linked-list → linked-list}/apply-diff-linked-list.js +0 -0
  242. /package/{dist/linked-list → linked-list}/apply-diff-linked-list.js.map +0 -0
  243. /package/{dist/linked-list → linked-list}/create-linked-list.d.ts +0 -0
  244. /package/{dist/linked-list → linked-list}/create-linked-list.js +0 -0
  245. /package/{dist/linked-list → linked-list}/create-linked-list.js.map +0 -0
  246. /package/{dist/linked-list → linked-list}/find-linked-list.d.ts +0 -0
  247. /package/{dist/linked-list → linked-list}/find-linked-list.js +0 -0
  248. /package/{dist/linked-list → linked-list}/find-linked-list.js.map +0 -0
  249. /package/{dist/linked-list → linked-list}/get-linked-list.d.ts +0 -0
  250. /package/{dist/linked-list → linked-list}/get-linked-list.js +0 -0
  251. /package/{dist/linked-list → linked-list}/get-linked-list.js.map +0 -0
  252. /package/{dist/linked-list → linked-list}/index.d.ts +0 -0
  253. /package/{dist/linked-list → linked-list}/index.js +0 -0
  254. /package/{dist/linked-list → linked-list}/index.js.map +0 -0
  255. /package/{dist/linked-list → linked-list}/insert-linked-list.d.ts +0 -0
  256. /package/{dist/linked-list → linked-list}/insert-linked-list.js +0 -0
  257. /package/{dist/linked-list → linked-list}/insert-linked-list.js.map +0 -0
  258. /package/{dist/linked-list → linked-list}/linked-list-utils.d.ts +0 -0
  259. /package/{dist/linked-list → linked-list}/linked-list-utils.js +0 -0
  260. /package/{dist/linked-list → linked-list}/linked-list-utils.js.map +0 -0
  261. /package/{dist/linked-list → linked-list}/reduce-linked-list.d.ts +0 -0
  262. /package/{dist/linked-list → linked-list}/reduce-linked-list.js +0 -0
  263. /package/{dist/linked-list → linked-list}/reduce-linked-list.js.map +0 -0
  264. /package/{dist/linked-list → linked-list}/remove-linked-list.d.ts +0 -0
  265. /package/{dist/linked-list → linked-list}/remove-linked-list.js +0 -0
  266. /package/{dist/linked-list → linked-list}/remove-linked-list.js.map +0 -0
  267. /package/{dist/linked-list → linked-list}/type.d.ts +0 -0
  268. /package/{dist/linked-list → linked-list}/update-linked-list.d.ts +0 -0
  269. /package/{dist/linked-list → linked-list}/update-linked-list.js +0 -0
  270. /package/{dist/linked-list → linked-list}/update-linked-list.js.map +0 -0
  271. /package/{dist/linked-list → linked-list}/while-linked-list.d.ts +0 -0
  272. /package/{dist/linked-list → linked-list}/while-linked-list.js +0 -0
  273. /package/{dist/linked-list → linked-list}/while-linked-list.js.map +0 -0
  274. /package/{dist/math → math}/clamp-number.d.ts +0 -0
  275. /package/{dist/math → math}/clamp-number.js +0 -0
  276. /package/{dist/math → math}/clamp-number.js.map +0 -0
  277. /package/{dist/math → math}/index.d.ts +0 -0
  278. /package/{dist/math → math}/index.js +0 -0
  279. /package/{dist/math → math}/index.js.map +0 -0
  280. /package/{dist/math → math}/interpolate.d.ts +0 -0
  281. /package/{dist/math → math}/interpolate.js +0 -0
  282. /package/{dist/math → math}/interpolate.js.map +0 -0
  283. /package/{dist/math → math}/median.d.ts +0 -0
  284. /package/{dist/math → math}/median.js +0 -0
  285. /package/{dist/math → math}/median.js.map +0 -0
  286. /package/{dist/math → math}/number-range.d.ts +0 -0
  287. /package/{dist/math → math}/number-range.js +0 -0
  288. /package/{dist/math → math}/number-range.js.map +0 -0
  289. /package/{dist/math → math}/random-number.d.ts +0 -0
  290. /package/{dist/math → math}/random-number.js +0 -0
  291. /package/{dist/math → math}/random-number.js.map +0 -0
  292. /package/{dist/object → object}/index.d.ts +0 -0
  293. /package/{dist/object → object}/index.js +0 -0
  294. /package/{dist/object → object}/index.js.map +0 -0
  295. /package/{dist/object → object}/merge-deep.d.ts +0 -0
  296. /package/{dist/object → object}/merge-deep.js +0 -0
  297. /package/{dist/object → object}/merge-deep.js.map +0 -0
  298. /package/{dist/object → object}/strip-properties-from-object.d.ts +0 -0
  299. /package/{dist/object → object}/strip-properties-from-object.js +0 -0
  300. /package/{dist/object → object}/strip-properties-from-object.js.map +0 -0
  301. /package/{dist/parsing → parsing}/index.d.ts +0 -0
  302. /package/{dist/parsing → parsing}/index.js +0 -0
  303. /package/{dist/parsing → parsing}/index.js.map +0 -0
  304. /package/{dist/parsing → parsing}/parse-boolean.d.ts +0 -0
  305. /package/{dist/parsing → parsing}/parse-boolean.js +0 -0
  306. /package/{dist/parsing → parsing}/parse-boolean.js.map +0 -0
  307. /package/{dist/parsing → parsing}/parse-enum.d.ts +0 -0
  308. /package/{dist/parsing → parsing}/parse-enum.js +0 -0
  309. /package/{dist/parsing → parsing}/parse-enum.js.map +0 -0
  310. /package/{dist/parsing → parsing}/parse-number.d.ts +0 -0
  311. /package/{dist/parsing → parsing}/parse-number.js +0 -0
  312. /package/{dist/parsing → parsing}/parse-number.js.map +0 -0
  313. /package/{dist/predicates → predicates}/index.d.ts +0 -0
  314. /package/{dist/predicates → predicates}/index.js +0 -0
  315. /package/{dist/predicates → predicates}/index.js.map +0 -0
  316. /package/{dist/predicates → predicates}/is-function.d.ts +0 -0
  317. /package/{dist/predicates → predicates}/is-function.js +0 -0
  318. /package/{dist/predicates → predicates}/is-function.js.map +0 -0
  319. /package/{dist/predicates → predicates}/is-null.d.ts +0 -0
  320. /package/{dist/predicates → predicates}/is-null.js +0 -0
  321. /package/{dist/predicates → predicates}/is-null.js.map +0 -0
  322. /package/{dist/predicates → predicates}/is-object.d.ts +0 -0
  323. /package/{dist/predicates → predicates}/is-object.js +0 -0
  324. /package/{dist/predicates → predicates}/is-object.js.map +0 -0
  325. /package/{dist/predicates → predicates}/is-primitive.d.ts +0 -0
  326. /package/{dist/predicates → predicates}/is-primitive.js +0 -0
  327. /package/{dist/predicates → predicates}/is-primitive.js.map +0 -0
  328. /package/{dist/predicates → predicates}/is-undefined.d.ts +0 -0
  329. /package/{dist/predicates → predicates}/is-undefined.js +0 -0
  330. /package/{dist/predicates → predicates}/is-undefined.js.map +0 -0
  331. /package/{dist/predicates → predicates}/is-uuid.d.ts +0 -0
  332. /package/{dist/promise → promise}/delay.d.ts +0 -0
  333. /package/{dist/promise → promise}/delay.js +0 -0
  334. /package/{dist/promise → promise}/delay.js.map +0 -0
  335. /package/{dist/promise → promise}/execute-or-resolve-default.d.ts +0 -0
  336. /package/{dist/promise → promise}/execute-or-resolve-default.js +0 -0
  337. /package/{dist/promise → promise}/execute-or-resolve-default.js.map +0 -0
  338. /package/{dist/promise → promise}/execute-with-delay.d.ts +0 -0
  339. /package/{dist/promise → promise}/execute-with-delay.js +0 -0
  340. /package/{dist/promise → promise}/execute-with-delay.js.map +0 -0
  341. /package/{dist/promise → promise}/index.d.ts +0 -0
  342. /package/{dist/promise → promise}/index.js +0 -0
  343. /package/{dist/promise → promise}/index.js.map +0 -0
  344. /package/{dist/string → string}/index.d.ts +0 -0
  345. /package/{dist/string → string}/index.js +0 -0
  346. /package/{dist/string → string}/index.js.map +0 -0
  347. /package/{dist/string → string}/is-string-length-within-range.d.ts +0 -0
  348. /package/{dist/string → string}/is-string-length-within-range.js +0 -0
  349. /package/{dist/string → string}/is-string-length-within-range.js.map +0 -0
  350. /package/{dist/string → string}/replace-in-template.d.ts +0 -0
  351. /package/{dist/string → string}/replace-in-template.js +0 -0
  352. /package/{dist/string → string}/replace-in-template.js.map +0 -0
  353. /package/{dist/time → time}/constants.d.ts +0 -0
  354. /package/{dist/time → time}/constants.js +0 -0
  355. /package/{dist/time → time}/constants.js.map +0 -0
  356. /package/{dist/time → time}/convert.d.ts +0 -0
  357. /package/{dist/time → time}/convert.js +0 -0
  358. /package/{dist/time → time}/convert.js.map +0 -0
  359. /package/{dist/time → time}/format-minutes.d.ts +0 -0
  360. /package/{dist/time → time}/format-minutes.js +0 -0
  361. /package/{dist/time → time}/format-minutes.js.map +0 -0
  362. /package/{dist/time → time}/get-time-diff-as-string.d.ts +0 -0
  363. /package/{dist/time → time}/get-time-diff-as-string.js +0 -0
  364. /package/{dist/time → time}/get-time-diff-as-string.js.map +0 -0
  365. /package/{dist/time → time}/index.d.ts +0 -0
  366. /package/{dist/time → time}/index.js +0 -0
  367. /package/{dist/time → time}/index.js.map +0 -0
  368. /package/{dist/types → types}/function.d.ts +0 -0
  369. /package/{dist/types → types}/general.d.ts +0 -0
  370. /package/{dist/types → types}/index.d.ts +0 -0
  371. /package/{dist/types → types}/index.js +0 -0
  372. /package/{dist/types → types}/index.js.map +0 -0
  373. /package/{dist/types → types}/object.d.ts +0 -0
  374. /package/{dist/types → types}/search.d.ts +0 -0
@@ -1,50 +0,0 @@
1
- import { ManipulationConfig, LinkedListItem } from './type';
2
-
3
- import {
4
- findPreviousId,
5
- assertItemCompatibility,
6
- assertPresence,
7
- assertNewNodePosition,
8
- } from './linked-list-utils';
9
-
10
- export const insertLinkedList = <T extends LinkedListItem>(item: T, config: ManipulationConfig<T>) => {
11
- const { format, list, factory } = config;
12
-
13
- assertItemCompatibility(item, format);
14
- assertPresence(item.nextId, list.items);
15
- assertPresence(item.previousId, list.items);
16
-
17
- const hasPrevious = item.previousId !== undefined;
18
-
19
- const previousId = hasPrevious
20
- ? item.previousId!
21
- : findPreviousId(item.nextId, list);
22
-
23
- assertNewNodePosition(item, {
24
- previousId,
25
- list,
26
- });
27
-
28
- const newHeadId = item.nextId === list.headId ? item.id : list.headId;
29
- const newItems = {
30
- ...list.items,
31
- ...(previousId ? {
32
- [previousId]: {
33
- ...list.items[previousId],
34
- nextId: item.id,
35
- },
36
- } : {}),
37
- ...(hasPrevious && item.nextId ? {
38
- [item.nextId]: {
39
- ...list.items[item.nextId],
40
- ...(hasPrevious ? { previousId: item.id } : {}),
41
- },
42
- } : {}),
43
- [item.id]: item,
44
- };
45
-
46
- return factory({
47
- headId: newHeadId,
48
- items: newItems,
49
- });
50
- };
@@ -1,143 +0,0 @@
1
- import { runWhile } from '../fp';
2
- import { LinkedListFormat, LinkedListItem, SimpleLinkedList } from './type';
3
-
4
- export type WalkConfig<T extends LinkedListItem, Result> = {
5
- startId: string | null,
6
- items: Record<string, T>,
7
- initValue: Result,
8
- };
9
-
10
- type WalkCallbackResult<R> = {
11
- result: R,
12
- control?: {
13
- stop?: boolean,
14
- },
15
- };
16
-
17
- export type WalkCallback<Item, Result> = (accumulator: Result, current: Item) => WalkCallbackResult<Result>;
18
-
19
- type RunWhileValue<T> = {
20
- currentId: string | null,
21
- accumulator: T,
22
- control: WalkCallbackResult<any>['control'],
23
- };
24
-
25
- export const walkListItemRecord = <T extends LinkedListItem, Result>(
26
- callback: WalkCallback<T, Result>,
27
- config: WalkConfig<T, Result>,
28
- ) => {
29
- const { items, startId, initValue } = config;
30
- const visited = new Set();
31
- const totalNodes = Object.keys(items).length;
32
-
33
- const { result } = runWhile({
34
- iterationLimit: totalNodes + 1,
35
- initialValue: {
36
- currentId: startId,
37
- accumulator: initValue,
38
- control: {
39
- stop: false,
40
- },
41
- } as RunWhileValue<Result>,
42
- predicate: ({ control, currentId }) => {
43
- const stop = control?.stop;
44
- const forcedStop = stop === undefined ? false : stop;
45
-
46
- /**
47
- * Stop early or when the end is reached
48
- */
49
- return !forcedStop && currentId !== null;
50
- },
51
- callback: (current) => {
52
- if (visited.has(current.currentId)) {
53
- throw new Error('Infinite loop found');
54
- }
55
-
56
- visited.add(current.currentId);
57
-
58
- const currentItem = items[current.currentId!];
59
-
60
- if (!currentItem) {
61
- throw new Error('Cul de sac detected');
62
- }
63
-
64
- const { result: currentResult, control } = callback(current.accumulator, currentItem);
65
-
66
- return {
67
- accumulator: currentResult,
68
- currentId: currentItem.nextId,
69
- control,
70
- };
71
- },
72
- });
73
-
74
- return result.accumulator;
75
- };
76
-
77
- export const findPreviousId = <T extends LinkedListItem>(id: string | null, list: SimpleLinkedList<T>) => {
78
- if (id === list.headId) {
79
- return null;
80
- }
81
-
82
- return walkListItemRecord(
83
- (acc, current) => {
84
- if (current.nextId === id) {
85
- return {
86
- result: current.id,
87
- control: {
88
- stop: true,
89
- },
90
- };
91
- }
92
-
93
- return {
94
- result: acc,
95
- };
96
- },
97
- {
98
- initValue: null as null | string,
99
- startId: list.headId,
100
- items: list.items,
101
- },
102
- );
103
- };
104
-
105
- export const assertItemCompatibility = <T extends LinkedListItem>(item: T, format: LinkedListFormat | null) => {
106
- /**
107
- * An empty linked list won't have any format yet, it will be
108
- * determined by the first item inserted in the list.
109
- */
110
- if (format === null) {
111
- return;
112
- }
113
-
114
- const incompatibleWithDoubleLinks = item.previousId === undefined && format === 'double';
115
- const incompatibleWithSingleLink = item.previousId !== undefined && format === 'single';
116
-
117
- if (incompatibleWithDoubleLinks || incompatibleWithSingleLink) {
118
- throw new Error(`Node is incompatible with the list (id: ${item.id})`);
119
- }
120
- };
121
-
122
- export const assertPresence = (id: string | null | undefined, items: Record<string, unknown>) => {
123
- if (id && !items[id]) {
124
- throw new Error(`Node not found in the list (id: ${id})`);
125
- }
126
- };
127
-
128
- type PositionAssertionConfig = {
129
- previousId: string | null,
130
- list: SimpleLinkedList<LinkedListItem>,
131
- };
132
-
133
- export const assertNewNodePosition = <T extends LinkedListItem>(item: T, config: PositionAssertionConfig) => {
134
- const { previousId, list } = config;
135
-
136
- const insertionMiddleError = previousId && list.items[previousId].nextId !== item.nextId;
137
- const insertionTailError = previousId && item.nextId === null && list.items[previousId].nextId !== null;
138
- const insertionHeadError = previousId === null && item.nextId !== list.headId;
139
-
140
- if (insertionMiddleError || insertionTailError || insertionHeadError) {
141
- throw new Error(`Invalid position for given node (id: ${item.id})`);
142
- }
143
- };
@@ -1,18 +0,0 @@
1
- import { ReduceCallback, LinkedListItem, SimpleLinkedList } from './type';
2
- import { walkListItemRecord } from './linked-list-utils';
3
-
4
- export const reduceLinkedList = <Item extends LinkedListItem, Result>(
5
- cb: ReduceCallback<Item, Result>,
6
- initValue: Result,
7
- list: SimpleLinkedList<Item>,
8
- ): Result => {
9
- const { items, headId } = list;
10
-
11
- return walkListItemRecord((acc, current) => ({
12
- result: cb(acc, current),
13
- }), {
14
- startId: headId,
15
- items,
16
- initValue,
17
- });
18
- };
@@ -1,36 +0,0 @@
1
- import { ManipulationConfig, LinkedListItem } from './type';
2
- import { assertPresence, findPreviousId } from './linked-list-utils';
3
-
4
- export const removeLinkedList = <T extends LinkedListItem>(id: string, config: ManipulationConfig<T>) => {
5
- const { format, list, factory } = config;
6
- const { [id]: itemToDelete, ...otherItems } = list.items;
7
-
8
- assertPresence(id, list.items);
9
-
10
- const isDoubleLinkList = format === 'double';
11
- const previousId = isDoubleLinkList
12
- ? itemToDelete.previousId!
13
- : findPreviousId(id, list);
14
-
15
- const newHeadId = previousId === null ? itemToDelete.nextId : list.headId;
16
- const newItems = {
17
- ...otherItems,
18
- ...(previousId ? {
19
- [previousId]: {
20
- ...otherItems[previousId],
21
- nextId: itemToDelete.nextId,
22
- },
23
- } : {}),
24
- ...(isDoubleLinkList && itemToDelete.nextId ? {
25
- [itemToDelete.nextId]: {
26
- ...otherItems[itemToDelete.nextId],
27
- ...(isDoubleLinkList ? { previousId } : {}),
28
- },
29
- } : {}),
30
- };
31
-
32
- return factory({
33
- headId: newHeadId,
34
- items: newItems,
35
- });
36
- };
@@ -1,38 +0,0 @@
1
- export type LinkedListItem = {
2
- id: string,
3
- nextId: string | null,
4
- previousId?: string | null,
5
- };
6
-
7
- export type SimpleLinkedList<T extends LinkedListItem> = {
8
- headId: string | null,
9
- items: {
10
- [id: string]: T,
11
- },
12
- };
13
-
14
- export type ReduceCallback<Item, Result> = (accumulator: Result, current: Item) => Result;
15
- export type ItemPredicate<Item> = (item: Item) => boolean;
16
- export type LinkedListFormat = 'double' | 'single';
17
- export type ManipulationConfig<T extends LinkedListItem> = {
18
- format: LinkedListFormat | null,
19
- list: SimpleLinkedList<T>,
20
- factory: (list: SimpleLinkedList<T>) => LinkedList<T>,
21
- };
22
-
23
- export type LinkedList<T extends LinkedListItem> = {
24
- readonly head: T | null,
25
- readonly items: {
26
- [id: string]: T,
27
- },
28
- readonly size: number,
29
- readonly format: LinkedListFormat | null,
30
- readonly reduce: <Result>(cb: ReduceCallback<T, Result>, init: Result) => Result,
31
- readonly find: (predicate: ItemPredicate<T>) => T | null,
32
- readonly while: (predicate: ItemPredicate<T>, startId?: string) => string[],
33
- readonly remove: (id: string) => LinkedList<T>,
34
- readonly insert: (item: T) => LinkedList<T>,
35
- readonly get: (id: string) => T | null,
36
- readonly update: (item: T) => LinkedList<T>,
37
- readonly applyDiff: (before: T | null, after: T | null) => LinkedList<T>,
38
- };
@@ -1,30 +0,0 @@
1
- import { ManipulationConfig, LinkedListItem } from './type';
2
- import { assertPresence } from './linked-list-utils';
3
-
4
- export const updateLinkedList = <T extends LinkedListItem>(item: T, config: ManipulationConfig<T>) => {
5
- const { list, factory } = config;
6
-
7
- assertPresence(item.id, list.items);
8
-
9
- /**
10
- * This method should not update any ids, this is why they are removed from the item.
11
- */
12
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
- const { nextId, previousId, id, ...updatedProperties } = item;
14
- const currentItem = list.items[item.id];
15
-
16
- const newItems = {
17
- ...list.items,
18
- [item.id]: {
19
- nextId: currentItem.nextId,
20
- previousId: currentItem.previousId,
21
- id: currentItem.id,
22
- ...updatedProperties,
23
- } as T,
24
- };
25
-
26
- return factory({
27
- headId: list.headId,
28
- items: newItems,
29
- });
30
- };
@@ -1,33 +0,0 @@
1
- import { LinkedListItem, ItemPredicate, SimpleLinkedList } from './type';
2
- import { walkListItemRecord } from './linked-list-utils';
3
-
4
- export const whileLinkedList = <Item extends LinkedListItem>(
5
- predicate: ItemPredicate<Item>,
6
- list: SimpleLinkedList<Item>,
7
- startId?: string,
8
- ): string[] => {
9
- if (startId && !list.items[startId]) {
10
- throw new Error('Cannot start from a node that does not exist');
11
- }
12
-
13
- return walkListItemRecord((acc, item) => {
14
- const itemMatched = predicate(item);
15
-
16
- if (itemMatched) {
17
- return {
18
- result: [...acc, item.id],
19
- };
20
- }
21
-
22
- return {
23
- result: acc,
24
- control: {
25
- stop: true,
26
- },
27
- };
28
- }, {
29
- initValue: [] as string[],
30
- startId: startId || list.headId,
31
- items: list.items,
32
- });
33
- };
@@ -1,30 +0,0 @@
1
- import { clampNumber } from '../clamp-number';
2
-
3
- describe('clampNumber', () => {
4
- it('should not return number below the min', () => {
5
- const result = clampNumber(-51, {
6
- min: -9,
7
- max: -1,
8
- });
9
-
10
- expect(result).toStrictEqual(-9);
11
- });
12
-
13
- it('should return the same number because it is inside the range', () => {
14
- const result = clampNumber(128, {
15
- min: 100,
16
- max: 200,
17
- });
18
-
19
- expect(result).toStrictEqual(128);
20
- });
21
-
22
- it('should not return number above the max', () => {
23
- const result = clampNumber(128, {
24
- min: -100,
25
- max: -8,
26
- });
27
-
28
- expect(result).toStrictEqual(-8);
29
- });
30
- });
@@ -1,28 +0,0 @@
1
- import { interpolate, RangeArray } from '../interpolate';
2
-
3
- describe('interpolate', () => {
4
- it('should throw if input range is x2 < x1 in input range', () => {
5
- expect(
6
- () => interpolate(100, [1, 0], [0, 1]),
7
- ).toThrowError('interpolate: inputRange[0] should not be superior to inputRange[1]');
8
- });
9
-
10
- it('should throw if input number is not in input range', () => {
11
- expect(
12
- () => interpolate(100, [0, 1], [1, 0]),
13
- ).toThrowError('interpolate: input number {100} is not in range of {0}-{1}');
14
- });
15
-
16
- it('should return the correct interpolated number', () => {
17
- const set: { num: number, result: number, inputRange: RangeArray, outputRange: RangeArray }[] = [
18
- { num: 50, inputRange: [0, 100], outputRange: [0, 1], result: 0.5 },
19
- { num: 15.5, inputRange: [0, 100], outputRange: [0, 1], result: 0.155 },
20
- { num: 15.5, inputRange: [0, 100], outputRange: [0, 1000], result: 155 },
21
- { num: 75, inputRange: [0, 100], outputRange: [-100, 0], result: -25 },
22
- ];
23
-
24
- set.forEach(({ num, inputRange, outputRange, result }) => expect(
25
- interpolate(num, inputRange, outputRange),
26
- ).toStrictEqual(result));
27
- });
28
- });
@@ -1,27 +0,0 @@
1
- import { median } from '../median';
2
-
3
- describe('median', () => {
4
- it('should return the middle value if the array has an odd number of elements', () => {
5
- expect(median([1, 2, 3])).toStrictEqual(2);
6
- });
7
-
8
- it('should return the average of the middle two values if the array has an even number of elements', () => {
9
- expect(median([1, 2, 3, 4])).toStrictEqual(2.5);
10
- });
11
-
12
- it('should handle an empty array', () => {
13
- expect(median([])).toBeNull();
14
- });
15
-
16
- it('should handle array with duplicate values', () => {
17
- expect(median([4, 7, 2, 4, 9])).toStrictEqual(4);
18
- });
19
-
20
- it('should handle array with negative values', () => {
21
- expect(median([-1, -5, -3, -2, -4])).toStrictEqual(-3);
22
- });
23
-
24
- it('should overwrite the default value if the array is empty', () => {
25
- expect(median([], 0)).toStrictEqual(0);
26
- });
27
- });
@@ -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
- });