dce-commonkit 4.4.0

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 (401) hide show
  1. package/.eslintrc.js +93 -0
  2. package/LICENSE +21 -0
  3. package/README.md +2 -0
  4. package/lib/constants/DAY_IN_MS.d.ts +6 -0
  5. package/lib/constants/DAY_IN_MS.js +9 -0
  6. package/lib/constants/DAY_IN_MS.js.map +1 -0
  7. package/lib/constants/HOUR_IN_MS.d.ts +6 -0
  8. package/lib/constants/HOUR_IN_MS.js +9 -0
  9. package/lib/constants/HOUR_IN_MS.js.map +1 -0
  10. package/lib/constants/LOG_REVIEW_GET_LOGS_ROUTE.d.ts +6 -0
  11. package/lib/constants/LOG_REVIEW_GET_LOGS_ROUTE.js +13 -0
  12. package/lib/constants/LOG_REVIEW_GET_LOGS_ROUTE.js.map +1 -0
  13. package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.d.ts +6 -0
  14. package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.js +13 -0
  15. package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.js.map +1 -0
  16. package/lib/constants/LOG_REVIEW_STATUS_ROUTE.d.ts +7 -0
  17. package/lib/constants/LOG_REVIEW_STATUS_ROUTE.js +14 -0
  18. package/lib/constants/LOG_REVIEW_STATUS_ROUTE.js.map +1 -0
  19. package/lib/constants/LOG_ROUTE_PATH.d.ts +6 -0
  20. package/lib/constants/LOG_ROUTE_PATH.js +13 -0
  21. package/lib/constants/LOG_ROUTE_PATH.js.map +1 -0
  22. package/lib/constants/MINUTE_IN_MS.d.ts +6 -0
  23. package/lib/constants/MINUTE_IN_MS.js +9 -0
  24. package/lib/constants/MINUTE_IN_MS.js.map +1 -0
  25. package/lib/constants/ROUTE_PATH_PREFIX.d.ts +6 -0
  26. package/lib/constants/ROUTE_PATH_PREFIX.js +9 -0
  27. package/lib/constants/ROUTE_PATH_PREFIX.js.map +1 -0
  28. package/lib/constants/SELECT_ADMIN_CHECK_ROUTE.d.ts +6 -0
  29. package/lib/constants/SELECT_ADMIN_CHECK_ROUTE.js +9 -0
  30. package/lib/constants/SELECT_ADMIN_CHECK_ROUTE.js.map +1 -0
  31. package/lib/errors/ErrorWithCode.d.ts +9 -0
  32. package/lib/errors/ErrorWithCode.js +33 -0
  33. package/lib/errors/ErrorWithCode.js.map +1 -0
  34. package/lib/helpers/abbreviate.d.ts +10 -0
  35. package/lib/helpers/abbreviate.js +24 -0
  36. package/lib/helpers/abbreviate.js.map +1 -0
  37. package/lib/helpers/abbreviate.test.d.ts +5 -0
  38. package/lib/helpers/abbreviate.test.js +28 -0
  39. package/lib/helpers/abbreviate.test.js.map +1 -0
  40. package/lib/helpers/asyncArrayFunctions/everyAsync.d.ts +13 -0
  41. package/lib/helpers/asyncArrayFunctions/everyAsync.js +81 -0
  42. package/lib/helpers/asyncArrayFunctions/everyAsync.js.map +1 -0
  43. package/lib/helpers/asyncArrayFunctions/everyAsync.test.d.ts +1 -0
  44. package/lib/helpers/asyncArrayFunctions/everyAsync.test.js +219 -0
  45. package/lib/helpers/asyncArrayFunctions/everyAsync.test.js.map +1 -0
  46. package/lib/helpers/asyncArrayFunctions/filterAsync.d.ts +13 -0
  47. package/lib/helpers/asyncArrayFunctions/filterAsync.js +81 -0
  48. package/lib/helpers/asyncArrayFunctions/filterAsync.js.map +1 -0
  49. package/lib/helpers/asyncArrayFunctions/filterAsync.test.d.ts +1 -0
  50. package/lib/helpers/asyncArrayFunctions/filterAsync.test.js +244 -0
  51. package/lib/helpers/asyncArrayFunctions/filterAsync.test.js.map +1 -0
  52. package/lib/helpers/asyncArrayFunctions/forEachAsync.d.ts +10 -0
  53. package/lib/helpers/asyncArrayFunctions/forEachAsync.js +72 -0
  54. package/lib/helpers/asyncArrayFunctions/forEachAsync.js.map +1 -0
  55. package/lib/helpers/asyncArrayFunctions/forEachAsync.test.d.ts +1 -0
  56. package/lib/helpers/asyncArrayFunctions/forEachAsync.test.js +223 -0
  57. package/lib/helpers/asyncArrayFunctions/forEachAsync.test.js.map +1 -0
  58. package/lib/helpers/asyncArrayFunctions/mapAsync.d.ts +11 -0
  59. package/lib/helpers/asyncArrayFunctions/mapAsync.js +77 -0
  60. package/lib/helpers/asyncArrayFunctions/mapAsync.js.map +1 -0
  61. package/lib/helpers/asyncArrayFunctions/mapAsync.test.d.ts +1 -0
  62. package/lib/helpers/asyncArrayFunctions/mapAsync.test.js +219 -0
  63. package/lib/helpers/asyncArrayFunctions/mapAsync.test.js.map +1 -0
  64. package/lib/helpers/asyncArrayFunctions/someAsync.d.ts +13 -0
  65. package/lib/helpers/asyncArrayFunctions/someAsync.js +80 -0
  66. package/lib/helpers/asyncArrayFunctions/someAsync.js.map +1 -0
  67. package/lib/helpers/asyncArrayFunctions/someAsync.test.d.ts +1 -0
  68. package/lib/helpers/asyncArrayFunctions/someAsync.test.js +227 -0
  69. package/lib/helpers/asyncArrayFunctions/someAsync.test.js.map +1 -0
  70. package/lib/helpers/avg.d.ts +8 -0
  71. package/lib/helpers/avg.js +24 -0
  72. package/lib/helpers/avg.js.map +1 -0
  73. package/lib/helpers/avg.test.d.ts +5 -0
  74. package/lib/helpers/avg.test.js +25 -0
  75. package/lib/helpers/avg.test.js.map +1 -0
  76. package/lib/helpers/capitalize.d.ts +7 -0
  77. package/lib/helpers/capitalize.js +20 -0
  78. package/lib/helpers/capitalize.js.map +1 -0
  79. package/lib/helpers/ceilToNumDecimals.d.ts +9 -0
  80. package/lib/helpers/ceilToNumDecimals.js +15 -0
  81. package/lib/helpers/ceilToNumDecimals.js.map +1 -0
  82. package/lib/helpers/ceilToNumDecimals.test.d.ts +5 -0
  83. package/lib/helpers/ceilToNumDecimals.test.js +38 -0
  84. package/lib/helpers/ceilToNumDecimals.test.js.map +1 -0
  85. package/lib/helpers/cloneDeep.d.ts +8 -0
  86. package/lib/helpers/cloneDeep.js +15 -0
  87. package/lib/helpers/cloneDeep.js.map +1 -0
  88. package/lib/helpers/compareArraysByProp.d.ts +13 -0
  89. package/lib/helpers/compareArraysByProp.js +62 -0
  90. package/lib/helpers/compareArraysByProp.js.map +1 -0
  91. package/lib/helpers/compareArraysByProp.test.d.ts +5 -0
  92. package/lib/helpers/compareArraysByProp.test.js +140 -0
  93. package/lib/helpers/compareArraysByProp.test.js.map +1 -0
  94. package/lib/helpers/extractProp.d.ts +12 -0
  95. package/lib/helpers/extractProp.js +19 -0
  96. package/lib/helpers/extractProp.js.map +1 -0
  97. package/lib/helpers/extractProp.test.d.ts +5 -0
  98. package/lib/helpers/extractProp.test.js +36 -0
  99. package/lib/helpers/extractProp.test.js.map +1 -0
  100. package/lib/helpers/floorToNumDecimals.d.ts +9 -0
  101. package/lib/helpers/floorToNumDecimals.js +15 -0
  102. package/lib/helpers/floorToNumDecimals.js.map +1 -0
  103. package/lib/helpers/floorToNumDecimals.test.d.ts +5 -0
  104. package/lib/helpers/floorToNumDecimals.test.js +38 -0
  105. package/lib/helpers/floorToNumDecimals.test.js.map +1 -0
  106. package/lib/helpers/forceNumIntoBounds.d.ts +10 -0
  107. package/lib/helpers/forceNumIntoBounds.js +15 -0
  108. package/lib/helpers/forceNumIntoBounds.js.map +1 -0
  109. package/lib/helpers/forceNumIntoBounds.test.d.ts +5 -0
  110. package/lib/helpers/forceNumIntoBounds.test.js +34 -0
  111. package/lib/helpers/forceNumIntoBounds.test.js.map +1 -0
  112. package/lib/helpers/genCSV.d.ts +18 -0
  113. package/lib/helpers/genCSV.js +69 -0
  114. package/lib/helpers/genCSV.js.map +1 -0
  115. package/lib/helpers/genCSV.test.d.ts +5 -0
  116. package/lib/helpers/genCSV.test.js +75 -0
  117. package/lib/helpers/genCSV.test.js.map +1 -0
  118. package/lib/helpers/genCommaList.d.ts +12 -0
  119. package/lib/helpers/genCommaList.js +20 -0
  120. package/lib/helpers/genCommaList.js.map +1 -0
  121. package/lib/helpers/genCommaList.test.d.ts +1 -0
  122. package/lib/helpers/genCommaList.test.js +94 -0
  123. package/lib/helpers/genCommaList.test.js.map +1 -0
  124. package/lib/helpers/getHumanReadableDate.d.ts +8 -0
  125. package/lib/helpers/getHumanReadableDate.js +32 -0
  126. package/lib/helpers/getHumanReadableDate.js.map +1 -0
  127. package/lib/helpers/getHumanReadableDate.test.d.ts +5 -0
  128. package/lib/helpers/getHumanReadableDate.test.js +31 -0
  129. package/lib/helpers/getHumanReadableDate.test.js.map +1 -0
  130. package/lib/helpers/getLocalTimeInfo.d.ts +19 -0
  131. package/lib/helpers/getLocalTimeInfo.js +51 -0
  132. package/lib/helpers/getLocalTimeInfo.js.map +1 -0
  133. package/lib/helpers/getLocalTimeInfo.test.d.ts +6 -0
  134. package/lib/helpers/getLocalTimeInfo.test.js +50 -0
  135. package/lib/helpers/getLocalTimeInfo.test.js.map +1 -0
  136. package/lib/helpers/getMonthName.d.ts +14 -0
  137. package/lib/helpers/getMonthName.js +31 -0
  138. package/lib/helpers/getMonthName.js.map +1 -0
  139. package/lib/helpers/getMonthName.test.d.ts +5 -0
  140. package/lib/helpers/getMonthName.test.js +70 -0
  141. package/lib/helpers/getMonthName.test.js.map +1 -0
  142. package/lib/helpers/getOrdinal.d.ts +8 -0
  143. package/lib/helpers/getOrdinal.js +16 -0
  144. package/lib/helpers/getOrdinal.js.map +1 -0
  145. package/lib/helpers/getOrdinal.test.d.ts +5 -0
  146. package/lib/helpers/getOrdinal.test.js +74 -0
  147. package/lib/helpers/getOrdinal.test.js.map +1 -0
  148. package/lib/helpers/getPartOfDay.d.ts +7 -0
  149. package/lib/helpers/getPartOfDay.js +24 -0
  150. package/lib/helpers/getPartOfDay.js.map +1 -0
  151. package/lib/helpers/getPartOfDay.test.d.ts +5 -0
  152. package/lib/helpers/getPartOfDay.test.js +49 -0
  153. package/lib/helpers/getPartOfDay.test.js.map +1 -0
  154. package/lib/helpers/getTimeInfoInET.d.ts +21 -0
  155. package/lib/helpers/getTimeInfoInET.js +67 -0
  156. package/lib/helpers/getTimeInfoInET.js.map +1 -0
  157. package/lib/helpers/getTimeInfoInET.test.d.ts +5 -0
  158. package/lib/helpers/getTimeInfoInET.test.js +74 -0
  159. package/lib/helpers/getTimeInfoInET.test.js.map +1 -0
  160. package/lib/helpers/getTimestampFromTimeInfoInET.d.ts +20 -0
  161. package/lib/helpers/getTimestampFromTimeInfoInET.js +136 -0
  162. package/lib/helpers/getTimestampFromTimeInfoInET.js.map +1 -0
  163. package/lib/helpers/getWordCount.d.ts +10 -0
  164. package/lib/helpers/getWordCount.js +24 -0
  165. package/lib/helpers/getWordCount.js.map +1 -0
  166. package/lib/helpers/idify.d.ts +9 -0
  167. package/lib/helpers/idify.js +24 -0
  168. package/lib/helpers/idify.js.map +1 -0
  169. package/lib/helpers/onlyKeepLetters.d.ts +8 -0
  170. package/lib/helpers/onlyKeepLetters.js +13 -0
  171. package/lib/helpers/onlyKeepLetters.js.map +1 -0
  172. package/lib/helpers/padDecimalZeros.d.ts +10 -0
  173. package/lib/helpers/padDecimalZeros.js +30 -0
  174. package/lib/helpers/padDecimalZeros.js.map +1 -0
  175. package/lib/helpers/padZerosLeft.d.ts +9 -0
  176. package/lib/helpers/padZerosLeft.js +21 -0
  177. package/lib/helpers/padZerosLeft.js.map +1 -0
  178. package/lib/helpers/parallelLimit.d.ts +12 -0
  179. package/lib/helpers/parallelLimit.js +104 -0
  180. package/lib/helpers/parallelLimit.js.map +1 -0
  181. package/lib/helpers/prefixWithAOrAn.d.ts +10 -0
  182. package/lib/helpers/prefixWithAOrAn.js +28 -0
  183. package/lib/helpers/prefixWithAOrAn.js.map +1 -0
  184. package/lib/helpers/roundToNumDecimals.d.ts +9 -0
  185. package/lib/helpers/roundToNumDecimals.js +15 -0
  186. package/lib/helpers/roundToNumDecimals.js.map +1 -0
  187. package/lib/helpers/shuffleArray.d.ts +8 -0
  188. package/lib/helpers/shuffleArray.js +29 -0
  189. package/lib/helpers/shuffleArray.js.map +1 -0
  190. package/lib/helpers/startMinWait.d.ts +9 -0
  191. package/lib/helpers/startMinWait.js +79 -0
  192. package/lib/helpers/startMinWait.js.map +1 -0
  193. package/lib/helpers/stringsToHumanReadableList.d.ts +10 -0
  194. package/lib/helpers/stringsToHumanReadableList.js +37 -0
  195. package/lib/helpers/stringsToHumanReadableList.js.map +1 -0
  196. package/lib/helpers/sum.d.ts +8 -0
  197. package/lib/helpers/sum.js +15 -0
  198. package/lib/helpers/sum.js.map +1 -0
  199. package/lib/helpers/validators/ChicagoTitleCase.d.ts +9 -0
  200. package/lib/helpers/validators/ChicagoTitleCase.js +31 -0
  201. package/lib/helpers/validators/ChicagoTitleCase.js.map +1 -0
  202. package/lib/helpers/validators/ChicagoTitleCase.test.d.ts +0 -0
  203. package/lib/helpers/validators/ChicagoTitleCase.test.js +79 -0
  204. package/lib/helpers/validators/ChicagoTitleCase.test.js.map +1 -0
  205. package/lib/helpers/validators/findURL.d.ts +0 -0
  206. package/lib/helpers/validators/findURL.js +39 -0
  207. package/lib/helpers/validators/findURL.js.map +1 -0
  208. package/lib/helpers/validators/findURL.test.d.ts +0 -0
  209. package/lib/helpers/validators/findURL.test.js +77 -0
  210. package/lib/helpers/validators/findURL.test.js.map +1 -0
  211. package/lib/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +10 -0
  212. package/lib/helpers/validators/shared/constants/ERROR_MESSAGES.js +21 -0
  213. package/lib/helpers/validators/shared/constants/ERROR_MESSAGES.js.map +1 -0
  214. package/lib/helpers/validators/shared/helpers/validateRegex.d.ts +19 -0
  215. package/lib/helpers/validators/shared/helpers/validateRegex.js +34 -0
  216. package/lib/helpers/validators/shared/helpers/validateRegex.js.map +1 -0
  217. package/lib/helpers/validators/shared/types/ValidationResult.d.ts +12 -0
  218. package/lib/helpers/validators/shared/types/ValidationResult.js +3 -0
  219. package/lib/helpers/validators/shared/types/ValidationResult.js.map +1 -0
  220. package/lib/helpers/validators/validURL.d.ts +8 -0
  221. package/lib/helpers/validators/validURL.js +20 -0
  222. package/lib/helpers/validators/validURL.js.map +1 -0
  223. package/lib/helpers/validators/validURL.test.d.ts +0 -0
  224. package/lib/helpers/validators/validURL.test.js +83 -0
  225. package/lib/helpers/validators/validURL.test.js.map +1 -0
  226. package/lib/helpers/validators/validateEmail.d.ts +11 -0
  227. package/lib/helpers/validators/validateEmail.js +39 -0
  228. package/lib/helpers/validators/validateEmail.js.map +1 -0
  229. package/lib/helpers/validators/validateEmail.test.d.ts +1 -0
  230. package/lib/helpers/validators/validateEmail.test.js +140 -0
  231. package/lib/helpers/validators/validateEmail.test.js.map +1 -0
  232. package/lib/helpers/validators/validatePhoneNumber.d.ts +11 -0
  233. package/lib/helpers/validators/validatePhoneNumber.js +40 -0
  234. package/lib/helpers/validators/validatePhoneNumber.js.map +1 -0
  235. package/lib/helpers/validators/validatePhoneNumber.test.d.ts +1 -0
  236. package/lib/helpers/validators/validatePhoneNumber.test.js +123 -0
  237. package/lib/helpers/validators/validatePhoneNumber.test.js.map +1 -0
  238. package/lib/helpers/validators/validateString.d.ts +22 -0
  239. package/lib/helpers/validators/validateString.js +124 -0
  240. package/lib/helpers/validators/validateString.js.map +1 -0
  241. package/lib/helpers/validators/validateString.test.d.ts +1 -0
  242. package/lib/helpers/validators/validateString.test.js +163 -0
  243. package/lib/helpers/validators/validateString.test.js.map +1 -0
  244. package/lib/helpers/waitMs.d.ts +7 -0
  245. package/lib/helpers/waitMs.js +68 -0
  246. package/lib/helpers/waitMs.js.map +1 -0
  247. package/lib/index.d.ts +63 -0
  248. package/lib/index.js +124 -0
  249. package/lib/index.js.map +1 -0
  250. package/lib/types/CommonKitErrorCode.d.ts +10 -0
  251. package/lib/types/CommonKitErrorCode.js +15 -0
  252. package/lib/types/CommonKitErrorCode.js.map +1 -0
  253. package/lib/types/DayOfWeek.d.ts +14 -0
  254. package/lib/types/DayOfWeek.js +18 -0
  255. package/lib/types/DayOfWeek.js.map +1 -0
  256. package/lib/types/Log/LogMainInfo.d.ts +39 -0
  257. package/lib/types/Log/LogMainInfo.js +3 -0
  258. package/lib/types/Log/LogMainInfo.js.map +1 -0
  259. package/lib/types/Log/LogSourceSpecificInfo.d.ts +13 -0
  260. package/lib/types/Log/LogSourceSpecificInfo.js +3 -0
  261. package/lib/types/Log/LogSourceSpecificInfo.js.map +1 -0
  262. package/lib/types/Log/LogTypeSpecificInfo.d.ts +17 -0
  263. package/lib/types/Log/LogTypeSpecificInfo.js +3 -0
  264. package/lib/types/Log/LogTypeSpecificInfo.js.map +1 -0
  265. package/lib/types/Log/index.d.ts +10 -0
  266. package/lib/types/Log/index.js +3 -0
  267. package/lib/types/Log/index.js.map +1 -0
  268. package/lib/types/LogAction.d.ts +29 -0
  269. package/lib/types/LogAction.js +55 -0
  270. package/lib/types/LogAction.js.map +1 -0
  271. package/lib/types/LogBuiltInMetadata.d.ts +16 -0
  272. package/lib/types/LogBuiltInMetadata.js +21 -0
  273. package/lib/types/LogBuiltInMetadata.js.map +1 -0
  274. package/lib/types/LogFunction.d.ts +24 -0
  275. package/lib/types/LogFunction.js +3 -0
  276. package/lib/types/LogFunction.js.map +1 -0
  277. package/lib/types/LogLevel.d.ts +10 -0
  278. package/lib/types/LogLevel.js +14 -0
  279. package/lib/types/LogLevel.js.map +1 -0
  280. package/lib/types/LogMetadataContextMap.d.ts +11 -0
  281. package/lib/types/LogMetadataContextMap.js +3 -0
  282. package/lib/types/LogMetadataContextMap.js.map +1 -0
  283. package/lib/types/LogMetadataTagMap.d.ts +8 -0
  284. package/lib/types/LogMetadataTagMap.js +3 -0
  285. package/lib/types/LogMetadataTagMap.js.map +1 -0
  286. package/lib/types/LogMetadataTargetMap.d.ts +8 -0
  287. package/lib/types/LogMetadataTargetMap.js +3 -0
  288. package/lib/types/LogMetadataTargetMap.js.map +1 -0
  289. package/lib/types/LogMetadataType.d.ts +13 -0
  290. package/lib/types/LogMetadataType.js +3 -0
  291. package/lib/types/LogMetadataType.js.map +1 -0
  292. package/lib/types/LogSource.d.ts +9 -0
  293. package/lib/types/LogSource.js +15 -0
  294. package/lib/types/LogSource.js.map +1 -0
  295. package/lib/types/LogType.d.ts +9 -0
  296. package/lib/types/LogType.js +15 -0
  297. package/lib/types/LogType.js.map +1 -0
  298. package/lib/types/ParamType.d.ts +17 -0
  299. package/lib/types/ParamType.js +21 -0
  300. package/lib/types/ParamType.js.map +1 -0
  301. package/package.json +47 -0
  302. package/src/constants/DAY_IN_MS.ts +7 -0
  303. package/src/constants/HOUR_IN_MS.ts +7 -0
  304. package/src/constants/LOG_REVIEW_GET_LOGS_ROUTE.ts +9 -0
  305. package/src/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.ts +9 -0
  306. package/src/constants/LOG_REVIEW_STATUS_ROUTE.ts +10 -0
  307. package/src/constants/LOG_ROUTE_PATH.ts +9 -0
  308. package/src/constants/MINUTE_IN_MS.ts +7 -0
  309. package/src/constants/ROUTE_PATH_PREFIX.ts +7 -0
  310. package/src/constants/SELECT_ADMIN_CHECK_ROUTE.ts +7 -0
  311. package/src/errors/ErrorWithCode.ts +15 -0
  312. package/src/helpers/abbreviate.test.ts +26 -0
  313. package/src/helpers/abbreviate.ts +25 -0
  314. package/src/helpers/asyncArrayFunctions/everyAsync.test.ts +114 -0
  315. package/src/helpers/asyncArrayFunctions/everyAsync.ts +51 -0
  316. package/src/helpers/asyncArrayFunctions/filterAsync.test.ts +126 -0
  317. package/src/helpers/asyncArrayFunctions/filterAsync.ts +50 -0
  318. package/src/helpers/asyncArrayFunctions/forEachAsync.test.ts +136 -0
  319. package/src/helpers/asyncArrayFunctions/forEachAsync.ts +40 -0
  320. package/src/helpers/asyncArrayFunctions/mapAsync.test.ts +125 -0
  321. package/src/helpers/asyncArrayFunctions/mapAsync.ts +46 -0
  322. package/src/helpers/asyncArrayFunctions/someAsync.test.ts +92 -0
  323. package/src/helpers/asyncArrayFunctions/someAsync.ts +49 -0
  324. package/src/helpers/avg.test.ts +24 -0
  325. package/src/helpers/avg.ts +22 -0
  326. package/src/helpers/capitalize.ts +20 -0
  327. package/src/helpers/ceilToNumDecimals.test.ts +39 -0
  328. package/src/helpers/ceilToNumDecimals.ts +13 -0
  329. package/src/helpers/cloneDeep.ts +11 -0
  330. package/src/helpers/compareArraysByProp.test.ts +147 -0
  331. package/src/helpers/compareArraysByProp.ts +56 -0
  332. package/src/helpers/extractProp.test.ts +34 -0
  333. package/src/helpers/extractProp.ts +17 -0
  334. package/src/helpers/floorToNumDecimals.test.ts +39 -0
  335. package/src/helpers/floorToNumDecimals.ts +13 -0
  336. package/src/helpers/forceNumIntoBounds.test.ts +34 -0
  337. package/src/helpers/forceNumIntoBounds.ts +19 -0
  338. package/src/helpers/genCSV.test.ts +77 -0
  339. package/src/helpers/genCSV.ts +87 -0
  340. package/src/helpers/genCommaList.test.ts +57 -0
  341. package/src/helpers/genCommaList.ts +21 -0
  342. package/src/helpers/getHumanReadableDate.test.ts +29 -0
  343. package/src/helpers/getHumanReadableDate.ts +36 -0
  344. package/src/helpers/getLocalTimeInfo.test.ts +48 -0
  345. package/src/helpers/getLocalTimeInfo.ts +58 -0
  346. package/src/helpers/getMonthName.test.ts +79 -0
  347. package/src/helpers/getMonthName.ts +29 -0
  348. package/src/helpers/getOrdinal.test.ts +84 -0
  349. package/src/helpers/getOrdinal.ts +14 -0
  350. package/src/helpers/getPartOfDay.test.ts +56 -0
  351. package/src/helpers/getPartOfDay.ts +20 -0
  352. package/src/helpers/getTimeInfoInET.test.ts +72 -0
  353. package/src/helpers/getTimeInfoInET.ts +79 -0
  354. package/src/helpers/getTimestampFromTimeInfoInET.ts +179 -0
  355. package/src/helpers/getWordCount.ts +26 -0
  356. package/src/helpers/idify.ts +24 -0
  357. package/src/helpers/onlyKeepLetters.ts +11 -0
  358. package/src/helpers/padDecimalZeros.ts +32 -0
  359. package/src/helpers/padZerosLeft.ts +21 -0
  360. package/src/helpers/parallelLimit.ts +63 -0
  361. package/src/helpers/prefixWithAOrAn.ts +29 -0
  362. package/src/helpers/roundToNumDecimals.ts +13 -0
  363. package/src/helpers/shuffleArray.ts +19 -0
  364. package/src/helpers/startMinWait.ts +33 -0
  365. package/src/helpers/stringsToHumanReadableList.ts +39 -0
  366. package/src/helpers/sum.ts +16 -0
  367. package/src/helpers/validators/ChicagoTitleCase.test.ts +85 -0
  368. package/src/helpers/validators/ChicagoTitleCase.ts +32 -0
  369. package/src/helpers/validators/findURL.test.ts +83 -0
  370. package/src/helpers/validators/findURL.ts +43 -0
  371. package/src/helpers/validators/shared/constants/ERROR_MESSAGES.ts +18 -0
  372. package/src/helpers/validators/shared/helpers/validateRegex.ts +47 -0
  373. package/src/helpers/validators/shared/types/ValidationResult.ts +20 -0
  374. package/src/helpers/validators/validURL.test.ts +90 -0
  375. package/src/helpers/validators/validURL.ts +18 -0
  376. package/src/helpers/validators/validateEmail.test.ts +110 -0
  377. package/src/helpers/validators/validateEmail.ts +47 -0
  378. package/src/helpers/validators/validatePhoneNumber.test.ts +94 -0
  379. package/src/helpers/validators/validatePhoneNumber.ts +49 -0
  380. package/src/helpers/validators/validateString.test.ts +173 -0
  381. package/src/helpers/validators/validateString.ts +171 -0
  382. package/src/helpers/waitMs.ts +12 -0
  383. package/src/index.ts +139 -0
  384. package/src/types/CommonKitErrorCode.ts +13 -0
  385. package/src/types/DayOfWeek.ts +15 -0
  386. package/src/types/Log/LogMainInfo.ts +69 -0
  387. package/src/types/Log/LogSourceSpecificInfo.ts +25 -0
  388. package/src/types/Log/LogTypeSpecificInfo.ts +33 -0
  389. package/src/types/Log/index.ts +17 -0
  390. package/src/types/LogAction.ts +52 -0
  391. package/src/types/LogBuiltInMetadata.ts +19 -0
  392. package/src/types/LogFunction.ts +46 -0
  393. package/src/types/LogLevel.ts +11 -0
  394. package/src/types/LogMetadataContextMap.ts +15 -0
  395. package/src/types/LogMetadataTagMap.ts +9 -0
  396. package/src/types/LogMetadataTargetMap.ts +9 -0
  397. package/src/types/LogMetadataType.ts +16 -0
  398. package/src/types/LogSource.ts +12 -0
  399. package/src/types/LogType.ts +12 -0
  400. package/src/types/ParamType.ts +18 -0
  401. package/tsconfig.json +19 -0
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ /**
40
+ * Run the operator function on each item in the array
41
+ * @author Gabe Abrams
42
+ * @param operatorFunction the operator function to apply
43
+ */
44
+ var forEachAsync = function (array, operatorFunction) { return __awaiter(void 0, void 0, void 0, function () {
45
+ var done, breakNow, i;
46
+ return __generator(this, function (_a) {
47
+ switch (_a.label) {
48
+ case 0:
49
+ done = false;
50
+ breakNow = function () {
51
+ done = true;
52
+ };
53
+ i = 0;
54
+ _a.label = 1;
55
+ case 1:
56
+ if (!(i < array.length && !done)) return [3 /*break*/, 4];
57
+ return [4 /*yield*/, operatorFunction(array[i], i, {
58
+ breakNow: breakNow,
59
+ array: array,
60
+ })];
61
+ case 2:
62
+ _a.sent();
63
+ _a.label = 3;
64
+ case 3:
65
+ i++;
66
+ return [3 /*break*/, 1];
67
+ case 4: return [2 /*return*/];
68
+ }
69
+ });
70
+ }); };
71
+ exports.default = forEachAsync;
72
+ //# sourceMappingURL=forEachAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forEachAsync.js","sourceRoot":"","sources":["../../../src/helpers/asyncArrayFunctions/forEachAsync.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,IAAM,YAAY,GAAG,UACnB,KAAU,EACV,gBAOS;;;;;gBAGL,IAAI,GAAG,KAAK,CAAC;gBAKX,QAAQ,GAAG;oBACf,IAAI,GAAG,IAAI,CAAC;gBACd,CAAC,CAAC;gBAGO,CAAC,GAAG,CAAC;;;qBAAE,CAAA,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,CAAA;gBACvC,qBAAM,gBAAgB,CACpB,KAAK,CAAC,CAAC,CAAC,EACR,CAAC,EACD;wBACE,QAAQ,UAAA;wBACR,KAAK,OAAA;qBACN,CACF,EAAA;;gBAPD,SAOC,CAAC;;;gBARuC,CAAC,EAAE,CAAA;;;;;KAU/C,CAAC;AAEF,kBAAe,YAAY,CAAC"}
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var forEachAsync_1 = __importDefault(require("./forEachAsync"));
43
+ describe('forEachAsync', function () {
44
+ it('should call the operator function for each item in the array', function () { return __awaiter(void 0, void 0, void 0, function () {
45
+ var array, operatorFunction;
46
+ return __generator(this, function (_a) {
47
+ switch (_a.label) {
48
+ case 0:
49
+ array = [1, 2, 3];
50
+ operatorFunction = jest.fn();
51
+ return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
52
+ case 1:
53
+ _a.sent();
54
+ expect(operatorFunction).toHaveBeenCalledTimes(3);
55
+ expect(operatorFunction).toHaveBeenCalledWith(1, 0, expect.any(Object));
56
+ expect(operatorFunction).toHaveBeenCalledWith(2, 1, expect.any(Object));
57
+ expect(operatorFunction).toHaveBeenCalledWith(3, 2, expect.any(Object));
58
+ return [2 /*return*/];
59
+ }
60
+ });
61
+ }); });
62
+ it('should pass the correct arguments to the operator function', function () { return __awaiter(void 0, void 0, void 0, function () {
63
+ var array, operatorFunction;
64
+ return __generator(this, function (_a) {
65
+ switch (_a.label) {
66
+ case 0:
67
+ array = ['a', 'b', 'c'];
68
+ operatorFunction = jest.fn();
69
+ return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
70
+ case 1:
71
+ _a.sent();
72
+ expect(operatorFunction).toHaveBeenCalledTimes(3);
73
+ expect(operatorFunction).toHaveBeenCalledWith('a', 0, expect.any(Object));
74
+ expect(operatorFunction).toHaveBeenCalledWith('b', 1, expect.any(Object));
75
+ expect(operatorFunction).toHaveBeenCalledWith('c', 2, expect.any(Object));
76
+ return [2 /*return*/];
77
+ }
78
+ });
79
+ }); });
80
+ it('should allow the operator function to break out of the loop', function () { return __awaiter(void 0, void 0, void 0, function () {
81
+ var array, operatorFunction;
82
+ return __generator(this, function (_a) {
83
+ switch (_a.label) {
84
+ case 0:
85
+ array = [1, 2, 3];
86
+ operatorFunction = jest.fn(function (item, index, _a) {
87
+ var breakNow = _a.breakNow;
88
+ if (item === 2) {
89
+ breakNow();
90
+ }
91
+ });
92
+ return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
93
+ case 1:
94
+ _a.sent();
95
+ expect(operatorFunction).toHaveBeenCalledTimes(2);
96
+ expect(operatorFunction).toHaveBeenCalledWith(1, 0, expect.any(Object));
97
+ expect(operatorFunction).toHaveBeenCalledWith(2, 1, expect.any(Object));
98
+ return [2 /*return*/];
99
+ }
100
+ });
101
+ }); });
102
+ it('should not call the operator function if the array is empty', function () { return __awaiter(void 0, void 0, void 0, function () {
103
+ var array, operatorFunction;
104
+ return __generator(this, function (_a) {
105
+ switch (_a.label) {
106
+ case 0:
107
+ array = [];
108
+ operatorFunction = jest.fn();
109
+ return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
110
+ case 1:
111
+ _a.sent();
112
+ expect(operatorFunction).not.toHaveBeenCalled();
113
+ return [2 /*return*/];
114
+ }
115
+ });
116
+ }); });
117
+ it('should return undefined', function () { return __awaiter(void 0, void 0, void 0, function () {
118
+ var array, operatorFunction, result;
119
+ return __generator(this, function (_a) {
120
+ switch (_a.label) {
121
+ case 0:
122
+ array = [1, 2, 3];
123
+ operatorFunction = jest.fn();
124
+ return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
125
+ case 1:
126
+ result = _a.sent();
127
+ expect(result).toBeUndefined();
128
+ return [2 /*return*/];
129
+ }
130
+ });
131
+ }); });
132
+ it('should work with an array of objects', function () { return __awaiter(void 0, void 0, void 0, function () {
133
+ var array, operatorFunction;
134
+ return __generator(this, function (_a) {
135
+ switch (_a.label) {
136
+ case 0:
137
+ array = [
138
+ { name: 'Alice', age: 30 },
139
+ { name: 'Bob', age: 25 },
140
+ { name: 'Charlie', age: 40 },
141
+ ];
142
+ operatorFunction = jest.fn();
143
+ return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
144
+ case 1:
145
+ _a.sent();
146
+ expect(operatorFunction).toHaveBeenCalledTimes(3);
147
+ expect(operatorFunction).toHaveBeenCalledWith({ name: 'Alice', age: 30 }, 0, expect.any(Object));
148
+ expect(operatorFunction).toHaveBeenCalledWith({ name: 'Bob', age: 25 }, 1, expect.any(Object));
149
+ expect(operatorFunction).toHaveBeenCalledWith({ name: 'Charlie', age: 40 }, 2, expect.any(Object));
150
+ return [2 /*return*/];
151
+ }
152
+ });
153
+ }); });
154
+ it('should work with an array of mixed types', function () { return __awaiter(void 0, void 0, void 0, function () {
155
+ var array, operatorFunction;
156
+ return __generator(this, function (_a) {
157
+ switch (_a.label) {
158
+ case 0:
159
+ array = [1, 'two', { three: 3 }];
160
+ operatorFunction = jest.fn();
161
+ return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
162
+ case 1:
163
+ _a.sent();
164
+ expect(operatorFunction).toHaveBeenCalledTimes(3);
165
+ expect(operatorFunction).toHaveBeenCalledWith(1, 0, expect.any(Object));
166
+ expect(operatorFunction).toHaveBeenCalledWith('two', 1, expect.any(Object));
167
+ expect(operatorFunction).toHaveBeenCalledWith({ three: 3 }, 2, expect.any(Object));
168
+ return [2 /*return*/];
169
+ }
170
+ });
171
+ }); });
172
+ it('should work with an array of length 1', function () { return __awaiter(void 0, void 0, void 0, function () {
173
+ var array, operatorFunction;
174
+ return __generator(this, function (_a) {
175
+ switch (_a.label) {
176
+ case 0:
177
+ array = ['a'];
178
+ operatorFunction = jest.fn();
179
+ return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
180
+ case 1:
181
+ _a.sent();
182
+ expect(operatorFunction).toHaveBeenCalledTimes(1);
183
+ expect(operatorFunction).toHaveBeenCalledWith('a', 0, expect.any(Object));
184
+ return [2 /*return*/];
185
+ }
186
+ });
187
+ }); });
188
+ it('should work with an array of length 100', function () { return __awaiter(void 0, void 0, void 0, function () {
189
+ var array, operatorFunction;
190
+ return __generator(this, function (_a) {
191
+ switch (_a.label) {
192
+ case 0:
193
+ array = Array.from({ length: 100 }, function (_, i) { return i; });
194
+ operatorFunction = jest.fn();
195
+ return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
196
+ case 1:
197
+ _a.sent();
198
+ expect(operatorFunction).toHaveBeenCalledTimes(100);
199
+ expect(operatorFunction).toHaveBeenCalledWith(0, 0, expect.any(Object));
200
+ expect(operatorFunction).toHaveBeenCalledWith(99, 99, expect.any(Object));
201
+ return [2 /*return*/];
202
+ }
203
+ });
204
+ }); });
205
+ it('should work with an array of length 1000', function () { return __awaiter(void 0, void 0, void 0, function () {
206
+ var array, operatorFunction;
207
+ return __generator(this, function (_a) {
208
+ switch (_a.label) {
209
+ case 0:
210
+ array = Array.from({ length: 1000 }, function (_, i) { return i; });
211
+ operatorFunction = jest.fn();
212
+ return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
213
+ case 1:
214
+ _a.sent();
215
+ expect(operatorFunction).toHaveBeenCalledTimes(1000);
216
+ expect(operatorFunction).toHaveBeenCalledWith(0, 0, expect.any(Object));
217
+ expect(operatorFunction).toHaveBeenCalledWith(999, 999, expect.any(Object));
218
+ return [2 /*return*/];
219
+ }
220
+ });
221
+ }); });
222
+ });
223
+ //# sourceMappingURL=forEachAsync.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forEachAsync.test.js","sourceRoot":"","sources":["../../../src/helpers/asyncArrayFunctions/forEachAsync.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAA0C;AAE1C,QAAQ,CAAC,cAAc,EAAE;IACvB,EAAE,CAAC,8DAA8D,EAAE;;;;;oBAC3D,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;oBAClB,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;oBAEnC,qBAAM,IAAA,sBAAY,EAAC,KAAK,EAAE,gBAAgB,CAAC,EAAA;;oBAA3C,SAA2C,CAAC;oBAE5C,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;oBAClD,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;oBACxE,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;oBACxE,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;;;;SACzE,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE;;;;;oBACzD,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;oBACxB,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;oBAEnC,qBAAM,IAAA,sBAAY,EAAC,KAAK,EAAE,gBAAgB,CAAC,EAAA;;oBAA3C,SAA2C,CAAC;oBAE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C,CAAC,CAAC;oBAClD,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;oBAEnC,qBAAM,IAAA,sBAAY,EAAC,KAAK,EAAE,gBAAgB,CAAC,EAAA;;oBAA3C,SAA2C,CAAC;oBAE5C,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;oBACrD,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;oBACxE,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;;;;SAC7E,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Run the operator function on each item in the array, collecting all results
3
+ * @author Gabe Abrams
4
+ * @param operatorFunction the operator function to apply
5
+ * @returns the array of results
6
+ */
7
+ declare const mapAsync: <T, U>(array: T[], operatorFunction: (item: T, index: number, opts: {
8
+ breakNow: () => void;
9
+ array: Array<T>;
10
+ }) => Promise<U>) => Promise<U[]>;
11
+ export default mapAsync;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ /**
40
+ * Run the operator function on each item in the array, collecting all results
41
+ * @author Gabe Abrams
42
+ * @param operatorFunction the operator function to apply
43
+ * @returns the array of results
44
+ */
45
+ var mapAsync = function (array, operatorFunction) { return __awaiter(void 0, void 0, void 0, function () {
46
+ var done, breakNow, results, i, result;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0:
50
+ done = false;
51
+ breakNow = function () {
52
+ done = true;
53
+ };
54
+ results = [];
55
+ i = 0;
56
+ _a.label = 1;
57
+ case 1:
58
+ if (!(i < array.length && !done)) return [3 /*break*/, 4];
59
+ return [4 /*yield*/, operatorFunction(array[i], i, {
60
+ breakNow: breakNow,
61
+ array: array,
62
+ })];
63
+ case 2:
64
+ result = _a.sent();
65
+ results.push(result);
66
+ _a.label = 3;
67
+ case 3:
68
+ i++;
69
+ return [3 /*break*/, 1];
70
+ case 4:
71
+ // Return results
72
+ return [2 /*return*/, results];
73
+ }
74
+ });
75
+ }); };
76
+ exports.default = mapAsync;
77
+ //# sourceMappingURL=mapAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapAsync.js","sourceRoot":"","sources":["../../../src/helpers/asyncArrayFunctions/mapAsync.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,IAAM,QAAQ,GAAG,UACf,KAAU,EACV,gBAOe;;;;;gBAGX,IAAI,GAAG,KAAK,CAAC;gBAKX,QAAQ,GAAG;oBACf,IAAI,GAAG,IAAI,CAAC;gBACd,CAAC,CAAC;gBAGI,OAAO,GAAQ,EAAE,CAAC;gBACf,CAAC,GAAG,CAAC;;;qBAAE,CAAA,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,CAAA;gBACxB,qBAAM,gBAAgB,CACnC,KAAK,CAAC,CAAC,CAAC,EACR,CAAC,EACD;wBACE,QAAQ,UAAA;wBACR,KAAK,OAAA;qBACN,CACF,EAAA;;gBAPK,MAAM,GAAG,SAOd;gBACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;;gBAToB,CAAC,EAAE,CAAA;;;YAY9C,iBAAiB;YACjB,sBAAO,OAAO,EAAC;;;KAChB,CAAC;AAEF,kBAAe,QAAQ,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var waitMs_1 = __importDefault(require("../waitMs"));
43
+ var mapAsync_1 = __importDefault(require("./mapAsync"));
44
+ describe('mapAsync', function () {
45
+ it('should return an empty array when given an empty array', function () { return __awaiter(void 0, void 0, void 0, function () {
46
+ var result;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0: return [4 /*yield*/, (0, mapAsync_1.default)([], function () { return __awaiter(void 0, void 0, void 0, function () {
50
+ return __generator(this, function (_a) {
51
+ return [2 /*return*/];
52
+ });
53
+ }); })];
54
+ case 1:
55
+ result = _a.sent();
56
+ expect(result).toEqual([]);
57
+ return [2 /*return*/];
58
+ }
59
+ });
60
+ }); });
61
+ it('should apply the operator function to each item in the array', function () { return __awaiter(void 0, void 0, void 0, function () {
62
+ var array, operatorFunction;
63
+ return __generator(this, function (_a) {
64
+ switch (_a.label) {
65
+ case 0:
66
+ array = [1, 2, 3];
67
+ operatorFunction = jest.fn();
68
+ return [4 /*yield*/, (0, mapAsync_1.default)(array, operatorFunction)];
69
+ case 1:
70
+ _a.sent();
71
+ expect(operatorFunction).toHaveBeenCalledTimes(3);
72
+ expect(operatorFunction).toHaveBeenCalledWith(1, 0, expect.any(Object));
73
+ expect(operatorFunction).toHaveBeenCalledWith(2, 1, expect.any(Object));
74
+ expect(operatorFunction).toHaveBeenCalledWith(3, 2, expect.any(Object));
75
+ return [2 /*return*/];
76
+ }
77
+ });
78
+ }); });
79
+ it('should collect and return the results of the operator function', function () { return __awaiter(void 0, void 0, void 0, function () {
80
+ var array, operatorFunction, result;
81
+ return __generator(this, function (_a) {
82
+ switch (_a.label) {
83
+ case 0:
84
+ array = [1, 2, 3];
85
+ operatorFunction = function (item) { return __awaiter(void 0, void 0, void 0, function () {
86
+ return __generator(this, function (_a) {
87
+ return [2 /*return*/, item * 2];
88
+ });
89
+ }); };
90
+ return [4 /*yield*/, (0, mapAsync_1.default)(array, operatorFunction)];
91
+ case 1:
92
+ result = _a.sent();
93
+ expect(result).toEqual([2, 4, 6]);
94
+ return [2 /*return*/];
95
+ }
96
+ });
97
+ }); });
98
+ it('should pass the correct index to the operator function', function () { return __awaiter(void 0, void 0, void 0, function () {
99
+ var array, operatorFunction;
100
+ return __generator(this, function (_a) {
101
+ switch (_a.label) {
102
+ case 0:
103
+ array = [1, 2, 3];
104
+ operatorFunction = jest.fn();
105
+ return [4 /*yield*/, (0, mapAsync_1.default)(array, operatorFunction)];
106
+ case 1:
107
+ _a.sent();
108
+ expect(operatorFunction).toHaveBeenCalledWith(expect.anything(), 0, expect.any(Object));
109
+ expect(operatorFunction).toHaveBeenCalledWith(expect.anything(), 1, expect.any(Object));
110
+ expect(operatorFunction).toHaveBeenCalledWith(expect.anything(), 2, expect.any(Object));
111
+ return [2 /*return*/];
112
+ }
113
+ });
114
+ }); });
115
+ it('should pass the correct options object to the operator function', function () { return __awaiter(void 0, void 0, void 0, function () {
116
+ var array, operatorFunction;
117
+ return __generator(this, function (_a) {
118
+ switch (_a.label) {
119
+ case 0:
120
+ array = [1, 2, 3];
121
+ operatorFunction = jest.fn();
122
+ return [4 /*yield*/, (0, mapAsync_1.default)(array, operatorFunction)];
123
+ case 1:
124
+ _a.sent();
125
+ expect(operatorFunction).toHaveBeenCalledWith(expect.anything(), expect.anything(), {
126
+ breakNow: expect.any(Function),
127
+ array: expect.any(Array),
128
+ });
129
+ return [2 /*return*/];
130
+ }
131
+ });
132
+ }); });
133
+ it('should allow the operator function to break the loop', function () { return __awaiter(void 0, void 0, void 0, function () {
134
+ var array, result;
135
+ return __generator(this, function (_a) {
136
+ switch (_a.label) {
137
+ case 0:
138
+ array = [1, 2, 3];
139
+ return [4 /*yield*/, (0, mapAsync_1.default)(array, function (item_1, index_1, _a) { return __awaiter(void 0, [item_1, index_1, _a], void 0, function (item, index, _b) {
140
+ var breakNow = _b.breakNow;
141
+ return __generator(this, function (_c) {
142
+ if (item === 2) {
143
+ breakNow();
144
+ }
145
+ return [2 /*return*/, item];
146
+ });
147
+ }); })];
148
+ case 1:
149
+ result = _a.sent();
150
+ expect(result).toEqual([1]);
151
+ return [2 /*return*/];
152
+ }
153
+ });
154
+ }); });
155
+ it('should handle asynchronous operator function', function () { return __awaiter(void 0, void 0, void 0, function () {
156
+ var array, result;
157
+ return __generator(this, function (_a) {
158
+ switch (_a.label) {
159
+ case 0:
160
+ array = [1, 2, 3];
161
+ return [4 /*yield*/, (0, mapAsync_1.default)(array, function (item) { return __awaiter(void 0, void 0, void 0, function () {
162
+ return __generator(this, function (_a) {
163
+ switch (_a.label) {
164
+ case 0: return [4 /*yield*/, (0, waitMs_1.default)(1000)];
165
+ case 1:
166
+ _a.sent();
167
+ return [2 /*return*/, item * 2];
168
+ }
169
+ });
170
+ }); })];
171
+ case 1:
172
+ result = _a.sent();
173
+ expect(result).toEqual([2, 4, 6]);
174
+ return [2 /*return*/];
175
+ }
176
+ });
177
+ }); });
178
+ it('should handle errors thrown by the operator function', function () { return __awaiter(void 0, void 0, void 0, function () {
179
+ var array;
180
+ return __generator(this, function (_a) {
181
+ switch (_a.label) {
182
+ case 0:
183
+ array = [1, 2, 3];
184
+ return [4 /*yield*/, expect((0, mapAsync_1.default)(array, function (item) { return __awaiter(void 0, void 0, void 0, function () {
185
+ return __generator(this, function (_a) {
186
+ if (item === 2) {
187
+ throw new Error('Error processing item');
188
+ }
189
+ return [2 /*return*/, item * 2];
190
+ });
191
+ }); })).rejects.toThrow('Error processing item')];
192
+ case 1:
193
+ _a.sent();
194
+ return [2 /*return*/];
195
+ }
196
+ });
197
+ }); });
198
+ it('should handle empty array with breakNow called', function () { return __awaiter(void 0, void 0, void 0, function () {
199
+ var array, result;
200
+ return __generator(this, function (_a) {
201
+ switch (_a.label) {
202
+ case 0:
203
+ array = [];
204
+ return [4 /*yield*/, (0, mapAsync_1.default)(array, function (item_1, index_1, _a) { return __awaiter(void 0, [item_1, index_1, _a], void 0, function (item, index, _b) {
205
+ var breakNow = _b.breakNow;
206
+ return __generator(this, function (_c) {
207
+ breakNow();
208
+ return [2 /*return*/, item];
209
+ });
210
+ }); })];
211
+ case 1:
212
+ result = _a.sent();
213
+ expect(result).toEqual([]);
214
+ return [2 /*return*/];
215
+ }
216
+ });
217
+ }); });
218
+ });
219
+ //# sourceMappingURL=mapAsync.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapAsync.test.js","sourceRoot":"","sources":["../../../src/helpers/asyncArrayFunctions/mapAsync.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA+B;AAC/B,wDAAkC;AAElC,QAAQ,CAAC,UAAU,EAAE;IACnB,EAAE,CAAC,wDAAwD,EAAE;;;;wBAC5C,qBAAM,IAAA,kBAAQ,EAAC,EAAE,EAAE;;;;yBAEjC,CAAC,EAAA;;oBAFI,MAAM,GAAG,SAEb;oBAEF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;;;;SAC5B,CAAC,CAAC;IAEH,EAAE,CAAC,8DAA8D,EAAE;;;;;oBAC3D,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;oBAClB,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;oBAEnC,qBAAM,IAAA,kBAAQ,EAAC,KAAK,EAAE,gBAAgB,CAAC,EAAA;;oBAAvC,SAAuC,CAAC;oBAExC,MAAM,CAAC,g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