@sparted/shared-library 1.0.8-alpha.6 → 1.0.8

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 (363) hide show
  1. package/{dist/cdn → cdn}/utils/extract-info-from-url.util.js +3 -0
  2. package/{dist/cdn → cdn}/utils/extract-info-from-url.util.js.map +1 -1
  3. package/{src/index.ts → index.d.ts} +14 -15
  4. package/{dist/index.js → index.js} +0 -2
  5. package/{dist/index.js.map → index.js.map} +1 -1
  6. package/package.json +3 -7
  7. package/.circleci/config.yml +0 -40
  8. package/.eslintignore +0 -1
  9. package/.eslintrc.js +0 -17
  10. package/.gitignore +0 -37
  11. package/CHANGELOG.md +0 -34
  12. package/README.md +0 -26
  13. package/dist/github/branch/create-branch.d.ts +0 -11
  14. package/dist/github/branch/create-branch.js +0 -27
  15. package/dist/github/branch/create-branch.js.map +0 -1
  16. package/dist/github/branch/index.d.ts +0 -2
  17. package/dist/github/branch/index.js +0 -12
  18. package/dist/github/branch/index.js.map +0 -1
  19. package/dist/github/branch/update-branch.d.ts +0 -11
  20. package/dist/github/branch/update-branch.js +0 -26
  21. package/dist/github/branch/update-branch.js.map +0 -1
  22. package/dist/github/commit/create-git-blob.d.ts +0 -26
  23. package/dist/github/commit/create-git-blob.js +0 -42
  24. package/dist/github/commit/create-git-blob.js.map +0 -1
  25. package/dist/github/commit/create-git-commit.d.ts +0 -23
  26. package/dist/github/commit/create-git-commit.js +0 -39
  27. package/dist/github/commit/create-git-commit.js.map +0 -1
  28. package/dist/github/commit/create-git-tree.d.ts +0 -29
  29. package/dist/github/commit/create-git-tree.js +0 -47
  30. package/dist/github/commit/create-git-tree.js.map +0 -1
  31. package/dist/github/commit/get-sha-last-commit-of-branch.d.ts +0 -21
  32. package/dist/github/commit/get-sha-last-commit-of-branch.js +0 -35
  33. package/dist/github/commit/get-sha-last-commit-of-branch.js.map +0 -1
  34. package/dist/github/commit/get-tree-by-commit-sha.d.ts +0 -23
  35. package/dist/github/commit/get-tree-by-commit-sha.js +0 -37
  36. package/dist/github/commit/get-tree-by-commit-sha.js.map +0 -1
  37. package/dist/github/commit/index.d.ts +0 -6
  38. package/dist/github/commit/index.js +0 -20
  39. package/dist/github/commit/run-new-commit-process.d.ts +0 -27
  40. package/dist/github/commit/run-new-commit-process.js +0 -49
  41. package/dist/github/commit/run-new-commit-process.js.map +0 -1
  42. package/dist/github/commit/utils.d.ts +0 -1
  43. package/dist/github/commit/utils.js +0 -29
  44. package/dist/github/commit/utils.js.map +0 -1
  45. package/dist/github/content/get-file-content.d.ts +0 -20
  46. package/dist/github/content/get-file-content.js +0 -38
  47. package/dist/github/content/get-file-content.js.map +0 -1
  48. package/dist/github/github.d.ts +0 -25
  49. package/dist/github/github.js +0 -65
  50. package/dist/github/github.js.map +0 -1
  51. package/dist/github/index.d.ts +0 -1
  52. package/dist/github/index.js +0 -10
  53. package/dist/github/merge/create-pull-request.d.ts +0 -14
  54. package/dist/github/merge/create-pull-request.js +0 -30
  55. package/dist/github/merge/create-pull-request.js.map +0 -1
  56. package/dist/github/merge/index.d.ts +0 -2
  57. package/dist/github/merge/index.js +0 -12
  58. package/dist/github/merge/index.js.map +0 -1
  59. package/dist/github/merge/merge-pull-request.d.ts +0 -13
  60. package/dist/github/merge/merge-pull-request.js +0 -28
  61. package/dist/github/merge/merge-pull-request.js.map +0 -1
  62. package/dist/index.d.ts +0 -15
  63. package/dist/package.json +0 -65
  64. package/dist/string/index.js.map +0 -1
  65. package/dist/time/index.js.map +0 -1
  66. package/global.d.ts +0 -2
  67. package/rollup.config.ts +0 -15
  68. package/src/array/__tests__/array-to-map.test.ts +0 -50
  69. package/src/array/__tests__/get-values-from-keys.test.ts +0 -14
  70. package/src/array/array-to-map.ts +0 -32
  71. package/src/array/get-values-from-keys.ts +0 -3
  72. package/src/array/index.ts +0 -2
  73. package/src/cdn/__tests__/cdn.factory.test.ts +0 -120
  74. package/src/cdn/__tests__/utils.test.ts +0 -456
  75. package/src/cdn/cdn.factory.ts +0 -63
  76. package/src/cdn/index.ts +0 -2
  77. package/src/cdn/types/cdn-factory.type.ts +0 -35
  78. package/src/cdn/types/index.ts +0 -1
  79. package/src/cdn/utils/extract-info-from-url.util.ts +0 -21
  80. package/src/cdn/utils/get-cdn-from-s3-url.util.ts +0 -20
  81. package/src/cdn/utils/get-cdn-url.util.ts +0 -26
  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/github/branch/create-branch.ts +0 -36
  89. package/src/github/branch/index.ts +0 -2
  90. package/src/github/branch/update-branch.ts +0 -35
  91. package/src/github/commit/create-git-blob.ts +0 -57
  92. package/src/github/commit/create-git-commit.ts +0 -57
  93. package/src/github/commit/create-git-tree.ts +0 -68
  94. package/src/github/commit/get-sha-last-commit-of-branch.ts +0 -50
  95. package/src/github/commit/get-tree-by-commit-sha.ts +0 -52
  96. package/src/github/commit/index.ts +0 -6
  97. package/src/github/commit/run-new-commit-process.ts +0 -88
  98. package/src/github/commit/utils.ts +0 -31
  99. package/src/github/content/get-file-content.ts +0 -50
  100. package/src/github/github.ts +0 -93
  101. package/src/github/index.ts +0 -1
  102. package/src/github/merge/create-pull-request.ts +0 -42
  103. package/src/github/merge/index.ts +0 -2
  104. package/src/github/merge/merge-pull-request.ts +0 -39
  105. package/src/http/__tests__/encode-search-object.test.ts +0 -34
  106. package/src/http/__tests__/fetch-with-timeout.test.ts +0 -50
  107. package/src/http/encode-search-object.ts +0 -39
  108. package/src/http/fetch-with-timeout.ts +0 -24
  109. package/src/http/index.ts +0 -2
  110. package/src/linked-list/__tests__/apply-diff-linked-list.test.ts +0 -103
  111. package/src/linked-list/__tests__/create-linked-list.test.ts +0 -204
  112. package/src/linked-list/__tests__/find-linked-list.test.ts +0 -40
  113. package/src/linked-list/__tests__/get-linked-list.test.ts +0 -28
  114. package/src/linked-list/__tests__/insert-linked-list.test.ts +0 -186
  115. package/src/linked-list/__tests__/linked-list-utils.test.ts +0 -252
  116. package/src/linked-list/__tests__/reduce-linked-list.test.ts +0 -31
  117. package/src/linked-list/__tests__/remove-linked-list.test.ts +0 -129
  118. package/src/linked-list/__tests__/update-linked-list.test.ts +0 -53
  119. package/src/linked-list/__tests__/while-linked-list.test.ts +0 -58
  120. package/src/linked-list/apply-diff-linked-list.ts +0 -35
  121. package/src/linked-list/create-linked-list.ts +0 -79
  122. package/src/linked-list/find-linked-list.ts +0 -26
  123. package/src/linked-list/get-linked-list.ts +0 -9
  124. package/src/linked-list/index.ts +0 -2
  125. package/src/linked-list/insert-linked-list.ts +0 -50
  126. package/src/linked-list/linked-list-utils.ts +0 -143
  127. package/src/linked-list/reduce-linked-list.ts +0 -18
  128. package/src/linked-list/remove-linked-list.ts +0 -36
  129. package/src/linked-list/type.ts +0 -38
  130. package/src/linked-list/update-linked-list.ts +0 -29
  131. package/src/linked-list/while-linked-list.ts +0 -33
  132. package/src/math/__tests__/clamp-number.test.ts +0 -30
  133. package/src/math/__tests__/interpolate.test.ts +0 -28
  134. package/src/math/__tests__/number-range.test.ts +0 -59
  135. package/src/math/__tests__/random-number.test.ts +0 -11
  136. package/src/math/clamp-number.ts +0 -8
  137. package/src/math/index.ts +0 -4
  138. package/src/math/interpolate.ts +0 -18
  139. package/src/math/number-range.ts +0 -16
  140. package/src/math/random-number.ts +0 -10
  141. package/src/object/__tests__/merge-deep.test.ts +0 -56
  142. package/src/object/index.ts +0 -1
  143. package/src/object/merge-deep.ts +0 -27
  144. package/src/parsing/__tests__/parse-boolean.test.ts +0 -15
  145. package/src/parsing/__tests__/parse-enum.test.ts +0 -19
  146. package/src/parsing/__tests__/parse-number.test.ts +0 -20
  147. package/src/parsing/index.ts +0 -3
  148. package/src/parsing/parse-boolean.ts +0 -10
  149. package/src/parsing/parse-enum.ts +0 -16
  150. package/src/parsing/parse-number.ts +0 -12
  151. package/src/predicates/__tests__/is-function.test.ts +0 -11
  152. package/src/predicates/__tests__/is-null.test.ts +0 -11
  153. package/src/predicates/__tests__/is-object.test.ts +0 -11
  154. package/src/predicates/__tests__/is-primitive.test.ts +0 -42
  155. package/src/predicates/__tests__/is-undefined.test.ts +0 -11
  156. package/src/predicates/__tests__/is-uuid.test.ts +0 -13
  157. package/src/predicates/index.ts +0 -5
  158. package/src/predicates/is-function.ts +0 -3
  159. package/src/predicates/is-null.ts +0 -3
  160. package/src/predicates/is-object.ts +0 -3
  161. package/src/predicates/is-primitive.ts +0 -19
  162. package/src/predicates/is-undefined.ts +0 -3
  163. package/src/predicates/is-uuid.ts +0 -3
  164. package/src/promise/__tests__/delay.test.ts +0 -13
  165. package/src/promise/__tests__/execute-or-resolve-default.test.ts +0 -25
  166. package/src/promise/__tests__/execute-with-delay.test.ts +0 -24
  167. package/src/promise/delay.ts +0 -3
  168. package/src/promise/execute-or-resolve-default.ts +0 -14
  169. package/src/promise/execute-with-delay.ts +0 -6
  170. package/src/promise/index.ts +0 -3
  171. package/src/string/__tests__/replace-in-template.test.ts +0 -52
  172. package/src/string/index.ts +0 -1
  173. package/src/string/replace-in-template.ts +0 -45
  174. package/src/time/__tests__/convert.test.ts +0 -14
  175. package/src/time/__tests__/format-minutes.test.ts +0 -10
  176. package/src/time/__tests__/get-time-diff-as-string.test.ts +0 -128
  177. package/src/time/constants.ts +0 -4
  178. package/src/time/convert.ts +0 -5
  179. package/src/time/format-minutes.ts +0 -9
  180. package/src/time/get-time-diff-as-string.ts +0 -196
  181. package/src/time/index.ts +0 -4
  182. package/src/types/function.ts +0 -1
  183. package/src/types/general.ts +0 -8
  184. package/src/types/index.ts +0 -4
  185. package/src/types/object.ts +0 -33
  186. package/src/types/search.ts +0 -29
  187. package/tsconfig.eslint.json +0 -8
  188. package/tsconfig.json +0 -25
  189. /package/{dist/_virtual → _virtual}/_tslib.js +0 -0
  190. /package/{dist/_virtual → _virtual}/_tslib.js.map +0 -0
  191. /package/{dist/array → array}/array-to-map.d.ts +0 -0
  192. /package/{dist/array → array}/array-to-map.js +0 -0
  193. /package/{dist/array → array}/array-to-map.js.map +0 -0
  194. /package/{dist/array → array}/get-values-from-keys.d.ts +0 -0
  195. /package/{dist/array → array}/get-values-from-keys.js +0 -0
  196. /package/{dist/array → array}/get-values-from-keys.js.map +0 -0
  197. /package/{dist/array → array}/index.d.ts +0 -0
  198. /package/{dist/array → array}/index.js +0 -0
  199. /package/{dist/array → array}/index.js.map +0 -0
  200. /package/{dist/cdn → cdn}/cdn.factory.d.ts +0 -0
  201. /package/{dist/cdn → cdn}/cdn.factory.js +0 -0
  202. /package/{dist/cdn → cdn}/cdn.factory.js.map +0 -0
  203. /package/{dist/cdn → cdn}/index.d.ts +0 -0
  204. /package/{dist/cdn → cdn}/index.js +0 -0
  205. /package/{dist/cdn → cdn}/index.js.map +0 -0
  206. /package/{dist/cdn → cdn}/types/cdn-factory.type.d.ts +0 -0
  207. /package/{dist/cdn → cdn}/types/index.d.ts +0 -0
  208. /package/{dist/cdn → cdn}/types/index.js +0 -0
  209. /package/{dist/cdn → cdn}/types/index.js.map +0 -0
  210. /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.d.ts +0 -0
  211. /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.d.ts +0 -0
  212. /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.js +0 -0
  213. /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.js.map +0 -0
  214. /package/{dist/cdn → cdn}/utils/get-cdn-url.util.d.ts +0 -0
  215. /package/{dist/cdn → cdn}/utils/get-cdn-url.util.js +0 -0
  216. /package/{dist/cdn → cdn}/utils/get-cdn-url.util.js.map +0 -0
  217. /package/{dist/formatting → formatting}/format-number.d.ts +0 -0
  218. /package/{dist/formatting → formatting}/format-number.js +0 -0
  219. /package/{dist/formatting → formatting}/format-number.js.map +0 -0
  220. /package/{dist/formatting → formatting}/index.d.ts +0 -0
  221. /package/{dist/formatting → formatting}/index.js +0 -0
  222. /package/{dist/formatting → formatting}/index.js.map +0 -0
  223. /package/{dist/fp → fp}/index.d.ts +0 -0
  224. /package/{dist/fp → fp}/index.js +0 -0
  225. /package/{dist/fp → fp}/index.js.map +0 -0
  226. /package/{dist/fp → fp}/run-while.d.ts +0 -0
  227. /package/{dist/fp → fp}/run-while.js +0 -0
  228. /package/{dist/fp → fp}/run-while.js.map +0 -0
  229. /package/{dist/http → http}/encode-search-object.d.ts +0 -0
  230. /package/{dist/http → http}/encode-search-object.js +0 -0
  231. /package/{dist/http → http}/encode-search-object.js.map +0 -0
  232. /package/{dist/http → http}/fetch-with-timeout.d.ts +0 -0
  233. /package/{dist/http → http}/fetch-with-timeout.js +0 -0
  234. /package/{dist/http → http}/fetch-with-timeout.js.map +0 -0
  235. /package/{dist/http → http}/index.d.ts +0 -0
  236. /package/{dist/http → http}/index.js +0 -0
  237. /package/{dist/http → http}/index.js.map +0 -0
  238. /package/{dist/linked-list → linked-list}/apply-diff-linked-list.d.ts +0 -0
  239. /package/{dist/linked-list → linked-list}/apply-diff-linked-list.js +0 -0
  240. /package/{dist/linked-list → linked-list}/apply-diff-linked-list.js.map +0 -0
  241. /package/{dist/linked-list → linked-list}/create-linked-list.d.ts +0 -0
  242. /package/{dist/linked-list → linked-list}/create-linked-list.js +0 -0
  243. /package/{dist/linked-list → linked-list}/create-linked-list.js.map +0 -0
  244. /package/{dist/linked-list → linked-list}/find-linked-list.d.ts +0 -0
  245. /package/{dist/linked-list → linked-list}/find-linked-list.js +0 -0
  246. /package/{dist/linked-list → linked-list}/find-linked-list.js.map +0 -0
  247. /package/{dist/linked-list → linked-list}/get-linked-list.d.ts +0 -0
  248. /package/{dist/linked-list → linked-list}/get-linked-list.js +0 -0
  249. /package/{dist/linked-list → linked-list}/get-linked-list.js.map +0 -0
  250. /package/{dist/linked-list → linked-list}/index.d.ts +0 -0
  251. /package/{dist/linked-list → linked-list}/index.js +0 -0
  252. /package/{dist/github → linked-list}/index.js.map +0 -0
  253. /package/{dist/linked-list → linked-list}/insert-linked-list.d.ts +0 -0
  254. /package/{dist/linked-list → linked-list}/insert-linked-list.js +0 -0
  255. /package/{dist/linked-list → linked-list}/insert-linked-list.js.map +0 -0
  256. /package/{dist/linked-list → linked-list}/linked-list-utils.d.ts +0 -0
  257. /package/{dist/linked-list → linked-list}/linked-list-utils.js +0 -0
  258. /package/{dist/linked-list → linked-list}/linked-list-utils.js.map +0 -0
  259. /package/{dist/linked-list → linked-list}/reduce-linked-list.d.ts +0 -0
  260. /package/{dist/linked-list → linked-list}/reduce-linked-list.js +0 -0
  261. /package/{dist/linked-list → linked-list}/reduce-linked-list.js.map +0 -0
  262. /package/{dist/linked-list → linked-list}/remove-linked-list.d.ts +0 -0
  263. /package/{dist/linked-list → linked-list}/remove-linked-list.js +0 -0
  264. /package/{dist/linked-list → linked-list}/remove-linked-list.js.map +0 -0
  265. /package/{dist/linked-list → linked-list}/type.d.ts +0 -0
  266. /package/{dist/linked-list → linked-list}/update-linked-list.d.ts +0 -0
  267. /package/{dist/linked-list → linked-list}/update-linked-list.js +0 -0
  268. /package/{dist/linked-list → linked-list}/update-linked-list.js.map +0 -0
  269. /package/{dist/linked-list → linked-list}/while-linked-list.d.ts +0 -0
  270. /package/{dist/linked-list → linked-list}/while-linked-list.js +0 -0
  271. /package/{dist/linked-list → linked-list}/while-linked-list.js.map +0 -0
  272. /package/{dist/math → math}/clamp-number.d.ts +0 -0
  273. /package/{dist/math → math}/clamp-number.js +0 -0
  274. /package/{dist/math → math}/clamp-number.js.map +0 -0
  275. /package/{dist/math → math}/index.d.ts +0 -0
  276. /package/{dist/math → math}/index.js +0 -0
  277. /package/{dist/math → math}/index.js.map +0 -0
  278. /package/{dist/math → math}/interpolate.d.ts +0 -0
  279. /package/{dist/math → math}/interpolate.js +0 -0
  280. /package/{dist/math → math}/interpolate.js.map +0 -0
  281. /package/{dist/math → math}/number-range.d.ts +0 -0
  282. /package/{dist/math → math}/number-range.js +0 -0
  283. /package/{dist/math → math}/number-range.js.map +0 -0
  284. /package/{dist/math → math}/random-number.d.ts +0 -0
  285. /package/{dist/math → math}/random-number.js +0 -0
  286. /package/{dist/math → math}/random-number.js.map +0 -0
  287. /package/{dist/object → object}/index.d.ts +0 -0
  288. /package/{dist/object → object}/index.js +0 -0
  289. /package/{dist/linked-list → object}/index.js.map +0 -0
  290. /package/{dist/object → object}/merge-deep.d.ts +0 -0
  291. /package/{dist/object → object}/merge-deep.js +0 -0
  292. /package/{dist/object → object}/merge-deep.js.map +0 -0
  293. /package/{dist/parsing → parsing}/index.d.ts +0 -0
  294. /package/{dist/parsing → parsing}/index.js +0 -0
  295. /package/{dist/parsing → parsing}/index.js.map +0 -0
  296. /package/{dist/parsing → parsing}/parse-boolean.d.ts +0 -0
  297. /package/{dist/parsing → parsing}/parse-boolean.js +0 -0
  298. /package/{dist/parsing → parsing}/parse-boolean.js.map +0 -0
  299. /package/{dist/parsing → parsing}/parse-enum.d.ts +0 -0
  300. /package/{dist/parsing → parsing}/parse-enum.js +0 -0
  301. /package/{dist/parsing → parsing}/parse-enum.js.map +0 -0
  302. /package/{dist/parsing → parsing}/parse-number.d.ts +0 -0
  303. /package/{dist/parsing → parsing}/parse-number.js +0 -0
  304. /package/{dist/parsing → parsing}/parse-number.js.map +0 -0
  305. /package/{dist/predicates → predicates}/index.d.ts +0 -0
  306. /package/{dist/predicates → predicates}/index.js +0 -0
  307. /package/{dist/predicates → predicates}/index.js.map +0 -0
  308. /package/{dist/predicates → predicates}/is-function.d.ts +0 -0
  309. /package/{dist/predicates → predicates}/is-function.js +0 -0
  310. /package/{dist/predicates → predicates}/is-function.js.map +0 -0
  311. /package/{dist/predicates → predicates}/is-null.d.ts +0 -0
  312. /package/{dist/predicates → predicates}/is-null.js +0 -0
  313. /package/{dist/predicates → predicates}/is-null.js.map +0 -0
  314. /package/{dist/predicates → predicates}/is-object.d.ts +0 -0
  315. /package/{dist/predicates → predicates}/is-object.js +0 -0
  316. /package/{dist/predicates → predicates}/is-object.js.map +0 -0
  317. /package/{dist/predicates → predicates}/is-primitive.d.ts +0 -0
  318. /package/{dist/predicates → predicates}/is-primitive.js +0 -0
  319. /package/{dist/predicates → predicates}/is-primitive.js.map +0 -0
  320. /package/{dist/predicates → predicates}/is-undefined.d.ts +0 -0
  321. /package/{dist/predicates → predicates}/is-undefined.js +0 -0
  322. /package/{dist/predicates → predicates}/is-undefined.js.map +0 -0
  323. /package/{dist/predicates → predicates}/is-uuid.d.ts +0 -0
  324. /package/{dist/promise → promise}/delay.d.ts +0 -0
  325. /package/{dist/promise → promise}/delay.js +0 -0
  326. /package/{dist/promise → promise}/delay.js.map +0 -0
  327. /package/{dist/promise → promise}/execute-or-resolve-default.d.ts +0 -0
  328. /package/{dist/promise → promise}/execute-or-resolve-default.js +0 -0
  329. /package/{dist/promise → promise}/execute-or-resolve-default.js.map +0 -0
  330. /package/{dist/promise → promise}/execute-with-delay.d.ts +0 -0
  331. /package/{dist/promise → promise}/execute-with-delay.js +0 -0
  332. /package/{dist/promise → promise}/execute-with-delay.js.map +0 -0
  333. /package/{dist/promise → promise}/index.d.ts +0 -0
  334. /package/{dist/promise → promise}/index.js +0 -0
  335. /package/{dist/promise → promise}/index.js.map +0 -0
  336. /package/{dist/string → string}/index.d.ts +0 -0
  337. /package/{dist/string → string}/index.js +0 -0
  338. /package/{dist/object → string}/index.js.map +0 -0
  339. /package/{dist/string → string}/replace-in-template.d.ts +0 -0
  340. /package/{dist/string → string}/replace-in-template.js +0 -0
  341. /package/{dist/string → string}/replace-in-template.js.map +0 -0
  342. /package/{dist/time → time}/constants.d.ts +0 -0
  343. /package/{dist/time → time}/constants.js +0 -0
  344. /package/{dist/time → time}/constants.js.map +0 -0
  345. /package/{dist/time → time}/convert.d.ts +0 -0
  346. /package/{dist/time → time}/convert.js +0 -0
  347. /package/{dist/time → time}/convert.js.map +0 -0
  348. /package/{dist/time → time}/format-minutes.d.ts +0 -0
  349. /package/{dist/time → time}/format-minutes.js +0 -0
  350. /package/{dist/time → time}/format-minutes.js.map +0 -0
  351. /package/{dist/time → time}/get-time-diff-as-string.d.ts +0 -0
  352. /package/{dist/time → time}/get-time-diff-as-string.js +0 -0
  353. /package/{dist/time → time}/get-time-diff-as-string.js.map +0 -0
  354. /package/{dist/time → time}/index.d.ts +0 -0
  355. /package/{dist/time → time}/index.js +0 -0
  356. /package/{dist/github/commit → time}/index.js.map +0 -0
  357. /package/{dist/types → types}/function.d.ts +0 -0
  358. /package/{dist/types → types}/general.d.ts +0 -0
  359. /package/{dist/types → types}/index.d.ts +0 -0
  360. /package/{dist/types → types}/index.js +0 -0
  361. /package/{dist/types → types}/index.js.map +0 -0
  362. /package/{dist/types → types}/object.d.ts +0 -0
  363. /package/{dist/types → types}/search.d.ts +0 -0
@@ -1,456 +0,0 @@
1
- import {
2
- imgixTransformationQueries,
3
- twicpicsTransformationQueries,
4
- } from '../cdn.factory';
5
- import { extractInfoFromUrl } from '../utils/extract-info-from-url.util';
6
- import { getCdnUrlFactory } from '../utils/get-cdn-url.util';
7
- import { getCdnFromS3UrlFactory } from '../utils/get-cdn-from-s3-url.util';
8
- import type { InstanceMapper } from '../types';
9
-
10
- describe('extract-info-from-url', () => {
11
- it('should handle non-aws s3 url', () => {
12
- const info = extractInfoFromUrl('https://www.google.com');
13
-
14
- expect(info).toBeUndefined();
15
- });
16
-
17
- it('should handle all aws s3 url', () => {
18
- const { instanceId: instanceIdEW1, path: pathEW1 } = extractInfoFromUrl(
19
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
20
- ) ?? {};
21
-
22
- expect(instanceIdEW1).toBe('check');
23
- expect(pathEW1).toBe('/path/to/something');
24
-
25
- const { instanceId: instanceIdAmazonaws, path: pathAmazonaws } = extractInfoFromUrl(
26
- 'https://sparted-prod-check.s3.amazonaws.com/path/to/something',
27
- ) ?? {};
28
-
29
- expect(instanceIdAmazonaws).toBe('check');
30
- expect(pathAmazonaws).toBe('/path/to/something');
31
-
32
- const { instanceId: instanceIdCloud, path: pathCloud } = extractInfoFromUrl(
33
- 'https://sparted-prod-check.s3.fr-par.scw.cloud/path/to/something',
34
- ) ?? {};
35
-
36
- expect(instanceIdCloud).toBe('check');
37
- expect(pathCloud).toBe('/path/to/something');
38
- });
39
- });
40
-
41
- describe('getCdnUrlFactory', () => {
42
- it('Imgix - should generate url without params', () => {
43
- const domain = 'https://sparted.imgix.fr';
44
- const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
45
- const getCdnUrl = getCdnUrlFactory({
46
- domain,
47
- instanceMapper,
48
- transformationQueries: imgixTransformationQueries,
49
- });
50
-
51
- expect(getCdnUrl('test', '/path/to/something')).toBe(
52
- 'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress,format',
53
- );
54
- });
55
-
56
- it('Twicpics - should generate url without params', () => {
57
- const domain = 'https://sparted.twicpics.fr';
58
- const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
59
- const getCdnUrl = getCdnUrlFactory({
60
- domain,
61
- instanceMapper,
62
- transformationQueries: twicpicsTransformationQueries,
63
- });
64
-
65
- expect(getCdnUrl('test', '/path/to/something')).toBe(
66
- 'https://sparted.twicpics.fr/prod/test/path/to/something',
67
- );
68
- });
69
-
70
- it('Imgix - should generate url of image as thumbnail', () => {
71
- const domain = 'https://sparted.imgix.fr';
72
- const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
73
- const getCdnUrl = getCdnUrlFactory({
74
- domain,
75
- instanceMapper,
76
- transformationQueries: imgixTransformationQueries,
77
- });
78
-
79
- expect(getCdnUrl('test', '/path/to/something', { asThumbnail: true })).toBe(
80
- 'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress,format&h=300&w=300',
81
- );
82
- });
83
-
84
- it('Twicpics - should generate url of image as thumbnail', () => {
85
- const domain = 'https://sparted.twicpics.fr';
86
- const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
87
- const getCdnUrl = getCdnUrlFactory({
88
- domain,
89
- instanceMapper,
90
- transformationQueries: twicpicsTransformationQueries,
91
- });
92
-
93
- expect(getCdnUrl('test', '/path/to/something', { asThumbnail: true })).toBe(
94
- 'https://sparted.twicpics.fr/prod/test/path/to/something?twic=v1/cover=300x300',
95
- );
96
- });
97
-
98
- it('Imgix - should generate url with params', () => {
99
- const domain = 'https://sparted.imgix.fr';
100
- const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
101
- const getCdnUrl = getCdnUrlFactory({
102
- domain,
103
- instanceMapper,
104
- transformationQueries: imgixTransformationQueries,
105
- });
106
-
107
- expect(
108
- getCdnUrl('test', '/path/to/something', {
109
- transformation: { fit: 'crop', height: 1, width: 1 },
110
- }),
111
- ).toBe(
112
- 'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress,format&fit=crop&h=1&w=1',
113
- );
114
-
115
- expect(
116
- getCdnUrl('test', '/path/to/something', {
117
- transformation: { fit: 'crop', width: 1 },
118
- }),
119
- ).toBe(
120
- 'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress,format&fit=crop&w=1',
121
- );
122
-
123
- expect(
124
- getCdnUrl('test', '/path/to/something', {
125
- transformation: { fit: 'crop', height: 1 },
126
- }),
127
- ).toBe(
128
- 'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress,format&fit=crop&h=1',
129
- );
130
-
131
- expect(
132
- getCdnUrl('test', '/path/to/something', { transformation: { width: 1 } }),
133
- ).toBe(
134
- 'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress,format&w=1',
135
- );
136
-
137
- expect(
138
- getCdnUrl('test', '/path/to/something', { transformation: { height: 1 } }),
139
- ).toBe(
140
- 'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress,format&h=1',
141
- );
142
-
143
- expect(
144
- getCdnUrl('test', '/path/to/something', {
145
- transformation: { height: 1, width: 1 },
146
- }),
147
- ).toBe(
148
- 'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress,format&h=1&w=1',
149
- );
150
-
151
- expect(
152
- getCdnUrl('test', '/path/to/something', {
153
- transformation: { devicePixelRatio: 2 },
154
- }),
155
- ).toBe(
156
- 'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress,format&dpr=2',
157
- );
158
-
159
- expect(
160
- getCdnUrl('test', '/path/to/something', {
161
- transformation: { quality: 75 },
162
- }),
163
- ).toBe(
164
- 'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress,format&q=75',
165
- );
166
- });
167
-
168
- it('Twicpics - should generate url of image as thumbnail', () => {
169
- const domain = 'https://sparted.twicpics.fr';
170
- const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
171
- const getCdnUrl = getCdnUrlFactory({
172
- domain,
173
- instanceMapper,
174
- transformationQueries: twicpicsTransformationQueries,
175
- });
176
-
177
- expect(
178
- getCdnUrl('test', '/path/to/something', {
179
- transformation: { fit: 'crop', height: 1, width: 1 },
180
- }),
181
- ).toBe(
182
- 'https://sparted.twicpics.fr/prod/test/path/to/something?twic=v1/crop=1x1',
183
- );
184
-
185
- expect(
186
- getCdnUrl('test', '/path/to/something', {
187
- transformation: { fit: 'contain', height: 1, width: 1 },
188
- }),
189
- ).toBe(
190
- 'https://sparted.twicpics.fr/prod/test/path/to/something?twic=v1/contain=1x1',
191
- );
192
-
193
- expect(
194
- getCdnUrl('test', '/path/to/something', { transformation: { width: 1 } }),
195
- ).toBe(
196
- 'https://sparted.twicpics.fr/prod/test/path/to/something?twic=v1/cover=1',
197
- );
198
- });
199
- });
200
-
201
- describe('getCdnFromS3UrlFactory', () => {
202
- it('Imgix - should handle non-aws s3 url', () => {
203
- const domain = 'https://sparted.imgix.fr';
204
- const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
205
- const getCdnUrl = getCdnUrlFactory({
206
- domain,
207
- instanceMapper,
208
- transformationQueries: imgixTransformationQueries,
209
- });
210
-
211
- const getCdnFromS3Url = getCdnFromS3UrlFactory({
212
- getCdnUrl,
213
- });
214
-
215
- expect(getCdnFromS3Url('https://www.google.com')).toBe(
216
- 'https://www.google.com',
217
- );
218
- });
219
-
220
- it('Twicpics - should handle non-aws s3 url', () => {
221
- const domain = 'https://sparted.twicpics.fr';
222
- const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
223
- const getCdnUrl = getCdnUrlFactory({
224
- domain,
225
- instanceMapper,
226
- transformationQueries: twicpicsTransformationQueries,
227
- });
228
-
229
- const getCdnFromS3Url = getCdnFromS3UrlFactory({
230
- getCdnUrl,
231
- });
232
-
233
- expect(getCdnFromS3Url('https://www.google.com')).toBe(
234
- 'https://www.google.com',
235
- );
236
- });
237
-
238
- it('Imgix - should handle all aws s3 url with no params', () => {
239
- const domain = 'https://sparted.imgix.fr';
240
- const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
241
- const getCdnUrl = getCdnUrlFactory({
242
- domain,
243
- instanceMapper,
244
- transformationQueries: imgixTransformationQueries,
245
- });
246
-
247
- const getCdnFromS3Url = getCdnFromS3UrlFactory({
248
- getCdnUrl,
249
- });
250
-
251
- expect(
252
- getCdnFromS3Url(
253
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
254
- ),
255
- ).toBe(
256
- 'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress,format',
257
- );
258
-
259
- expect(
260
- getCdnFromS3Url(
261
- 'https://sparted-prod-check.s3.amazonaws.com/path/to/something',
262
- ),
263
- ).toBe(
264
- 'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress,format',
265
- );
266
-
267
- expect(
268
- getCdnFromS3Url(
269
- 'https://sparted-prod-check.s3.fr-par.scw.cloud/path/to/something',
270
- ),
271
- ).toBe(
272
- 'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress,format',
273
- );
274
- });
275
-
276
- it('Twicpics - should handle all aws s3 url with no params', () => {
277
- const domain = 'https://sparted.twicpics.fr';
278
- const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
279
- const getCdnUrl = getCdnUrlFactory({
280
- domain,
281
- instanceMapper,
282
- transformationQueries: twicpicsTransformationQueries,
283
- });
284
-
285
- const getCdnFromS3Url = getCdnFromS3UrlFactory({
286
- getCdnUrl,
287
- });
288
-
289
- expect(
290
- getCdnFromS3Url(
291
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
292
- ),
293
- ).toBe('https://sparted.twicpics.fr/prod/check/path/to/something');
294
-
295
- expect(
296
- getCdnFromS3Url(
297
- 'https://sparted-prod-check.s3.amazonaws.com/path/to/something',
298
- ),
299
- ).toBe('https://sparted.twicpics.fr/prod/check/path/to/something');
300
-
301
- expect(
302
- getCdnFromS3Url(
303
- 'https://sparted-prod-check.s3.fr-par.scw.cloud/path/to/something',
304
- ),
305
- ).toBe('https://sparted.twicpics.fr/prod/check/path/to/something');
306
- });
307
-
308
- it('Imgix - should handle params', () => {
309
- const domain = 'https://sparted.imgix.fr';
310
- const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
311
- const getCdnUrl = getCdnUrlFactory({
312
- domain,
313
- instanceMapper,
314
- transformationQueries: imgixTransformationQueries,
315
- });
316
-
317
- const getCdnFromS3Url = getCdnFromS3UrlFactory({
318
- getCdnUrl,
319
- });
320
-
321
- expect(
322
- getCdnFromS3Url(
323
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
324
- {
325
- transformation: { fit: 'crop', height: 1, width: 1 },
326
- },
327
- ),
328
- ).toBe(
329
- 'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress,format&fit=crop&h=1&w=1',
330
- );
331
-
332
- expect(
333
- getCdnFromS3Url(
334
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
335
- {
336
- transformation: { fit: 'crop', width: 1 },
337
- },
338
- ),
339
- ).toBe(
340
- 'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress,format&fit=crop&w=1',
341
- );
342
-
343
- expect(
344
- getCdnFromS3Url(
345
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
346
- {
347
- transformation: { fit: 'crop', height: 1 },
348
- },
349
- ),
350
- ).toBe(
351
- 'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress,format&fit=crop&h=1',
352
- );
353
-
354
- expect(
355
- getCdnFromS3Url(
356
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
357
- {
358
- transformation: { width: 1 },
359
- },
360
- ),
361
- ).toBe(
362
- 'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress,format&w=1',
363
- );
364
-
365
- expect(
366
- getCdnFromS3Url(
367
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
368
- {
369
- transformation: { height: 1 },
370
- },
371
- ),
372
- ).toBe(
373
- 'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress,format&h=1',
374
- );
375
-
376
- expect(
377
- getCdnFromS3Url(
378
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
379
- {
380
- transformation: { height: 1, width: 1 },
381
- },
382
- ),
383
- ).toBe(
384
- 'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress,format&h=1&w=1',
385
- );
386
-
387
- expect(
388
- getCdnFromS3Url(
389
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
390
- {
391
- transformation: { devicePixelRatio: 2 },
392
- },
393
- ),
394
- ).toBe(
395
- 'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress,format&dpr=2',
396
- );
397
-
398
- expect(
399
- getCdnFromS3Url(
400
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
401
- {
402
- transformation: { quality: 75 },
403
- },
404
- ),
405
- ).toBe(
406
- 'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress,format&q=75',
407
- );
408
- });
409
-
410
- it('Twicpics - should handle params', () => {
411
- const domain = 'https://sparted.twicpics.fr';
412
- const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
413
- const getCdnUrl = getCdnUrlFactory({
414
- domain,
415
- instanceMapper,
416
- transformationQueries: twicpicsTransformationQueries,
417
- });
418
-
419
- const getCdnFromS3Url = getCdnFromS3UrlFactory({
420
- getCdnUrl,
421
- });
422
-
423
- expect(
424
- getCdnFromS3Url(
425
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
426
- {
427
- transformation: { fit: 'crop', height: 1, width: 1 },
428
- },
429
- ),
430
- ).toBe(
431
- 'https://sparted.twicpics.fr/prod/check/path/to/something?twic=v1/crop=1x1',
432
- );
433
-
434
- expect(
435
- getCdnFromS3Url(
436
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
437
- {
438
- transformation: { fit: 'contain', height: 1, width: 1 },
439
- },
440
- ),
441
- ).toBe(
442
- 'https://sparted.twicpics.fr/prod/check/path/to/something?twic=v1/contain=1x1',
443
- );
444
-
445
- expect(
446
- getCdnFromS3Url(
447
- 'https://sparted-prod-check.s3.eu-west-1/path/to/something',
448
- {
449
- transformation: { width: 1 },
450
- },
451
- ),
452
- ).toBe(
453
- 'https://sparted.twicpics.fr/prod/check/path/to/something?twic=v1/cover=1',
454
- );
455
- });
456
- });
@@ -1,63 +0,0 @@
1
- import type { CreateCdn, TransformationQueries } from './types';
2
- import { getCdnFromS3UrlFactory } from './utils/get-cdn-from-s3-url.util';
3
- import { getCdnUrlFactory } from './utils/get-cdn-url.util';
4
-
5
- export const imgixTransformationQueries: TransformationQueries = ({
6
- fit,
7
- devicePixelRatio,
8
- height,
9
- width,
10
- quality,
11
- }) => [
12
- '?auto=compress,format',
13
- fit === 'crop' ? '&fit=crop' : '',
14
- Number.isFinite(devicePixelRatio) ? `&dpr=${devicePixelRatio}` : '',
15
- Number.isFinite(height) ? `&h=${height}` : '',
16
- Number.isFinite(width) ? `&w=${width}` : '',
17
- quality !== undefined && quality >= 0 && quality <= 100
18
- ? `&q=${quality}`
19
- : '',
20
- ].join('');
21
-
22
- export const twicpicsTransformationQueries: TransformationQueries = (
23
- params,
24
- ) => {
25
- if (params.fit !== undefined) {
26
- if (params.width === undefined || params.height === undefined) {
27
- // eslint-disable-next-line no-console
28
- console.error('⚠️ The Twicpics api needs a width and a height.');
29
- return '';
30
- }
31
- return `?twic=v1/${params.fit}=${params.width}x${params.height}`;
32
- }
33
- if (params.width !== undefined) {
34
- const resizeHeight = params.height !== undefined ? `x${params.height}` : '';
35
- return `?twic=v1/cover=${params.width}${resizeHeight}`;
36
- }
37
- return '';
38
- };
39
-
40
- /**
41
- *
42
- * @param type cdn provider: 'twicpics' | 'imgix'
43
- * @param domain provider domain
44
- * @param instanceMapper domain + the result of the instanceMapper will form the base path
45
- * @returns \{ getCdnUrl, transformationQueries \}
46
- */
47
- export const createCdn: CreateCdn = ({ type, domain, instanceMapper }) => {
48
- const getCdnUrl = getCdnUrlFactory({
49
- domain,
50
- instanceMapper,
51
- transformationQueries:
52
- type === 'imgix'
53
- ? imgixTransformationQueries
54
- : twicpicsTransformationQueries,
55
- });
56
-
57
- return {
58
- getCdnUrl,
59
- getCdnFromS3Url: getCdnFromS3UrlFactory({
60
- getCdnUrl,
61
- }),
62
- };
63
- };
package/src/cdn/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { createCdn } from './cdn.factory';
2
- export * from './types';
@@ -1,35 +0,0 @@
1
- export type BaseUrlMapperFunc = (instanceId: string) => string;
2
-
3
- export type Transformation = {
4
- fit?: 'crop' | 'contain';
5
- width?: number;
6
- height?: number;
7
- devicePixelRatio?: number;
8
- quality?: number;
9
- };
10
-
11
- export type CdnParams = {
12
- asThumbnail?: boolean;
13
- transformation?: Transformation;
14
- };
15
-
16
- export type TransformationQueries = (params: Transformation) => string;
17
-
18
- export type GetCdnUrl = (instanceId: string, path: `/${string}`, params?: CdnParams) => string;
19
-
20
- export type GetCdnFromS3Url = (url: string, params?: CdnParams) => string;
21
-
22
- export type InstanceMapper = (instanceId: string) => string;
23
-
24
- export type CdnConfig = {
25
- type: 'twicpics' | 'imgix';
26
- domain: `https://${string}`;
27
- instanceMapper: InstanceMapper;
28
- };
29
-
30
- export type Cdn = {
31
- getCdnUrl: GetCdnUrl;
32
- getCdnFromS3Url: GetCdnFromS3Url;
33
- };
34
-
35
- export type CreateCdn = (config: CdnConfig) => Cdn;
@@ -1 +0,0 @@
1
- export * from './cdn-factory.type';
@@ -1,21 +0,0 @@
1
- type ExtractInfoFromUrl = (url: string) =>
2
- | {
3
- instanceId: string;
4
- path: `/${string}`;
5
- }
6
- | undefined;
7
-
8
- const S3_URL_RE = /https:\/\/sparted-prod-([^.]+)\.s3(\.eu-west-1)?(\.amazonaws\.com)?(\.fr-par\.scw\.cloud)?(\/[^?]+)/;
9
-
10
- export const extractInfoFromUrl: ExtractInfoFromUrl = (url) => {
11
- const matchS3Url = url.match(S3_URL_RE);
12
-
13
- if (!matchS3Url) {
14
- return undefined;
15
- }
16
-
17
- const instanceId = matchS3Url[1];
18
- const path = matchS3Url[5] as `/${string}`;
19
-
20
- return { instanceId, path };
21
- };
@@ -1,20 +0,0 @@
1
- import type { GetCdnFromS3Url, GetCdnUrl } from '../types';
2
- import { extractInfoFromUrl } from './extract-info-from-url.util';
3
-
4
- type FactoryConfig = {
5
- getCdnUrl: GetCdnUrl;
6
- };
7
-
8
- export function getCdnFromS3UrlFactory(config: FactoryConfig): GetCdnFromS3Url {
9
- return (url, params) => {
10
- const { getCdnUrl } = config;
11
-
12
- const info = extractInfoFromUrl(url);
13
- if (info === undefined) {
14
- return url;
15
- }
16
- const { instanceId, path } = info;
17
-
18
- return getCdnUrl(instanceId, path, params);
19
- };
20
- }
@@ -1,26 +0,0 @@
1
- import type {
2
- GetCdnUrl,
3
- InstanceMapper,
4
- Transformation,
5
- TransformationQueries,
6
- } from '../types';
7
-
8
- const DEFAULT_THUMBNAIL_CONFIG: Transformation = { width: 300, height: 300 };
9
-
10
- type FactoryConfig = {
11
- domain: `https://${string}`;
12
- instanceMapper: InstanceMapper;
13
- transformationQueries: TransformationQueries;
14
- };
15
-
16
- export const getCdnUrlFactory = (config: FactoryConfig): GetCdnUrl => (instanceId, path, params = {}) => {
17
- const { domain, instanceMapper, transformationQueries } = config;
18
-
19
- const {
20
- transformation = params.asThumbnail ? DEFAULT_THUMBNAIL_CONFIG : {},
21
- } = params;
22
-
23
- return `${domain}${instanceMapper(
24
- instanceId,
25
- )}${path}${transformationQueries(transformation)}`;
26
- };
@@ -1,11 +0,0 @@
1
- import { formatNumber } from '../format-number';
2
-
3
- describe('formatNumber', () => {
4
- it('should format numbers correctly', () => {
5
- expect(formatNumber(48)).toBe('48');
6
- expect(formatNumber(999)).toBe('999');
7
- expect(formatNumber(1000)).toBe('1.0k');
8
- expect(formatNumber(42869)).toBe('42.8k');
9
- expect(formatNumber(992169)).toBe('992.1k');
10
- });
11
- });
@@ -1,14 +0,0 @@
1
- const DECIMAL_SEPARATOR = '.';
2
- const THOUSAND_UNIT = 'k';
3
-
4
- export const formatNumber = (n: number): string => {
5
- const numString = String(n);
6
- if (n < 1000) {
7
- return numString;
8
- }
9
-
10
- const decimalsMinusLast = numString.slice(0, numString.length - 3);
11
- const lastDecimal = numString.slice(numString.length - 3, numString.length - 2);
12
-
13
- return `${decimalsMinusLast}${DECIMAL_SEPARATOR}${lastDecimal}${THOUSAND_UNIT}`;
14
- };
@@ -1 +0,0 @@
1
- export * from './format-number';
@@ -1,29 +0,0 @@
1
- import { runWhile } from '../run-while';
2
-
3
- describe('runWhile', () => {
4
- it('should run while the predicate is true and return the right interation count', () => {
5
- const { result, iterationCount } = runWhile({
6
- predicate: (counter) => counter <= 9,
7
- callback: (counter) => counter + 1,
8
- initialValue: 0,
9
- });
10
-
11
- expect(result).toStrictEqual(10);
12
- expect(iterationCount).toStrictEqual(10);
13
- });
14
-
15
- it('should throw an error when the iteration limit is reached', () => {
16
- const predicateMock = jest.fn().mockReturnValue(true);
17
-
18
- const { iterationCount } = runWhile({
19
- predicate: predicateMock,
20
- callback: (counter) => counter + 1,
21
- initialValue: 0,
22
- iterationLimit: 89,
23
- });
24
-
25
- // Called once outside the while loop
26
- expect(predicateMock).toHaveBeenCalledTimes(90);
27
- expect(iterationCount).toStrictEqual(89);
28
- });
29
- });