@sparted/shared-library 1.1.2 → 1.1.3

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 (369) hide show
  1. package/.circleci/config.yml +40 -0
  2. package/.eslintignore +1 -0
  3. package/.eslintrc.json +25 -0
  4. package/.gitignore +37 -0
  5. package/.idea/.gitignore +8 -0
  6. package/.idea/codeStyles/Project.xml +35 -0
  7. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  8. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  9. package/.idea/jsLinters/eslint.xml +6 -0
  10. package/.idea/misc.xml +6 -0
  11. package/.idea/modules.xml +8 -0
  12. package/.idea/shared-library.iml +11 -0
  13. package/.idea/vcs.xml +6 -0
  14. package/.idea/workspace.xml +105 -0
  15. package/.prettierrc.json +6 -0
  16. package/CHANGELOG.md +112 -0
  17. package/README.md +26 -0
  18. package/dist/package.json +65 -0
  19. package/global.d.ts +2 -0
  20. package/package.json +1 -1
  21. package/rollup.config.ts +19 -0
  22. package/src/array/__tests__/array-to-map.test.ts +50 -0
  23. package/src/array/__tests__/get-values-from-keys.test.ts +14 -0
  24. package/src/array/__tests__/inner-join.test.ts +55 -0
  25. package/src/array/__tests__/left-outter-join.test.ts +55 -0
  26. package/src/array/array-to-map.ts +32 -0
  27. package/src/array/get-values-from-keys.ts +3 -0
  28. package/src/array/index.ts +4 -0
  29. package/src/array/inner-join.ts +10 -0
  30. package/src/array/left-outter-join.ts +10 -0
  31. package/src/business/picture-spot/index.ts +3 -0
  32. package/src/business/types/content.ts +135 -0
  33. package/src/business/types/index.ts +4 -0
  34. package/src/business/types/media.ts +18 -0
  35. package/src/business/types/multilingual.ts +42 -0
  36. package/src/business/types/thematic.ts +10 -0
  37. package/src/cdn/__tests__/cdn.factory.test.ts +150 -0
  38. package/src/cdn/__tests__/utils.test.ts +528 -0
  39. package/src/cdn/cdn.factory.ts +70 -0
  40. package/src/cdn/index.ts +2 -0
  41. package/src/cdn/types/cdn-factory.type.ts +49 -0
  42. package/src/cdn/types/index.ts +1 -0
  43. package/src/cdn/utils/extract-info-from-url.util.ts +25 -0
  44. package/src/cdn/utils/get-cdn-from-s3-url.util.ts +20 -0
  45. package/src/cdn/utils/get-cdn-url.util.ts +31 -0
  46. package/src/cdn/utils/twicpics-transformations.util.ts +9 -0
  47. package/src/color/__tests__/get-contrast-color.test.ts +22 -0
  48. package/src/color/get-contrast-color.ts +18 -0
  49. package/src/color/index.ts +1 -0
  50. package/src/formatting/__tests__/format-number.test.ts +11 -0
  51. package/src/formatting/format-number.ts +14 -0
  52. package/src/formatting/index.ts +1 -0
  53. package/src/fp/__tests__/run-while.test.ts +29 -0
  54. package/src/fp/index.ts +1 -0
  55. package/src/fp/run-while.ts +54 -0
  56. package/src/http/__tests__/build-search-params.test.ts +17 -0
  57. package/src/http/__tests__/encode-search-object.test.ts +34 -0
  58. package/src/http/__tests__/fetch-with-timeout.test.ts +50 -0
  59. package/src/http/build-search-params.ts +18 -0
  60. package/src/http/encode-search-object.ts +39 -0
  61. package/src/http/fetch-with-timeout.ts +24 -0
  62. package/src/http/index.ts +3 -0
  63. package/src/index.ts +15 -0
  64. package/src/linked-list/__tests__/apply-diff-linked-list.test.ts +103 -0
  65. package/src/linked-list/__tests__/create-linked-list.test.ts +204 -0
  66. package/src/linked-list/__tests__/find-linked-list.test.ts +40 -0
  67. package/src/linked-list/__tests__/get-linked-list.test.ts +28 -0
  68. package/src/linked-list/__tests__/insert-linked-list.test.ts +186 -0
  69. package/src/linked-list/__tests__/linked-list-utils.test.ts +252 -0
  70. package/src/linked-list/__tests__/reduce-linked-list.test.ts +31 -0
  71. package/src/linked-list/__tests__/remove-linked-list.test.ts +129 -0
  72. package/src/linked-list/__tests__/update-linked-list.test.ts +53 -0
  73. package/src/linked-list/__tests__/while-linked-list.test.ts +58 -0
  74. package/src/linked-list/apply-diff-linked-list.ts +35 -0
  75. package/src/linked-list/create-linked-list.ts +79 -0
  76. package/src/linked-list/find-linked-list.ts +26 -0
  77. package/src/linked-list/get-linked-list.ts +9 -0
  78. package/src/linked-list/index.ts +2 -0
  79. package/src/linked-list/insert-linked-list.ts +50 -0
  80. package/src/linked-list/linked-list-utils.ts +143 -0
  81. package/src/linked-list/reduce-linked-list.ts +18 -0
  82. package/src/linked-list/remove-linked-list.ts +36 -0
  83. package/src/linked-list/type.ts +38 -0
  84. package/src/linked-list/update-linked-list.ts +30 -0
  85. package/src/linked-list/while-linked-list.ts +33 -0
  86. package/src/math/__tests__/clamp-number.test.ts +30 -0
  87. package/src/math/__tests__/interpolate.test.ts +28 -0
  88. package/src/math/__tests__/median.test.ts +27 -0
  89. package/src/math/__tests__/number-range.test.ts +59 -0
  90. package/src/math/__tests__/random-number.test.ts +11 -0
  91. package/src/math/clamp-number.ts +8 -0
  92. package/src/math/index.ts +5 -0
  93. package/src/math/interpolate.ts +18 -0
  94. package/src/math/median.ts +21 -0
  95. package/src/math/number-range.ts +16 -0
  96. package/src/math/random-number.ts +10 -0
  97. package/src/object/__tests__/merge-deep.test.ts +56 -0
  98. package/src/object/__tests__/strip-properties-from-object.test.ts +65 -0
  99. package/src/object/index.ts +2 -0
  100. package/src/object/merge-deep.ts +26 -0
  101. package/src/object/strip-properties-from-object.ts +26 -0
  102. package/src/parsing/__tests__/parse-boolean.test.ts +15 -0
  103. package/src/parsing/__tests__/parse-enum.test.ts +19 -0
  104. package/src/parsing/__tests__/parse-number.test.ts +20 -0
  105. package/src/parsing/index.ts +3 -0
  106. package/src/parsing/parse-boolean.ts +10 -0
  107. package/src/parsing/parse-enum.ts +16 -0
  108. package/src/parsing/parse-number.ts +12 -0
  109. package/src/predicates/__tests__/is-function.test.ts +11 -0
  110. package/src/predicates/__tests__/is-null.test.ts +11 -0
  111. package/src/predicates/__tests__/is-object.test.ts +11 -0
  112. package/src/predicates/__tests__/is-primitive.test.ts +42 -0
  113. package/src/predicates/__tests__/is-undefined.test.ts +11 -0
  114. package/src/predicates/__tests__/is-uuid.test.ts +13 -0
  115. package/src/predicates/index.ts +5 -0
  116. package/src/predicates/is-function.ts +3 -0
  117. package/src/predicates/is-null.ts +1 -0
  118. package/src/predicates/is-object.ts +3 -0
  119. package/src/predicates/is-primitive.ts +19 -0
  120. package/src/predicates/is-undefined.ts +3 -0
  121. package/src/predicates/is-uuid.ts +3 -0
  122. package/src/promise/__tests__/delay.test.ts +13 -0
  123. package/src/promise/__tests__/execute-or-resolve-default.test.ts +25 -0
  124. package/src/promise/__tests__/execute-with-delay.test.ts +24 -0
  125. package/src/promise/delay.ts +3 -0
  126. package/src/promise/execute-or-resolve-default.ts +14 -0
  127. package/src/promise/execute-with-delay.ts +6 -0
  128. package/src/promise/index.ts +3 -0
  129. package/src/string/__tests__/is-string-length-within-range.test.ts +23 -0
  130. package/src/string/__tests__/replace-in-template.test.ts +52 -0
  131. package/src/string/index.ts +2 -0
  132. package/src/string/is-string-length-within-range.ts +10 -0
  133. package/src/string/replace-in-template.ts +45 -0
  134. package/src/time/__tests__/convert.test.ts +14 -0
  135. package/src/time/__tests__/format-minutes.test.ts +10 -0
  136. package/src/time/__tests__/get-time-diff-as-string.test.ts +128 -0
  137. package/src/time/constants.ts +4 -0
  138. package/src/time/convert.ts +5 -0
  139. package/src/time/format-minutes.ts +9 -0
  140. package/src/time/get-time-diff-as-string.ts +196 -0
  141. package/src/time/index.ts +4 -0
  142. package/src/types/function.ts +1 -0
  143. package/src/types/general.ts +15 -0
  144. package/src/types/index.ts +4 -0
  145. package/src/types/object.ts +33 -0
  146. package/src/types/search.ts +29 -0
  147. package/tsconfig.json +25 -0
  148. package/yarn.lock +4040 -0
  149. /package/{_virtual → dist/_virtual}/_tslib.js +0 -0
  150. /package/{_virtual → dist/_virtual}/_tslib.js.map +0 -0
  151. /package/{array → dist/array}/array-to-map.d.ts +0 -0
  152. /package/{array → dist/array}/array-to-map.js +0 -0
  153. /package/{array → dist/array}/array-to-map.js.map +0 -0
  154. /package/{array → dist/array}/get-values-from-keys.d.ts +0 -0
  155. /package/{array → dist/array}/get-values-from-keys.js +0 -0
  156. /package/{array → dist/array}/get-values-from-keys.js.map +0 -0
  157. /package/{array → dist/array}/index.d.ts +0 -0
  158. /package/{array → dist/array}/index.js +0 -0
  159. /package/{array → dist/array}/index.js.map +0 -0
  160. /package/{array → dist/array}/inner-join.d.ts +0 -0
  161. /package/{array → dist/array}/inner-join.js +0 -0
  162. /package/{array → dist/array}/inner-join.js.map +0 -0
  163. /package/{array → dist/array}/left-outter-join.d.ts +0 -0
  164. /package/{array → dist/array}/left-outter-join.js +0 -0
  165. /package/{array → dist/array}/left-outter-join.js.map +0 -0
  166. /package/{business → dist/business}/picture-spot/index.d.ts +0 -0
  167. /package/{business → dist/business}/picture-spot/index.js +0 -0
  168. /package/{business → dist/business}/picture-spot/index.js.map +0 -0
  169. /package/{business → dist/business}/types/content.d.ts +0 -0
  170. /package/{business → dist/business}/types/content.js +0 -0
  171. /package/{business → dist/business}/types/content.js.map +0 -0
  172. /package/{business → dist/business}/types/index.d.ts +0 -0
  173. /package/{business → dist/business}/types/index.js +0 -0
  174. /package/{business → dist/business}/types/index.js.map +0 -0
  175. /package/{business → dist/business}/types/media.d.ts +0 -0
  176. /package/{business → dist/business}/types/multilingual.d.ts +0 -0
  177. /package/{business → dist/business}/types/multilingual.js +0 -0
  178. /package/{business → dist/business}/types/multilingual.js.map +0 -0
  179. /package/{business → dist/business}/types/thematic.d.ts +0 -0
  180. /package/{cdn → dist/cdn}/cdn.factory.d.ts +0 -0
  181. /package/{cdn → dist/cdn}/cdn.factory.js +0 -0
  182. /package/{cdn → dist/cdn}/cdn.factory.js.map +0 -0
  183. /package/{cdn → dist/cdn}/index.d.ts +0 -0
  184. /package/{cdn → dist/cdn}/index.js +0 -0
  185. /package/{cdn → dist/cdn}/index.js.map +0 -0
  186. /package/{cdn → dist/cdn}/types/cdn-factory.type.d.ts +0 -0
  187. /package/{cdn → dist/cdn}/types/index.d.ts +0 -0
  188. /package/{cdn → dist/cdn}/types/index.js +0 -0
  189. /package/{cdn → dist/cdn}/types/index.js.map +0 -0
  190. /package/{cdn → dist/cdn}/utils/extract-info-from-url.util.d.ts +0 -0
  191. /package/{cdn → dist/cdn}/utils/extract-info-from-url.util.js +0 -0
  192. /package/{cdn → dist/cdn}/utils/extract-info-from-url.util.js.map +0 -0
  193. /package/{cdn → dist/cdn}/utils/get-cdn-from-s3-url.util.d.ts +0 -0
  194. /package/{cdn → dist/cdn}/utils/get-cdn-from-s3-url.util.js +0 -0
  195. /package/{cdn → dist/cdn}/utils/get-cdn-from-s3-url.util.js.map +0 -0
  196. /package/{cdn → dist/cdn}/utils/get-cdn-url.util.d.ts +0 -0
  197. /package/{cdn → dist/cdn}/utils/get-cdn-url.util.js +0 -0
  198. /package/{cdn → dist/cdn}/utils/get-cdn-url.util.js.map +0 -0
  199. /package/{cdn → dist/cdn}/utils/twicpics-transformations.util.d.ts +0 -0
  200. /package/{cdn → dist/cdn}/utils/twicpics-transformations.util.js +0 -0
  201. /package/{cdn → dist/cdn}/utils/twicpics-transformations.util.js.map +0 -0
  202. /package/{color → dist/color}/get-contrast-color.d.ts +0 -0
  203. /package/{color → dist/color}/get-contrast-color.js +0 -0
  204. /package/{color → dist/color}/get-contrast-color.js.map +0 -0
  205. /package/{color → dist/color}/index.d.ts +0 -0
  206. /package/{color → dist/color}/index.js +0 -0
  207. /package/{color → dist/color}/index.js.map +0 -0
  208. /package/{formatting → dist/formatting}/format-number.d.ts +0 -0
  209. /package/{formatting → dist/formatting}/format-number.js +0 -0
  210. /package/{formatting → dist/formatting}/format-number.js.map +0 -0
  211. /package/{formatting → dist/formatting}/index.d.ts +0 -0
  212. /package/{formatting → dist/formatting}/index.js +0 -0
  213. /package/{formatting → dist/formatting}/index.js.map +0 -0
  214. /package/{fp → dist/fp}/index.d.ts +0 -0
  215. /package/{fp → dist/fp}/index.js +0 -0
  216. /package/{fp → dist/fp}/index.js.map +0 -0
  217. /package/{fp → dist/fp}/run-while.d.ts +0 -0
  218. /package/{fp → dist/fp}/run-while.js +0 -0
  219. /package/{fp → dist/fp}/run-while.js.map +0 -0
  220. /package/{http → dist/http}/build-search-params.d.ts +0 -0
  221. /package/{http → dist/http}/build-search-params.js +0 -0
  222. /package/{http → dist/http}/build-search-params.js.map +0 -0
  223. /package/{http → dist/http}/encode-search-object.d.ts +0 -0
  224. /package/{http → dist/http}/encode-search-object.js +0 -0
  225. /package/{http → dist/http}/encode-search-object.js.map +0 -0
  226. /package/{http → dist/http}/fetch-with-timeout.d.ts +0 -0
  227. /package/{http → dist/http}/fetch-with-timeout.js +0 -0
  228. /package/{http → dist/http}/fetch-with-timeout.js.map +0 -0
  229. /package/{http → dist/http}/index.d.ts +0 -0
  230. /package/{http → dist/http}/index.js +0 -0
  231. /package/{http → dist/http}/index.js.map +0 -0
  232. /package/{index.d.ts → dist/index.d.ts} +0 -0
  233. /package/{index.js → dist/index.js} +0 -0
  234. /package/{index.js.map → dist/index.js.map} +0 -0
  235. /package/{linked-list → dist/linked-list}/apply-diff-linked-list.d.ts +0 -0
  236. /package/{linked-list → dist/linked-list}/apply-diff-linked-list.js +0 -0
  237. /package/{linked-list → dist/linked-list}/apply-diff-linked-list.js.map +0 -0
  238. /package/{linked-list → dist/linked-list}/create-linked-list.d.ts +0 -0
  239. /package/{linked-list → dist/linked-list}/create-linked-list.js +0 -0
  240. /package/{linked-list → dist/linked-list}/create-linked-list.js.map +0 -0
  241. /package/{linked-list → dist/linked-list}/find-linked-list.d.ts +0 -0
  242. /package/{linked-list → dist/linked-list}/find-linked-list.js +0 -0
  243. /package/{linked-list → dist/linked-list}/find-linked-list.js.map +0 -0
  244. /package/{linked-list → dist/linked-list}/get-linked-list.d.ts +0 -0
  245. /package/{linked-list → dist/linked-list}/get-linked-list.js +0 -0
  246. /package/{linked-list → dist/linked-list}/get-linked-list.js.map +0 -0
  247. /package/{linked-list → dist/linked-list}/index.d.ts +0 -0
  248. /package/{linked-list → dist/linked-list}/index.js +0 -0
  249. /package/{linked-list → dist/linked-list}/index.js.map +0 -0
  250. /package/{linked-list → dist/linked-list}/insert-linked-list.d.ts +0 -0
  251. /package/{linked-list → dist/linked-list}/insert-linked-list.js +0 -0
  252. /package/{linked-list → dist/linked-list}/insert-linked-list.js.map +0 -0
  253. /package/{linked-list → dist/linked-list}/linked-list-utils.d.ts +0 -0
  254. /package/{linked-list → dist/linked-list}/linked-list-utils.js +0 -0
  255. /package/{linked-list → dist/linked-list}/linked-list-utils.js.map +0 -0
  256. /package/{linked-list → dist/linked-list}/reduce-linked-list.d.ts +0 -0
  257. /package/{linked-list → dist/linked-list}/reduce-linked-list.js +0 -0
  258. /package/{linked-list → dist/linked-list}/reduce-linked-list.js.map +0 -0
  259. /package/{linked-list → dist/linked-list}/remove-linked-list.d.ts +0 -0
  260. /package/{linked-list → dist/linked-list}/remove-linked-list.js +0 -0
  261. /package/{linked-list → dist/linked-list}/remove-linked-list.js.map +0 -0
  262. /package/{linked-list → dist/linked-list}/type.d.ts +0 -0
  263. /package/{linked-list → dist/linked-list}/update-linked-list.d.ts +0 -0
  264. /package/{linked-list → dist/linked-list}/update-linked-list.js +0 -0
  265. /package/{linked-list → dist/linked-list}/update-linked-list.js.map +0 -0
  266. /package/{linked-list → dist/linked-list}/while-linked-list.d.ts +0 -0
  267. /package/{linked-list → dist/linked-list}/while-linked-list.js +0 -0
  268. /package/{linked-list → dist/linked-list}/while-linked-list.js.map +0 -0
  269. /package/{math → dist/math}/clamp-number.d.ts +0 -0
  270. /package/{math → dist/math}/clamp-number.js +0 -0
  271. /package/{math → dist/math}/clamp-number.js.map +0 -0
  272. /package/{math → dist/math}/index.d.ts +0 -0
  273. /package/{math → dist/math}/index.js +0 -0
  274. /package/{math → dist/math}/index.js.map +0 -0
  275. /package/{math → dist/math}/interpolate.d.ts +0 -0
  276. /package/{math → dist/math}/interpolate.js +0 -0
  277. /package/{math → dist/math}/interpolate.js.map +0 -0
  278. /package/{math → dist/math}/median.d.ts +0 -0
  279. /package/{math → dist/math}/median.js +0 -0
  280. /package/{math → dist/math}/median.js.map +0 -0
  281. /package/{math → dist/math}/number-range.d.ts +0 -0
  282. /package/{math → dist/math}/number-range.js +0 -0
  283. /package/{math → dist/math}/number-range.js.map +0 -0
  284. /package/{math → dist/math}/random-number.d.ts +0 -0
  285. /package/{math → dist/math}/random-number.js +0 -0
  286. /package/{math → dist/math}/random-number.js.map +0 -0
  287. /package/{object → dist/object}/index.d.ts +0 -0
  288. /package/{object → dist/object}/index.js +0 -0
  289. /package/{object → dist/object}/index.js.map +0 -0
  290. /package/{object → dist/object}/merge-deep.d.ts +0 -0
  291. /package/{object → dist/object}/merge-deep.js +0 -0
  292. /package/{object → dist/object}/merge-deep.js.map +0 -0
  293. /package/{object → dist/object}/strip-properties-from-object.d.ts +0 -0
  294. /package/{object → dist/object}/strip-properties-from-object.js +0 -0
  295. /package/{object → dist/object}/strip-properties-from-object.js.map +0 -0
  296. /package/{parsing → dist/parsing}/index.d.ts +0 -0
  297. /package/{parsing → dist/parsing}/index.js +0 -0
  298. /package/{parsing → dist/parsing}/index.js.map +0 -0
  299. /package/{parsing → dist/parsing}/parse-boolean.d.ts +0 -0
  300. /package/{parsing → dist/parsing}/parse-boolean.js +0 -0
  301. /package/{parsing → dist/parsing}/parse-boolean.js.map +0 -0
  302. /package/{parsing → dist/parsing}/parse-enum.d.ts +0 -0
  303. /package/{parsing → dist/parsing}/parse-enum.js +0 -0
  304. /package/{parsing → dist/parsing}/parse-enum.js.map +0 -0
  305. /package/{parsing → dist/parsing}/parse-number.d.ts +0 -0
  306. /package/{parsing → dist/parsing}/parse-number.js +0 -0
  307. /package/{parsing → dist/parsing}/parse-number.js.map +0 -0
  308. /package/{predicates → dist/predicates}/index.d.ts +0 -0
  309. /package/{predicates → dist/predicates}/index.js +0 -0
  310. /package/{predicates → dist/predicates}/index.js.map +0 -0
  311. /package/{predicates → dist/predicates}/is-function.d.ts +0 -0
  312. /package/{predicates → dist/predicates}/is-function.js +0 -0
  313. /package/{predicates → dist/predicates}/is-function.js.map +0 -0
  314. /package/{predicates → dist/predicates}/is-null.d.ts +0 -0
  315. /package/{predicates → dist/predicates}/is-null.js +0 -0
  316. /package/{predicates → dist/predicates}/is-null.js.map +0 -0
  317. /package/{predicates → dist/predicates}/is-object.d.ts +0 -0
  318. /package/{predicates → dist/predicates}/is-object.js +0 -0
  319. /package/{predicates → dist/predicates}/is-object.js.map +0 -0
  320. /package/{predicates → dist/predicates}/is-primitive.d.ts +0 -0
  321. /package/{predicates → dist/predicates}/is-primitive.js +0 -0
  322. /package/{predicates → dist/predicates}/is-primitive.js.map +0 -0
  323. /package/{predicates → dist/predicates}/is-undefined.d.ts +0 -0
  324. /package/{predicates → dist/predicates}/is-undefined.js +0 -0
  325. /package/{predicates → dist/predicates}/is-undefined.js.map +0 -0
  326. /package/{predicates → dist/predicates}/is-uuid.d.ts +0 -0
  327. /package/{promise → dist/promise}/delay.d.ts +0 -0
  328. /package/{promise → dist/promise}/delay.js +0 -0
  329. /package/{promise → dist/promise}/delay.js.map +0 -0
  330. /package/{promise → dist/promise}/execute-or-resolve-default.d.ts +0 -0
  331. /package/{promise → dist/promise}/execute-or-resolve-default.js +0 -0
  332. /package/{promise → dist/promise}/execute-or-resolve-default.js.map +0 -0
  333. /package/{promise → dist/promise}/execute-with-delay.d.ts +0 -0
  334. /package/{promise → dist/promise}/execute-with-delay.js +0 -0
  335. /package/{promise → dist/promise}/execute-with-delay.js.map +0 -0
  336. /package/{promise → dist/promise}/index.d.ts +0 -0
  337. /package/{promise → dist/promise}/index.js +0 -0
  338. /package/{promise → dist/promise}/index.js.map +0 -0
  339. /package/{string → dist/string}/index.d.ts +0 -0
  340. /package/{string → dist/string}/index.js +0 -0
  341. /package/{string → dist/string}/index.js.map +0 -0
  342. /package/{string → dist/string}/is-string-length-within-range.d.ts +0 -0
  343. /package/{string → dist/string}/is-string-length-within-range.js +0 -0
  344. /package/{string → dist/string}/is-string-length-within-range.js.map +0 -0
  345. /package/{string → dist/string}/replace-in-template.d.ts +0 -0
  346. /package/{string → dist/string}/replace-in-template.js +0 -0
  347. /package/{string → dist/string}/replace-in-template.js.map +0 -0
  348. /package/{time → dist/time}/constants.d.ts +0 -0
  349. /package/{time → dist/time}/constants.js +0 -0
  350. /package/{time → dist/time}/constants.js.map +0 -0
  351. /package/{time → dist/time}/convert.d.ts +0 -0
  352. /package/{time → dist/time}/convert.js +0 -0
  353. /package/{time → dist/time}/convert.js.map +0 -0
  354. /package/{time → dist/time}/format-minutes.d.ts +0 -0
  355. /package/{time → dist/time}/format-minutes.js +0 -0
  356. /package/{time → dist/time}/format-minutes.js.map +0 -0
  357. /package/{time → dist/time}/get-time-diff-as-string.d.ts +0 -0
  358. /package/{time → dist/time}/get-time-diff-as-string.js +0 -0
  359. /package/{time → dist/time}/get-time-diff-as-string.js.map +0 -0
  360. /package/{time → dist/time}/index.d.ts +0 -0
  361. /package/{time → dist/time}/index.js +0 -0
  362. /package/{time → dist/time}/index.js.map +0 -0
  363. /package/{types → dist/types}/function.d.ts +0 -0
  364. /package/{types → dist/types}/general.d.ts +0 -0
  365. /package/{types → dist/types}/index.d.ts +0 -0
  366. /package/{types → dist/types}/index.js +0 -0
  367. /package/{types → dist/types}/index.js.map +0 -0
  368. /package/{types → dist/types}/object.d.ts +0 -0
  369. /package/{types → dist/types}/search.d.ts +0 -0
@@ -0,0 +1,40 @@
1
+ # Javascript Node CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-javascript/ for more details
4
+ #
5
+ version: 2.1
6
+ jobs:
7
+ test:
8
+ docker:
9
+ - image: cimg/node:18.10.0
10
+
11
+ steps:
12
+ - checkout
13
+
14
+ - run:
15
+ name: Set npm token
16
+ command: 'echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc'
17
+
18
+ - run:
19
+ name: Install node modules
20
+ command: yarn
21
+
22
+ - run:
23
+ name: Check lint
24
+ command: yarn lint
25
+
26
+ - run:
27
+ name: Run tests
28
+ # Limit resources as the default parameters overload the CPU of the machine and makes tests hang
29
+ command: yarn test --maxWorkers=50%
30
+
31
+ - run:
32
+ name: Build
33
+ command: yarn build
34
+
35
+ workflows:
36
+ version: 2
37
+
38
+ autodeploy:
39
+ jobs:
40
+ - test
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ dist/
package/.eslintrc.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "env": {
3
+ "es2021": true,
4
+ "node": true
5
+ },
6
+ "plugins": [
7
+ "@typescript-eslint",
8
+ "prettier",
9
+ "import"
10
+ ],
11
+ "extends": [
12
+ "eslint:recommended",
13
+ "plugin:@typescript-eslint/recommended",
14
+ "plugin:import/recommended",
15
+ "plugin:import/typescript",
16
+ "prettier"
17
+ ],
18
+ "parser": "@typescript-eslint/parser",
19
+ "rules": {
20
+ "prettier/prettier": "warn",
21
+ "@typescript-eslint/no-explicit-any": "warn",
22
+ "@typescript-eslint/ban-types": "warn",
23
+ "@typescript-eslint/ban-ts-comment": "warn"
24
+ }
25
+ }
package/.gitignore ADDED
@@ -0,0 +1,37 @@
1
+ *.dat
2
+ *.iml
3
+ *.log
4
+ *.out
5
+ *.pid
6
+ *.seed
7
+ *.sublime-*
8
+ *.swo
9
+ *.swp
10
+ *.tgz
11
+ *.xml
12
+ .tmp
13
+ .env
14
+ doc/*.json
15
+
16
+ # Mac Related files
17
+ .DS_Store
18
+
19
+ # IDE Related Files
20
+ .idea
21
+ .project
22
+
23
+ # eslint
24
+ .eslintcache
25
+
26
+ # jest
27
+ jest-stare
28
+
29
+ # JS Related files
30
+ bower_components
31
+ npm-debug.log
32
+ node_modules
33
+ nestjs/node_modules
34
+ .npmrc
35
+
36
+ # Build
37
+ dist
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
@@ -0,0 +1,35 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <code_scheme name="Project" version="173">
3
+ <JSCodeStyleSettings version="0">
4
+ <option name="VAR_DECLARATION_WRAP" value="2" />
5
+ <option name="OBJECT_LITERAL_WRAP" value="2" />
6
+ </JSCodeStyleSettings>
7
+ <TypeScriptCodeStyleSettings version="0">
8
+ <option name="VAR_DECLARATION_WRAP" value="2" />
9
+ <option name="OBJECT_LITERAL_WRAP" value="2" />
10
+ </TypeScriptCodeStyleSettings>
11
+ <codeStyleSettings language="JavaScript">
12
+ <option name="BLOCK_COMMENT_ADD_SPACE" value="true" />
13
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
14
+ <option name="METHOD_CALL_CHAIN_WRAP" value="2" />
15
+ <option name="IF_BRACE_FORCE" value="1" />
16
+ <option name="DOWHILE_BRACE_FORCE" value="1" />
17
+ <option name="WHILE_BRACE_FORCE" value="1" />
18
+ <option name="FOR_BRACE_FORCE" value="1" />
19
+ </codeStyleSettings>
20
+ <codeStyleSettings language="TypeScript">
21
+ <option name="BLOCK_COMMENT_ADD_SPACE" value="true" />
22
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
23
+ <option name="METHOD_CALL_CHAIN_WRAP" value="2" />
24
+ <option name="IF_BRACE_FORCE" value="1" />
25
+ <option name="DOWHILE_BRACE_FORCE" value="1" />
26
+ <option name="WHILE_BRACE_FORCE" value="1" />
27
+ <option name="FOR_BRACE_FORCE" value="1" />
28
+ <indentOptions>
29
+ <option name="INDENT_SIZE" value="2" />
30
+ <option name="CONTINUATION_INDENT_SIZE" value="2" />
31
+ <option name="TAB_SIZE" value="2" />
32
+ </indentOptions>
33
+ </codeStyleSettings>
34
+ </code_scheme>
35
+ </component>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
+ </profile>
6
+ </component>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="EslintConfiguration">
4
+ <option name="fix-on-save" value="true" />
5
+ </component>
6
+ </project>
package/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager">
4
+ <output url="file://$PROJECT_DIR$/out" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/shared-library.iml" filepath="$PROJECT_DIR$/.idea/shared-library.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$">
6
+ <excludeFolder url="file://$MODULE_DIR$/dist" />
7
+ </content>
8
+ <orderEntry type="inheritedJdk" />
9
+ <orderEntry type="sourceFolder" forTests="false" />
10
+ </component>
11
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,105 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AutoImportSettings">
4
+ <option name="autoReloadType" value="SELECTIVE" />
5
+ </component>
6
+ <component name="ChangeListManager">
7
+ <list default="true" id="9c51afc7-3a2a-462c-a7b1-b3e0ca474b0c" name="Changes" comment="">
8
+ <change afterPath="$PROJECT_DIR$/src/business/no-interaction/index.ts" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/src/business/picture-spot/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/business/picture-spot/index.ts" afterDir="false" />
10
+ </list>
11
+ <option name="SHOW_DIALOG" value="false" />
12
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
13
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
14
+ <option name="LAST_RESOLUTION" value="IGNORE" />
15
+ </component>
16
+ <component name="Git.Settings">
17
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
18
+ </component>
19
+ <component name="GoLibraries">
20
+ <option name="indexEntireGoPath" value="true" />
21
+ </component>
22
+ <component name="MarkdownSettingsMigration">
23
+ <option name="stateVersion" value="1" />
24
+ </component>
25
+ <component name="ProjectId" id="2LBBaAUnkGvlewEioyoXgDTb3Rx" />
26
+ <component name="ProjectLevelVcsManager">
27
+ <ConfirmationsSetting value="2" id="Add" />
28
+ </component>
29
+ <component name="ProjectViewState">
30
+ <option name="autoscrollFromSource" value="true" />
31
+ <option name="hideEmptyMiddlePackages" value="true" />
32
+ <option name="showLibraryContents" value="true" />
33
+ </component>
34
+ <component name="PropertiesComponent">{
35
+ &quot;keyToString&quot;: {
36
+ &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
37
+ &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
38
+ &quot;RunOnceActivity.go.formatter.settings.were.checked&quot;: &quot;true&quot;,
39
+ &quot;RunOnceActivity.go.migrated.go.modules.settings&quot;: &quot;true&quot;,
40
+ &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
41
+ &quot;dart.analysis.tool.window.visible&quot;: &quot;false&quot;,
42
+ &quot;git-widget-placeholder&quot;: &quot;master&quot;,
43
+ &quot;go.import.settings.migrated&quot;: &quot;true&quot;,
44
+ &quot;last_opened_file_path&quot;: &quot;/Users/cchampou/dev/shared-library&quot;,
45
+ &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
46
+ &quot;node.js.detected.package.standard&quot;: &quot;true&quot;,
47
+ &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
48
+ &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
49
+ &quot;node.js.selected.package.standard&quot;: &quot;&quot;,
50
+ &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
51
+ &quot;nodejs_package_manager_path&quot;: &quot;yarn&quot;,
52
+ &quot;settings.editor.selected.configurable&quot;: &quot;settings.javascript.linters.eslint&quot;,
53
+ &quot;show.migrate.to.gradle.popup&quot;: &quot;false&quot;,
54
+ &quot;ts.external.directory.path&quot;: &quot;/Users/cchampou/dev/shared-library/node_modules/typescript/lib&quot;,
55
+ &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
56
+ }
57
+ }</component>
58
+ <component name="RecentsManager">
59
+ <key name="MoveFile.RECENT_KEYS">
60
+ <recent name="$PROJECT_DIR$/src/business/types" />
61
+ <recent name="$PROJECT_DIR$/src/types/business" />
62
+ <recent name="$PROJECT_DIR$/src/business" />
63
+ <recent name="$PROJECT_DIR$/src/types" />
64
+ </key>
65
+ </component>
66
+ <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
67
+ <component name="TaskManager">
68
+ <task active="true" id="Default" summary="Default task">
69
+ <changelist id="9c51afc7-3a2a-462c-a7b1-b3e0ca474b0c" name="Changes" comment="" />
70
+ <created>1675334656680</created>
71
+ <option name="number" value="Default" />
72
+ <option name="presentableId" value="Default" />
73
+ <updated>1675334656680</updated>
74
+ <workItem from="1675334657881" duration="9370000" />
75
+ <workItem from="1675413502042" duration="3448000" />
76
+ <workItem from="1675777811478" duration="2023000" />
77
+ <workItem from="1676048809145" duration="1369000" />
78
+ <workItem from="1676285644197" duration="9643000" />
79
+ <workItem from="1676390431531" duration="720000" />
80
+ <workItem from="1677080847564" duration="1233000" />
81
+ <workItem from="1679044878990" duration="2004000" />
82
+ <workItem from="1689058230559" duration="5032000" />
83
+ <workItem from="1692285159365" duration="2040000" />
84
+ <workItem from="1692345932803" duration="2572000" />
85
+ <workItem from="1692883384801" duration="809000" />
86
+ <workItem from="1704897952885" duration="6308000" />
87
+ <workItem from="1704980905659" duration="3963000" />
88
+ <workItem from="1705481044854" duration="2558000" />
89
+ <workItem from="1706005322333" duration="2222000" />
90
+ <workItem from="1706026800654" duration="819000" />
91
+ </task>
92
+ <servers />
93
+ </component>
94
+ <component name="TypeScriptGeneratedFilesManager">
95
+ <option name="version" value="3" />
96
+ </component>
97
+ <component name="VgoProject">
98
+ <integration-enabled>false</integration-enabled>
99
+ <settings-migrated>true</settings-migrated>
100
+ </component>
101
+ <component name="XSLT-Support.FileAssociations.UIState">
102
+ <expand />
103
+ <select />
104
+ </component>
105
+ </project>
@@ -0,0 +1,6 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": true,
4
+ "trailingComma": "all",
5
+ "printWidth": 120
6
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,112 @@
1
+ ## 1.1.3
2
+ - Fix multilingual type adding partial
3
+
4
+ ## 1.1.2
5
+ - Add Gameplay type guards
6
+
7
+ ## 1.1.1
8
+ - Fix publication issue
9
+
10
+ ## 1.1.0
11
+ - Add business entities types
12
+
13
+ ## 1.0.29
14
+ - Add `getContrastColor` function
15
+
16
+ ## 1.0.28
17
+ - Fix `twicpicsTransformationQueries` function to have integer values
18
+
19
+ ## 1.0.27
20
+ - Add `isStringLengthWithinRange` function
21
+
22
+ ## 1.0.26
23
+ - Add `innerJoin` to `index.ts`
24
+
25
+ ## 1.0.25
26
+ - Add `innerJoin` function for arrays
27
+ - Modify `leftOutterJoin` function implementation
28
+
29
+ ## 1.0.24
30
+ - Add `leftOutterJoin` function for arrays
31
+
32
+ ## 1.0.23
33
+ - Add ability to define constructor params in `ClassType`
34
+
35
+ ## 1.0.22
36
+ - Fix `stripPropertiesFromObject` issue with null values
37
+
38
+ ## 1.0.21
39
+ - Fix exports from `object` directory
40
+
41
+ ## 1.0.20
42
+ - Add `stripPropertiesFromObject` function
43
+
44
+ ## 1.0.19
45
+ - Fix export `median` function
46
+
47
+ ## 1.0.18
48
+ - Add math `median` function
49
+
50
+ ## 1.0.17
51
+ - Handle device pixel ratio (DPR) in Twicpics transformations
52
+
53
+ ## 1.0.16
54
+ - Set twicpics image quality to 90
55
+
56
+ ## 1.0.15
57
+ - Handle only width or only height in twicpics transformations
58
+
59
+ ## 1.0.14
60
+ - Fix: bad tarball published
61
+
62
+ ## 1.0.13
63
+ - Add output format query param
64
+
65
+ ## 1.0.12
66
+ - Add cache version query param
67
+
68
+ ## 1.0.11
69
+ - Add valueOf type
70
+
71
+ ## 1.0.10
72
+
73
+ ## 1.0.9
74
+ - Add option to remove image compression
75
+
76
+ ## 1.0.8
77
+ - Fix crash when passing undefined to extractInfoFromUrl function
78
+
79
+ ## 1.0.7
80
+ - Fix Twicpics resizing
81
+
82
+ ## 1.0.6
83
+ - Add current map to `dataModifier` function on `arrayToMap`
84
+
85
+ ## 1.0.5
86
+ - CDN abstraction for Imgix and Twicpics
87
+
88
+ ## 1.0.0
89
+ - Breaking change: rename date folder into time
90
+ - Export convertion functions from time
91
+
92
+ ## 0.0.18
93
+ - Change update behavior to fully replace updated items
94
+
95
+ ## 0.0.17
96
+ - Remove error thrown when not every items have been visisted
97
+
98
+ ## 0.0.16
99
+ - Fix an issue when initializing an empty linked list
100
+
101
+ ## 0.0.15
102
+ - Rollback target version, change output format
103
+
104
+ ## 0.0.14
105
+ - Bump target version in tsconfig
106
+
107
+ ## 0.0.13
108
+ - Bring most utilities from the back-office, mobile-app and nest to this package (#32q6ude)
109
+
110
+ ## 0.0.1
111
+ - Library initialisation (#2ykhvcg)
112
+ - Fix files taken as packaged
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Shared-library
2
+
3
+ Regroup low levels utils to share across Sparted's projects. Nothing should be platform specific and it should ideally not depend on any external library.
4
+
5
+ # Publishing
6
+
7
+ Since we want to be able to do the following sub imports when using the library:
8
+
9
+ ```ts
10
+ import { function1, function2 } from '@sparted/shared-library/array';
11
+ import { function3, function4 } from '@sparted/shared-library/strings';
12
+ ```
13
+
14
+ While also being able to import everything from the root.
15
+
16
+ We'll need to do some rollup/npm trickery to keep everything tree-shakable and intuitive.
17
+
18
+ To do so, we copy the package.json inside the generated dist folder when building the library. Then we run `npm publish` from inside the dist folder.
19
+
20
+ What this do, is take everything inside the dist folder and publish as its standalone package. This enables us to import directly from `@sparted/shared-library/array` without adding `dist` since `dist/array` becomes a root folder. If we do not do this and instead run `npm publish` in the root directory, the package would keep the folder structure and we would need to add `dist` in imports. eg: `@sparted/shared-library/dist/array`.
21
+
22
+ ## How to publish
23
+
24
+ 1. Update the `package.json` version
25
+ 2. Run `yarn build-and-publish` (this command assumes the `package.json` version was not already published)
26
+ 3. The new version should be commited and pushed
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@sparted/shared-library",
3
+ "version": "1.1.2",
4
+ "repository": "git@github.com:Sparted/shared-library.git",
5
+ "author": {
6
+ "name": "Sparted",
7
+ "email": "developer@sparted.com",
8
+ "url": "https://www.sparted.com"
9
+ },
10
+ "license": "MIT",
11
+ "module": "index.js",
12
+ "main": "index.js",
13
+ "files": [
14
+ "**/*",
15
+ "**/**"
16
+ ],
17
+ "scripts": {
18
+ "test": "jest",
19
+ "lint": "eslint .",
20
+ "clean": "rm -rf ./dist",
21
+ "build": "yarn clean && rollup --config rollup.config.ts --configPlugin typescript2 && cp package.json ./dist/package.json",
22
+ "build-and-publish": "yarn test && yarn build && (cd ./dist && yarn publish)"
23
+ },
24
+ "devDependencies": {
25
+ "@types/glob": "^8.0.0",
26
+ "@types/jest": "^29.0.3",
27
+ "@types/ungap__structured-clone": "^0.3.0",
28
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
29
+ "@typescript-eslint/parser": "^6.0.0",
30
+ "eslint": "^7.32.0",
31
+ "eslint-config-prettier": "^8.8.0",
32
+ "eslint-plugin-import": "^2.27.5",
33
+ "eslint-plugin-prettier": "^4.2.1",
34
+ "glob": "^8.0.3",
35
+ "jest": "^29.6.1",
36
+ "jest-environment-jsdom": "^29.0.3",
37
+ "jest-extended": "^3.1.0",
38
+ "jest-fetch-mock": "^3.0.3",
39
+ "prettier": "2",
40
+ "rollup": "^2.79.1",
41
+ "rollup-plugin-typescript2": "^0.34.0",
42
+ "ts-jest": "^29.0.2",
43
+ "tslib": "^2.4.0",
44
+ "typescript": "^4.8.3"
45
+ },
46
+ "jest": {
47
+ "moduleFileExtensions": [
48
+ "js",
49
+ "ts"
50
+ ],
51
+ "setupFilesAfterEnv": [
52
+ "jest-extended/all"
53
+ ],
54
+ "rootDir": ".",
55
+ "testRegex": [
56
+ ".*\\.test\\.ts$"
57
+ ],
58
+ "transform": {
59
+ "^.+\\.(t|j)s$": "ts-jest"
60
+ }
61
+ },
62
+ "dependencies": {
63
+ "@ungap/structured-clone": "^1.2.0"
64
+ }
65
+ }
package/global.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies -- only needed during development
2
+ import 'jest-extended';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparted/shared-library",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "repository": "git@github.com:Sparted/shared-library.git",
5
5
  "author": {
6
6
  "name": "Sparted",
@@ -0,0 +1,19 @@
1
+ import { glob } from 'glob';
2
+ import typescript from 'rollup-plugin-typescript2';
3
+
4
+ export default {
5
+ input: glob.sync('./src/**/index.ts'),
6
+ plugins: [
7
+ typescript({
8
+ exclude: ['**/__tests__', '**/*.test.ts'],
9
+ }),
10
+ ],
11
+ output: [
12
+ {
13
+ dir: 'dist',
14
+ format: 'cjs',
15
+ sourcemap: true,
16
+ preserveModules: true, // Keep directory structure and files
17
+ },
18
+ ],
19
+ };
@@ -0,0 +1,50 @@
1
+ import { arrayToMap } from '../array-to-map';
2
+
3
+ type Item = {
4
+ id: string,
5
+ bar: number,
6
+ };
7
+
8
+ describe('arrayToMap', () => {
9
+ it('should convert array to map with item containing one key', () => {
10
+ const array = [{ id: 'toto' }, { id: 'bonjour' }];
11
+ const map = arrayToMap(array, { selectKey: ({ id }) => id });
12
+
13
+ expect(map).toStrictEqual({
14
+ bonjour: { id: 'bonjour' },
15
+ toto: { id: 'toto' },
16
+ });
17
+ });
18
+
19
+ it('should convert array to map and select right key in item', () => {
20
+ const array = [{ id: 'toto', bar: 1 }, { id: 'bonjour', bar: 2 }];
21
+ const map = arrayToMap(array, { selectKey: ({ bar }) => bar.toString() });
22
+
23
+ expect(map).toStrictEqual({
24
+ 1: { id: 'toto', bar: 1 },
25
+ 2: { id: 'bonjour', bar: 2 },
26
+ });
27
+ });
28
+
29
+ it('should handle data transformation', () => {
30
+ const item1: Item = { id: 'toto', bar: 1 };
31
+ const item2: Item = { id: 'bonjour', bar: 2 };
32
+ const array = [item1, item2];
33
+
34
+ const modifierFn = jest.fn();
35
+ const map = arrayToMap<Item, string>(array, {
36
+ selectKey: ({ bar }) => bar.toString(),
37
+ dataModifier: ({ id }, currentMap) => {
38
+ modifierFn(currentMap);
39
+ return id;
40
+ },
41
+ });
42
+
43
+ expect(modifierFn).toHaveBeenNthCalledWith(1, {});
44
+ expect(modifierFn).toHaveBeenNthCalledWith(2, { 1: 'toto' });
45
+ expect(map).toStrictEqual({
46
+ 1: 'toto',
47
+ 2: 'bonjour',
48
+ });
49
+ });
50
+ });
@@ -0,0 +1,14 @@
1
+ import { valuesFromKeys } from '../get-values-from-keys';
2
+
3
+ describe('valuesFromKeys', () => {
4
+ it('should transform a map to an array with only selected keys', () => {
5
+ const map = {
6
+ uno: 1,
7
+ dos: 2,
8
+ tres: 3,
9
+ quatro: 4,
10
+ };
11
+
12
+ expect(valuesFromKeys(['uno', 'tres'], map)).toStrictEqual([1, 3]);
13
+ });
14
+ });