@sparted/shared-library 0.0.18 → 1.0.1-O

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