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
package/.eslintrc.js ADDED
@@ -0,0 +1,93 @@
1
+ const config = {
2
+ extends: [
3
+ 'airbnb',
4
+ 'airbnb/hooks',
5
+ ],
6
+ overrides: [
7
+ {
8
+ files: [
9
+ '*.ts',
10
+ '*.tsx',
11
+ ],
12
+ extends: [
13
+ 'airbnb-typescript',
14
+ ],
15
+ parserOptions: {
16
+ project: './tsconfig.json',
17
+ tsconfigRootDir: __dirname,
18
+ sourceType: 'module',
19
+ },
20
+ rules: {
21
+ '@typescript-eslint/lines-between-class-members': 'off',
22
+ '@typescript-eslint/no-unused-expressions': 'off',
23
+ },
24
+ },
25
+ ],
26
+ rules: {
27
+ 'arrow-body-style': [
28
+ 'warn',
29
+ 'always',
30
+ ],
31
+ 'react/prop-types': 'off',
32
+ 'react/function-component-definition': [
33
+ 2,
34
+ {
35
+ namedComponents: 'arrow-function',
36
+ },
37
+ ],
38
+ 'no-spaced-func': 'off',
39
+ 'react-hooks/exhaustive-deps': 'off',
40
+ 'lines-between-class-members': 'off',
41
+ 'no-case-declarations': 'off',
42
+ 'react/require-default-props': 'off',
43
+ 'react/react-in-jsx-scope': 'off',
44
+ 'arrow-parens': [
45
+ 'warn',
46
+ 'always',
47
+ ],
48
+ 'comma-dangle': [
49
+ 'error',
50
+ {
51
+ arrays: 'always-multiline',
52
+ objects: 'always-multiline',
53
+ imports: 'always-multiline',
54
+ exports: 'always-multiline',
55
+ functions: 'always-multiline',
56
+ },
57
+ ],
58
+ 'consistent-return': 'off',
59
+ 'id-length': 'off',
60
+ 'max-len': [
61
+ 'error',
62
+ {
63
+ code: 125,
64
+ ignoreStrings: true,
65
+ ignoreTemplateLiterals: true,
66
+ ignoreUrls: true,
67
+ },
68
+ ],
69
+ 'newline-per-chained-call': [
70
+ 'error',
71
+ {
72
+ ignoreChainWithDepth: 2,
73
+ },
74
+ ],
75
+ 'no-plusplus': [
76
+ 'warn',
77
+ {
78
+ allowForLoopAfterthoughts: true,
79
+ },
80
+ ],
81
+ 'prefer-template': 1,
82
+ radix: 'error',
83
+ 'no-await-in-loop': 'off',
84
+ 'max-params': [
85
+ 'warn',
86
+ {
87
+ max: 3,
88
+ },
89
+ ],
90
+ },
91
+ };
92
+
93
+ module.exports = config;
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Harvard Edtech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # dce-commonkit
2
+ Common helpers, constants, and other resources that are shared between dce-reactkit and dce-expresskit
@@ -0,0 +1,6 @@
1
+ /**
2
+ * One day in ms
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const DAY_IN_MS = 86400000;
6
+ export default DAY_IN_MS;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * One day in ms
5
+ * @author Gabe Abrams
6
+ */
7
+ var DAY_IN_MS = 86400000;
8
+ exports.default = DAY_IN_MS;
9
+ //# sourceMappingURL=DAY_IN_MS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DAY_IN_MS.js","sourceRoot":"","sources":["../../src/constants/DAY_IN_MS.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,IAAM,SAAS,GAAG,QAAQ,CAAC;AAE3B,kBAAe,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * One hour in ms
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const HOUR_IN_MS = 3600000;
6
+ export default HOUR_IN_MS;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * One hour in ms
5
+ * @author Gabe Abrams
6
+ */
7
+ var HOUR_IN_MS = 3600000;
8
+ exports.default = HOUR_IN_MS;
9
+ //# sourceMappingURL=HOUR_IN_MS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HOUR_IN_MS.js","sourceRoot":"","sources":["../../src/constants/HOUR_IN_MS.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,IAAM,UAAU,GAAG,OAAO,CAAC;AAE3B,kBAAe,UAAU,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Path of the route for getting logs for log review
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const LOG_REVIEW_GET_LOGS_ROUTE = "/admin/dce-reactkit/logs";
6
+ export default LOG_REVIEW_GET_LOGS_ROUTE;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var ROUTE_PATH_PREFIX_1 = __importDefault(require("./ROUTE_PATH_PREFIX"));
7
+ /**
8
+ * Path of the route for getting logs for log review
9
+ * @author Gabe Abrams
10
+ */
11
+ var LOG_REVIEW_GET_LOGS_ROUTE = "/admin".concat(ROUTE_PATH_PREFIX_1.default, "/logs");
12
+ exports.default = LOG_REVIEW_GET_LOGS_ROUTE;
13
+ //# sourceMappingURL=LOG_REVIEW_GET_LOGS_ROUTE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LOG_REVIEW_GET_LOGS_ROUTE.js","sourceRoot":"","sources":["../../src/constants/LOG_REVIEW_GET_LOGS_ROUTE.ts"],"names":[],"mappings":";;;;;AAAA,0EAAoD;AAEpD;;;GAGG;AACH,IAAM,yBAAyB,GAAG,gBAAS,2BAAiB,UAAO,CAAC;AAEpE,kBAAe,yBAAyB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Path of the route for storing client-side logs
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const LOG_REVIEW_ROUTE_PATH_PREFIX = "/admin/dce-reactkit/logs";
6
+ export default LOG_REVIEW_ROUTE_PATH_PREFIX;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var ROUTE_PATH_PREFIX_1 = __importDefault(require("./ROUTE_PATH_PREFIX"));
7
+ /**
8
+ * Path of the route for storing client-side logs
9
+ * @author Gabe Abrams
10
+ */
11
+ var LOG_REVIEW_ROUTE_PATH_PREFIX = "/admin".concat(ROUTE_PATH_PREFIX_1.default, "/logs");
12
+ exports.default = LOG_REVIEW_ROUTE_PATH_PREFIX;
13
+ //# sourceMappingURL=LOG_REVIEW_ROUTE_PATH_PREFIX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LOG_REVIEW_ROUTE_PATH_PREFIX.js","sourceRoot":"","sources":["../../src/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.ts"],"names":[],"mappings":";;;;;AAAA,0EAAoD;AAEpD;;;GAGG;AACH,IAAM,4BAA4B,GAAG,gBAAS,2BAAiB,UAAO,CAAC;AAEvE,kBAAe,4BAA4B,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Route for checking the status of the current user's
3
+ * access to log review
4
+ * @author Gabe Abrams
5
+ */
6
+ declare const LOG_REVIEW_STATUS_ROUTE = "/dce-reactkit/logs/access_allowed";
7
+ export default LOG_REVIEW_STATUS_ROUTE;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var ROUTE_PATH_PREFIX_1 = __importDefault(require("./ROUTE_PATH_PREFIX"));
7
+ /**
8
+ * Route for checking the status of the current user's
9
+ * access to log review
10
+ * @author Gabe Abrams
11
+ */
12
+ var LOG_REVIEW_STATUS_ROUTE = "".concat(ROUTE_PATH_PREFIX_1.default, "/logs/access_allowed");
13
+ exports.default = LOG_REVIEW_STATUS_ROUTE;
14
+ //# sourceMappingURL=LOG_REVIEW_STATUS_ROUTE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LOG_REVIEW_STATUS_ROUTE.js","sourceRoot":"","sources":["../../src/constants/LOG_REVIEW_STATUS_ROUTE.ts"],"names":[],"mappings":";;;;;AAAA,0EAAoD;AAEpD;;;;GAIG;AACH,IAAM,uBAAuB,GAAG,UAAG,2BAAiB,yBAAsB,CAAC;AAE3E,kBAAe,uBAAuB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Path of the route for storing client-side logs
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const LOG_ROUTE_PATH = "/dce-reactkit/log";
6
+ export default LOG_ROUTE_PATH;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var ROUTE_PATH_PREFIX_1 = __importDefault(require("./ROUTE_PATH_PREFIX"));
7
+ /**
8
+ * Path of the route for storing client-side logs
9
+ * @author Gabe Abrams
10
+ */
11
+ var LOG_ROUTE_PATH = "".concat(ROUTE_PATH_PREFIX_1.default, "/log");
12
+ exports.default = LOG_ROUTE_PATH;
13
+ //# sourceMappingURL=LOG_ROUTE_PATH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LOG_ROUTE_PATH.js","sourceRoot":"","sources":["../../src/constants/LOG_ROUTE_PATH.ts"],"names":[],"mappings":";;;;;AAAA,0EAAoD;AAEpD;;;GAGG;AACH,IAAM,cAAc,GAAG,UAAG,2BAAiB,SAAM,CAAC;AAElD,kBAAe,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * One minute in ms
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const MINUTE_IN_MS = 60000;
6
+ export default MINUTE_IN_MS;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * One minute in ms
5
+ * @author Gabe Abrams
6
+ */
7
+ var MINUTE_IN_MS = 60000;
8
+ exports.default = MINUTE_IN_MS;
9
+ //# sourceMappingURL=MINUTE_IN_MS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MINUTE_IN_MS.js","sourceRoot":"","sources":["../../src/constants/MINUTE_IN_MS.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,IAAM,YAAY,GAAG,KAAK,CAAC;AAE3B,kBAAe,YAAY,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Path that all routes start with
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const ROUTE_PATH_PREFIX = "/dce-reactkit";
6
+ export default ROUTE_PATH_PREFIX;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Path that all routes start with
5
+ * @author Gabe Abrams
6
+ */
7
+ var ROUTE_PATH_PREFIX = '/dce-reactkit';
8
+ exports.default = ROUTE_PATH_PREFIX;
9
+ //# sourceMappingURL=ROUTE_PATH_PREFIX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ROUTE_PATH_PREFIX.js","sourceRoot":"","sources":["../../src/constants/ROUTE_PATH_PREFIX.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,IAAM,iBAAiB,GAAG,eAAe,CAAC;AAE1C,kBAAe,iBAAiB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Route for checking if the current user is a select admin
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const SELECT_ADMIN_CHECK_ROUTE = "/api/admin/select/is-select-admin";
6
+ export default SELECT_ADMIN_CHECK_ROUTE;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Route for checking if the current user is a select admin
5
+ * @author Gabe Abrams
6
+ */
7
+ var SELECT_ADMIN_CHECK_ROUTE = '/api/admin/select/is-select-admin';
8
+ exports.default = SELECT_ADMIN_CHECK_ROUTE;
9
+ //# sourceMappingURL=SELECT_ADMIN_CHECK_ROUTE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SELECT_ADMIN_CHECK_ROUTE.js","sourceRoot":"","sources":["../../src/constants/SELECT_ADMIN_CHECK_ROUTE.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,IAAM,wBAAwB,GAAG,mCAAmC,CAAC;AAErE,kBAAe,wBAAwB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * An error with a code
3
+ * @author Gabe Abrams
4
+ */
5
+ declare class ErrorWithCode extends Error {
6
+ code: string;
7
+ constructor(message: string, code: string);
8
+ }
9
+ export default ErrorWithCode;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ /**
19
+ * An error with a code
20
+ * @author Gabe Abrams
21
+ */
22
+ var ErrorWithCode = /** @class */ (function (_super) {
23
+ __extends(ErrorWithCode, _super);
24
+ function ErrorWithCode(message, code) {
25
+ var _this = _super.call(this, message) || this;
26
+ _this.name = 'ErrorWithCode';
27
+ _this.code = code;
28
+ return _this;
29
+ }
30
+ return ErrorWithCode;
31
+ }(Error));
32
+ exports.default = ErrorWithCode;
33
+ //# sourceMappingURL=ErrorWithCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorWithCode.js","sourceRoot":"","sources":["../../src/errors/ErrorWithCode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH;IAA4B,iCAAK;IAG/B,uBAAY,OAAe,EAAE,IAAY;QACvC,YAAA,MAAK,YAAC,OAAO,CAAC,SAAC;QACf,KAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;IACnB,CAAC;IACH,oBAAC;AAAD,CAAC,AARD,CAA4B,KAAK,GAQhC;AAED,kBAAe,aAAa,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Shorten text so it fits into a certain number of chars
3
+ * @author Gabe Abrams
4
+ * @param text the text to abbreviate
5
+ * @param maxChars the maximum number of chars to include
6
+ * @returns abbreviated text with length no greater than maxChars
7
+ * (including ellipses if applicable)
8
+ */
9
+ declare const abbreviate: (text: string, maxChars: number) => string;
10
+ export default abbreviate;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Shorten text so it fits into a certain number of chars
5
+ * @author Gabe Abrams
6
+ * @param text the text to abbreviate
7
+ * @param maxChars the maximum number of chars to include
8
+ * @returns abbreviated text with length no greater than maxChars
9
+ * (including ellipses if applicable)
10
+ */
11
+ var abbreviate = function (text, maxChars) {
12
+ // Check if already short enough
13
+ if (text.trim().length < maxChars) {
14
+ return text.trim();
15
+ }
16
+ // Abbreviate
17
+ var shortenedText = (text
18
+ .trim()
19
+ .substring(0, maxChars - 3)
20
+ .trim());
21
+ return "".concat(shortenedText, "...");
22
+ };
23
+ exports.default = abbreviate;
24
+ //# sourceMappingURL=abbreviate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abbreviate.js","sourceRoot":"","sources":["../../src/helpers/abbreviate.ts"],"names":[],"mappings":";;AAAA;;;;;;;GAOG;AACH,IAAM,UAAU,GAAG,UAAC,IAAY,EAAE,QAAgB;IAChD,gCAAgC;IAChC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,QAAQ,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED,aAAa;IACb,IAAM,aAAa,GAAG,CACpB,IAAI;SACD,IAAI,EAAE;SACN,SAAS,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC;SAC1B,IAAI,EAAE,CACV,CAAC;IACF,OAAO,UAAG,aAAa,QAAK,CAAC;AAC/B,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Unit tests for abbreviate helper
3
+ * @author Gabe Abrams
4
+ */
5
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Unit tests for abbreviate helper
4
+ * @author Gabe Abrams
5
+ */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ var abbreviate_1 = __importDefault(require("./abbreviate"));
11
+ describe('helpers > abbreviate', function () {
12
+ it('should return the original text if it is shorter than the maxChars parameter', function () {
13
+ var text = 'Hello, world!';
14
+ var maxChars = 20;
15
+ expect((0, abbreviate_1.default)(text, maxChars)).toEqual(text);
16
+ });
17
+ it('should abbreviate the text if it is longer than the maxChars parameter', function () {
18
+ var text = 'This is a really long string that needs to be abbreviated';
19
+ var maxChars = 20;
20
+ expect((0, abbreviate_1.default)(text, maxChars)).toEqual('This is a really...');
21
+ });
22
+ it('should handle leading/trailing whitespace', function () {
23
+ var text = ' This is a string with leading/trailing whitespace ';
24
+ var maxChars = 20;
25
+ expect((0, abbreviate_1.default)(text, maxChars)).toEqual('This is a string...');
26
+ });
27
+ });
28
+ //# sourceMappingURL=abbreviate.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abbreviate.test.js","sourceRoot":"","sources":["../../src/helpers/abbreviate.test.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAEH,4DAAsC;AAEtC,QAAQ,CAAC,sBAAsB,EAAE;IAC/B,EAAE,CAAC,8EAA8E,EAAE;QAC/E,IAAM,IAAI,GAAG,eAAe,CAAC;QAC7B,IAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,MAAM,CAAC,IAAA,oBAAU,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wEAAwE,EAAE;QAC3E,IAAM,IAAI,GAAG,2DAA2D,CAAC;QACzE,IAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,MAAM,CAAC,IAAA,oBAAU,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE;QAC9C,IAAM,IAAI,GAAG,yDAAyD,CAAC;QACvE,IAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,MAAM,CAAC,IAAA,oBAAU,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Run the operator function on each item in the array, returning true if
3
+ * the operator function returns true for every item in the array
4
+ * @author Gabe Abrams
5
+ * @param operatorFunction the operator function to apply. If it returns true
6
+ * for every item, this function will return true
7
+ * @returns true if the operator function returns true for every item in the array
8
+ */
9
+ declare const everyAsync: <T>(array: T[], operatorFunction: (item: T, index: number, opts: {
10
+ breakNow: () => void;
11
+ array: Array<T>;
12
+ }) => Promise<any>) => Promise<boolean>;
13
+ export default everyAsync;
@@ -0,0 +1,81 @@
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, returning true if
41
+ * the operator function returns true for every item in the array
42
+ * @author Gabe Abrams
43
+ * @param operatorFunction the operator function to apply. If it returns true
44
+ * for every item, this function will return true
45
+ * @returns true if the operator function returns true for every item in the array
46
+ */
47
+ var everyAsync = function (array, operatorFunction) { return __awaiter(void 0, void 0, void 0, function () {
48
+ var done, breakNow, i, passed;
49
+ return __generator(this, function (_a) {
50
+ switch (_a.label) {
51
+ case 0:
52
+ done = false;
53
+ breakNow = function () {
54
+ done = true;
55
+ };
56
+ i = 0;
57
+ _a.label = 1;
58
+ case 1:
59
+ if (!(i < array.length && !done)) return [3 /*break*/, 4];
60
+ return [4 /*yield*/, operatorFunction(array[i], i, {
61
+ breakNow: breakNow,
62
+ array: array,
63
+ })];
64
+ case 2:
65
+ passed = _a.sent();
66
+ // Check if this one failed or if loop was broken
67
+ if (!passed || done) {
68
+ return [2 /*return*/, false];
69
+ }
70
+ _a.label = 3;
71
+ case 3:
72
+ i++;
73
+ return [3 /*break*/, 1];
74
+ case 4:
75
+ // Return true because none returned false
76
+ return [2 /*return*/, true];
77
+ }
78
+ });
79
+ }); };
80
+ exports.default = everyAsync;
81
+ //# sourceMappingURL=everyAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"everyAsync.js","sourceRoot":"","sources":["../../../src/helpers/asyncArrayFunctions/everyAsync.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;GAOG;AACH,IAAM,UAAU,GAAG,UACjB,KAAU,EACV,gBAOiB;;;;;gBAGb,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;gBACxB,qBAAM,gBAAgB,CACnC,KAAK,CAAC,CAAC,CAAC,EACR,CAAC,EACD;wBACE,QAAQ,UAAA;wBACR,KAAK,OAAA;qBACN,CACF,EAAA;;gBAPK,MAAM,GAAG,SAOd;gBAED,iDAAiD;gBACjD,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;oBACpB,sBAAO,KAAK,EAAC;gBACf,CAAC;;;gBAbwC,CAAC,EAAE,CAAA;;;YAgB9C,0CAA0C;YAC1C,sBAAO,IAAI,EAAC;;;KACb,CAAC;AAEF,kBAAe,UAAU,CAAC"}