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.
- package/.eslintrc.js +93 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/lib/constants/DAY_IN_MS.d.ts +6 -0
- package/lib/constants/DAY_IN_MS.js +9 -0
- package/lib/constants/DAY_IN_MS.js.map +1 -0
- package/lib/constants/HOUR_IN_MS.d.ts +6 -0
- package/lib/constants/HOUR_IN_MS.js +9 -0
- package/lib/constants/HOUR_IN_MS.js.map +1 -0
- package/lib/constants/LOG_REVIEW_GET_LOGS_ROUTE.d.ts +6 -0
- package/lib/constants/LOG_REVIEW_GET_LOGS_ROUTE.js +13 -0
- package/lib/constants/LOG_REVIEW_GET_LOGS_ROUTE.js.map +1 -0
- package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.d.ts +6 -0
- package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.js +13 -0
- package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.js.map +1 -0
- package/lib/constants/LOG_REVIEW_STATUS_ROUTE.d.ts +7 -0
- package/lib/constants/LOG_REVIEW_STATUS_ROUTE.js +14 -0
- package/lib/constants/LOG_REVIEW_STATUS_ROUTE.js.map +1 -0
- package/lib/constants/LOG_ROUTE_PATH.d.ts +6 -0
- package/lib/constants/LOG_ROUTE_PATH.js +13 -0
- package/lib/constants/LOG_ROUTE_PATH.js.map +1 -0
- package/lib/constants/MINUTE_IN_MS.d.ts +6 -0
- package/lib/constants/MINUTE_IN_MS.js +9 -0
- package/lib/constants/MINUTE_IN_MS.js.map +1 -0
- package/lib/constants/ROUTE_PATH_PREFIX.d.ts +6 -0
- package/lib/constants/ROUTE_PATH_PREFIX.js +9 -0
- package/lib/constants/ROUTE_PATH_PREFIX.js.map +1 -0
- package/lib/constants/SELECT_ADMIN_CHECK_ROUTE.d.ts +6 -0
- package/lib/constants/SELECT_ADMIN_CHECK_ROUTE.js +9 -0
- package/lib/constants/SELECT_ADMIN_CHECK_ROUTE.js.map +1 -0
- package/lib/errors/ErrorWithCode.d.ts +9 -0
- package/lib/errors/ErrorWithCode.js +33 -0
- package/lib/errors/ErrorWithCode.js.map +1 -0
- package/lib/helpers/abbreviate.d.ts +10 -0
- package/lib/helpers/abbreviate.js +24 -0
- package/lib/helpers/abbreviate.js.map +1 -0
- package/lib/helpers/abbreviate.test.d.ts +5 -0
- package/lib/helpers/abbreviate.test.js +28 -0
- package/lib/helpers/abbreviate.test.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/everyAsync.d.ts +13 -0
- package/lib/helpers/asyncArrayFunctions/everyAsync.js +81 -0
- package/lib/helpers/asyncArrayFunctions/everyAsync.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/everyAsync.test.d.ts +1 -0
- package/lib/helpers/asyncArrayFunctions/everyAsync.test.js +219 -0
- package/lib/helpers/asyncArrayFunctions/everyAsync.test.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/filterAsync.d.ts +13 -0
- package/lib/helpers/asyncArrayFunctions/filterAsync.js +81 -0
- package/lib/helpers/asyncArrayFunctions/filterAsync.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/filterAsync.test.d.ts +1 -0
- package/lib/helpers/asyncArrayFunctions/filterAsync.test.js +244 -0
- package/lib/helpers/asyncArrayFunctions/filterAsync.test.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/forEachAsync.d.ts +10 -0
- package/lib/helpers/asyncArrayFunctions/forEachAsync.js +72 -0
- package/lib/helpers/asyncArrayFunctions/forEachAsync.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/forEachAsync.test.d.ts +1 -0
- package/lib/helpers/asyncArrayFunctions/forEachAsync.test.js +223 -0
- package/lib/helpers/asyncArrayFunctions/forEachAsync.test.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/mapAsync.d.ts +11 -0
- package/lib/helpers/asyncArrayFunctions/mapAsync.js +77 -0
- package/lib/helpers/asyncArrayFunctions/mapAsync.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/mapAsync.test.d.ts +1 -0
- package/lib/helpers/asyncArrayFunctions/mapAsync.test.js +219 -0
- package/lib/helpers/asyncArrayFunctions/mapAsync.test.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/someAsync.d.ts +13 -0
- package/lib/helpers/asyncArrayFunctions/someAsync.js +80 -0
- package/lib/helpers/asyncArrayFunctions/someAsync.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/someAsync.test.d.ts +1 -0
- package/lib/helpers/asyncArrayFunctions/someAsync.test.js +227 -0
- package/lib/helpers/asyncArrayFunctions/someAsync.test.js.map +1 -0
- package/lib/helpers/avg.d.ts +8 -0
- package/lib/helpers/avg.js +24 -0
- package/lib/helpers/avg.js.map +1 -0
- package/lib/helpers/avg.test.d.ts +5 -0
- package/lib/helpers/avg.test.js +25 -0
- package/lib/helpers/avg.test.js.map +1 -0
- package/lib/helpers/capitalize.d.ts +7 -0
- package/lib/helpers/capitalize.js +20 -0
- package/lib/helpers/capitalize.js.map +1 -0
- package/lib/helpers/ceilToNumDecimals.d.ts +9 -0
- package/lib/helpers/ceilToNumDecimals.js +15 -0
- package/lib/helpers/ceilToNumDecimals.js.map +1 -0
- package/lib/helpers/ceilToNumDecimals.test.d.ts +5 -0
- package/lib/helpers/ceilToNumDecimals.test.js +38 -0
- package/lib/helpers/ceilToNumDecimals.test.js.map +1 -0
- package/lib/helpers/cloneDeep.d.ts +8 -0
- package/lib/helpers/cloneDeep.js +15 -0
- package/lib/helpers/cloneDeep.js.map +1 -0
- package/lib/helpers/compareArraysByProp.d.ts +13 -0
- package/lib/helpers/compareArraysByProp.js +62 -0
- package/lib/helpers/compareArraysByProp.js.map +1 -0
- package/lib/helpers/compareArraysByProp.test.d.ts +5 -0
- package/lib/helpers/compareArraysByProp.test.js +140 -0
- package/lib/helpers/compareArraysByProp.test.js.map +1 -0
- package/lib/helpers/extractProp.d.ts +12 -0
- package/lib/helpers/extractProp.js +19 -0
- package/lib/helpers/extractProp.js.map +1 -0
- package/lib/helpers/extractProp.test.d.ts +5 -0
- package/lib/helpers/extractProp.test.js +36 -0
- package/lib/helpers/extractProp.test.js.map +1 -0
- package/lib/helpers/floorToNumDecimals.d.ts +9 -0
- package/lib/helpers/floorToNumDecimals.js +15 -0
- package/lib/helpers/floorToNumDecimals.js.map +1 -0
- package/lib/helpers/floorToNumDecimals.test.d.ts +5 -0
- package/lib/helpers/floorToNumDecimals.test.js +38 -0
- package/lib/helpers/floorToNumDecimals.test.js.map +1 -0
- package/lib/helpers/forceNumIntoBounds.d.ts +10 -0
- package/lib/helpers/forceNumIntoBounds.js +15 -0
- package/lib/helpers/forceNumIntoBounds.js.map +1 -0
- package/lib/helpers/forceNumIntoBounds.test.d.ts +5 -0
- package/lib/helpers/forceNumIntoBounds.test.js +34 -0
- package/lib/helpers/forceNumIntoBounds.test.js.map +1 -0
- package/lib/helpers/genCSV.d.ts +18 -0
- package/lib/helpers/genCSV.js +69 -0
- package/lib/helpers/genCSV.js.map +1 -0
- package/lib/helpers/genCSV.test.d.ts +5 -0
- package/lib/helpers/genCSV.test.js +75 -0
- package/lib/helpers/genCSV.test.js.map +1 -0
- package/lib/helpers/genCommaList.d.ts +12 -0
- package/lib/helpers/genCommaList.js +20 -0
- package/lib/helpers/genCommaList.js.map +1 -0
- package/lib/helpers/genCommaList.test.d.ts +1 -0
- package/lib/helpers/genCommaList.test.js +94 -0
- package/lib/helpers/genCommaList.test.js.map +1 -0
- package/lib/helpers/getHumanReadableDate.d.ts +8 -0
- package/lib/helpers/getHumanReadableDate.js +32 -0
- package/lib/helpers/getHumanReadableDate.js.map +1 -0
- package/lib/helpers/getHumanReadableDate.test.d.ts +5 -0
- package/lib/helpers/getHumanReadableDate.test.js +31 -0
- package/lib/helpers/getHumanReadableDate.test.js.map +1 -0
- package/lib/helpers/getLocalTimeInfo.d.ts +19 -0
- package/lib/helpers/getLocalTimeInfo.js +51 -0
- package/lib/helpers/getLocalTimeInfo.js.map +1 -0
- package/lib/helpers/getLocalTimeInfo.test.d.ts +6 -0
- package/lib/helpers/getLocalTimeInfo.test.js +50 -0
- package/lib/helpers/getLocalTimeInfo.test.js.map +1 -0
- package/lib/helpers/getMonthName.d.ts +14 -0
- package/lib/helpers/getMonthName.js +31 -0
- package/lib/helpers/getMonthName.js.map +1 -0
- package/lib/helpers/getMonthName.test.d.ts +5 -0
- package/lib/helpers/getMonthName.test.js +70 -0
- package/lib/helpers/getMonthName.test.js.map +1 -0
- package/lib/helpers/getOrdinal.d.ts +8 -0
- package/lib/helpers/getOrdinal.js +16 -0
- package/lib/helpers/getOrdinal.js.map +1 -0
- package/lib/helpers/getOrdinal.test.d.ts +5 -0
- package/lib/helpers/getOrdinal.test.js +74 -0
- package/lib/helpers/getOrdinal.test.js.map +1 -0
- package/lib/helpers/getPartOfDay.d.ts +7 -0
- package/lib/helpers/getPartOfDay.js +24 -0
- package/lib/helpers/getPartOfDay.js.map +1 -0
- package/lib/helpers/getPartOfDay.test.d.ts +5 -0
- package/lib/helpers/getPartOfDay.test.js +49 -0
- package/lib/helpers/getPartOfDay.test.js.map +1 -0
- package/lib/helpers/getTimeInfoInET.d.ts +21 -0
- package/lib/helpers/getTimeInfoInET.js +67 -0
- package/lib/helpers/getTimeInfoInET.js.map +1 -0
- package/lib/helpers/getTimeInfoInET.test.d.ts +5 -0
- package/lib/helpers/getTimeInfoInET.test.js +74 -0
- package/lib/helpers/getTimeInfoInET.test.js.map +1 -0
- package/lib/helpers/getTimestampFromTimeInfoInET.d.ts +20 -0
- package/lib/helpers/getTimestampFromTimeInfoInET.js +136 -0
- package/lib/helpers/getTimestampFromTimeInfoInET.js.map +1 -0
- package/lib/helpers/getWordCount.d.ts +10 -0
- package/lib/helpers/getWordCount.js +24 -0
- package/lib/helpers/getWordCount.js.map +1 -0
- package/lib/helpers/idify.d.ts +9 -0
- package/lib/helpers/idify.js +24 -0
- package/lib/helpers/idify.js.map +1 -0
- package/lib/helpers/onlyKeepLetters.d.ts +8 -0
- package/lib/helpers/onlyKeepLetters.js +13 -0
- package/lib/helpers/onlyKeepLetters.js.map +1 -0
- package/lib/helpers/padDecimalZeros.d.ts +10 -0
- package/lib/helpers/padDecimalZeros.js +30 -0
- package/lib/helpers/padDecimalZeros.js.map +1 -0
- package/lib/helpers/padZerosLeft.d.ts +9 -0
- package/lib/helpers/padZerosLeft.js +21 -0
- package/lib/helpers/padZerosLeft.js.map +1 -0
- package/lib/helpers/parallelLimit.d.ts +12 -0
- package/lib/helpers/parallelLimit.js +104 -0
- package/lib/helpers/parallelLimit.js.map +1 -0
- package/lib/helpers/prefixWithAOrAn.d.ts +10 -0
- package/lib/helpers/prefixWithAOrAn.js +28 -0
- package/lib/helpers/prefixWithAOrAn.js.map +1 -0
- package/lib/helpers/roundToNumDecimals.d.ts +9 -0
- package/lib/helpers/roundToNumDecimals.js +15 -0
- package/lib/helpers/roundToNumDecimals.js.map +1 -0
- package/lib/helpers/shuffleArray.d.ts +8 -0
- package/lib/helpers/shuffleArray.js +29 -0
- package/lib/helpers/shuffleArray.js.map +1 -0
- package/lib/helpers/startMinWait.d.ts +9 -0
- package/lib/helpers/startMinWait.js +79 -0
- package/lib/helpers/startMinWait.js.map +1 -0
- package/lib/helpers/stringsToHumanReadableList.d.ts +10 -0
- package/lib/helpers/stringsToHumanReadableList.js +37 -0
- package/lib/helpers/stringsToHumanReadableList.js.map +1 -0
- package/lib/helpers/sum.d.ts +8 -0
- package/lib/helpers/sum.js +15 -0
- package/lib/helpers/sum.js.map +1 -0
- package/lib/helpers/validators/ChicagoTitleCase.d.ts +9 -0
- package/lib/helpers/validators/ChicagoTitleCase.js +31 -0
- package/lib/helpers/validators/ChicagoTitleCase.js.map +1 -0
- package/lib/helpers/validators/ChicagoTitleCase.test.d.ts +0 -0
- package/lib/helpers/validators/ChicagoTitleCase.test.js +79 -0
- package/lib/helpers/validators/ChicagoTitleCase.test.js.map +1 -0
- package/lib/helpers/validators/findURL.d.ts +0 -0
- package/lib/helpers/validators/findURL.js +39 -0
- package/lib/helpers/validators/findURL.js.map +1 -0
- package/lib/helpers/validators/findURL.test.d.ts +0 -0
- package/lib/helpers/validators/findURL.test.js +77 -0
- package/lib/helpers/validators/findURL.test.js.map +1 -0
- package/lib/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +10 -0
- package/lib/helpers/validators/shared/constants/ERROR_MESSAGES.js +21 -0
- package/lib/helpers/validators/shared/constants/ERROR_MESSAGES.js.map +1 -0
- package/lib/helpers/validators/shared/helpers/validateRegex.d.ts +19 -0
- package/lib/helpers/validators/shared/helpers/validateRegex.js +34 -0
- package/lib/helpers/validators/shared/helpers/validateRegex.js.map +1 -0
- package/lib/helpers/validators/shared/types/ValidationResult.d.ts +12 -0
- package/lib/helpers/validators/shared/types/ValidationResult.js +3 -0
- package/lib/helpers/validators/shared/types/ValidationResult.js.map +1 -0
- package/lib/helpers/validators/validURL.d.ts +8 -0
- package/lib/helpers/validators/validURL.js +20 -0
- package/lib/helpers/validators/validURL.js.map +1 -0
- package/lib/helpers/validators/validURL.test.d.ts +0 -0
- package/lib/helpers/validators/validURL.test.js +83 -0
- package/lib/helpers/validators/validURL.test.js.map +1 -0
- package/lib/helpers/validators/validateEmail.d.ts +11 -0
- package/lib/helpers/validators/validateEmail.js +39 -0
- package/lib/helpers/validators/validateEmail.js.map +1 -0
- package/lib/helpers/validators/validateEmail.test.d.ts +1 -0
- package/lib/helpers/validators/validateEmail.test.js +140 -0
- package/lib/helpers/validators/validateEmail.test.js.map +1 -0
- package/lib/helpers/validators/validatePhoneNumber.d.ts +11 -0
- package/lib/helpers/validators/validatePhoneNumber.js +40 -0
- package/lib/helpers/validators/validatePhoneNumber.js.map +1 -0
- package/lib/helpers/validators/validatePhoneNumber.test.d.ts +1 -0
- package/lib/helpers/validators/validatePhoneNumber.test.js +123 -0
- package/lib/helpers/validators/validatePhoneNumber.test.js.map +1 -0
- package/lib/helpers/validators/validateString.d.ts +22 -0
- package/lib/helpers/validators/validateString.js +124 -0
- package/lib/helpers/validators/validateString.js.map +1 -0
- package/lib/helpers/validators/validateString.test.d.ts +1 -0
- package/lib/helpers/validators/validateString.test.js +163 -0
- package/lib/helpers/validators/validateString.test.js.map +1 -0
- package/lib/helpers/waitMs.d.ts +7 -0
- package/lib/helpers/waitMs.js +68 -0
- package/lib/helpers/waitMs.js.map +1 -0
- package/lib/index.d.ts +63 -0
- package/lib/index.js +124 -0
- package/lib/index.js.map +1 -0
- package/lib/types/CommonKitErrorCode.d.ts +10 -0
- package/lib/types/CommonKitErrorCode.js +15 -0
- package/lib/types/CommonKitErrorCode.js.map +1 -0
- package/lib/types/DayOfWeek.d.ts +14 -0
- package/lib/types/DayOfWeek.js +18 -0
- package/lib/types/DayOfWeek.js.map +1 -0
- package/lib/types/Log/LogMainInfo.d.ts +39 -0
- package/lib/types/Log/LogMainInfo.js +3 -0
- package/lib/types/Log/LogMainInfo.js.map +1 -0
- package/lib/types/Log/LogSourceSpecificInfo.d.ts +13 -0
- package/lib/types/Log/LogSourceSpecificInfo.js +3 -0
- package/lib/types/Log/LogSourceSpecificInfo.js.map +1 -0
- package/lib/types/Log/LogTypeSpecificInfo.d.ts +17 -0
- package/lib/types/Log/LogTypeSpecificInfo.js +3 -0
- package/lib/types/Log/LogTypeSpecificInfo.js.map +1 -0
- package/lib/types/Log/index.d.ts +10 -0
- package/lib/types/Log/index.js +3 -0
- package/lib/types/Log/index.js.map +1 -0
- package/lib/types/LogAction.d.ts +29 -0
- package/lib/types/LogAction.js +55 -0
- package/lib/types/LogAction.js.map +1 -0
- package/lib/types/LogBuiltInMetadata.d.ts +16 -0
- package/lib/types/LogBuiltInMetadata.js +21 -0
- package/lib/types/LogBuiltInMetadata.js.map +1 -0
- package/lib/types/LogFunction.d.ts +24 -0
- package/lib/types/LogFunction.js +3 -0
- package/lib/types/LogFunction.js.map +1 -0
- package/lib/types/LogLevel.d.ts +10 -0
- package/lib/types/LogLevel.js +14 -0
- package/lib/types/LogLevel.js.map +1 -0
- package/lib/types/LogMetadataContextMap.d.ts +11 -0
- package/lib/types/LogMetadataContextMap.js +3 -0
- package/lib/types/LogMetadataContextMap.js.map +1 -0
- package/lib/types/LogMetadataTagMap.d.ts +8 -0
- package/lib/types/LogMetadataTagMap.js +3 -0
- package/lib/types/LogMetadataTagMap.js.map +1 -0
- package/lib/types/LogMetadataTargetMap.d.ts +8 -0
- package/lib/types/LogMetadataTargetMap.js +3 -0
- package/lib/types/LogMetadataTargetMap.js.map +1 -0
- package/lib/types/LogMetadataType.d.ts +13 -0
- package/lib/types/LogMetadataType.js +3 -0
- package/lib/types/LogMetadataType.js.map +1 -0
- package/lib/types/LogSource.d.ts +9 -0
- package/lib/types/LogSource.js +15 -0
- package/lib/types/LogSource.js.map +1 -0
- package/lib/types/LogType.d.ts +9 -0
- package/lib/types/LogType.js +15 -0
- package/lib/types/LogType.js.map +1 -0
- package/lib/types/ParamType.d.ts +17 -0
- package/lib/types/ParamType.js +21 -0
- package/lib/types/ParamType.js.map +1 -0
- package/package.json +47 -0
- package/src/constants/DAY_IN_MS.ts +7 -0
- package/src/constants/HOUR_IN_MS.ts +7 -0
- package/src/constants/LOG_REVIEW_GET_LOGS_ROUTE.ts +9 -0
- package/src/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.ts +9 -0
- package/src/constants/LOG_REVIEW_STATUS_ROUTE.ts +10 -0
- package/src/constants/LOG_ROUTE_PATH.ts +9 -0
- package/src/constants/MINUTE_IN_MS.ts +7 -0
- package/src/constants/ROUTE_PATH_PREFIX.ts +7 -0
- package/src/constants/SELECT_ADMIN_CHECK_ROUTE.ts +7 -0
- package/src/errors/ErrorWithCode.ts +15 -0
- package/src/helpers/abbreviate.test.ts +26 -0
- package/src/helpers/abbreviate.ts +25 -0
- package/src/helpers/asyncArrayFunctions/everyAsync.test.ts +114 -0
- package/src/helpers/asyncArrayFunctions/everyAsync.ts +51 -0
- package/src/helpers/asyncArrayFunctions/filterAsync.test.ts +126 -0
- package/src/helpers/asyncArrayFunctions/filterAsync.ts +50 -0
- package/src/helpers/asyncArrayFunctions/forEachAsync.test.ts +136 -0
- package/src/helpers/asyncArrayFunctions/forEachAsync.ts +40 -0
- package/src/helpers/asyncArrayFunctions/mapAsync.test.ts +125 -0
- package/src/helpers/asyncArrayFunctions/mapAsync.ts +46 -0
- package/src/helpers/asyncArrayFunctions/someAsync.test.ts +92 -0
- package/src/helpers/asyncArrayFunctions/someAsync.ts +49 -0
- package/src/helpers/avg.test.ts +24 -0
- package/src/helpers/avg.ts +22 -0
- package/src/helpers/capitalize.ts +20 -0
- package/src/helpers/ceilToNumDecimals.test.ts +39 -0
- package/src/helpers/ceilToNumDecimals.ts +13 -0
- package/src/helpers/cloneDeep.ts +11 -0
- package/src/helpers/compareArraysByProp.test.ts +147 -0
- package/src/helpers/compareArraysByProp.ts +56 -0
- package/src/helpers/extractProp.test.ts +34 -0
- package/src/helpers/extractProp.ts +17 -0
- package/src/helpers/floorToNumDecimals.test.ts +39 -0
- package/src/helpers/floorToNumDecimals.ts +13 -0
- package/src/helpers/forceNumIntoBounds.test.ts +34 -0
- package/src/helpers/forceNumIntoBounds.ts +19 -0
- package/src/helpers/genCSV.test.ts +77 -0
- package/src/helpers/genCSV.ts +87 -0
- package/src/helpers/genCommaList.test.ts +57 -0
- package/src/helpers/genCommaList.ts +21 -0
- package/src/helpers/getHumanReadableDate.test.ts +29 -0
- package/src/helpers/getHumanReadableDate.ts +36 -0
- package/src/helpers/getLocalTimeInfo.test.ts +48 -0
- package/src/helpers/getLocalTimeInfo.ts +58 -0
- package/src/helpers/getMonthName.test.ts +79 -0
- package/src/helpers/getMonthName.ts +29 -0
- package/src/helpers/getOrdinal.test.ts +84 -0
- package/src/helpers/getOrdinal.ts +14 -0
- package/src/helpers/getPartOfDay.test.ts +56 -0
- package/src/helpers/getPartOfDay.ts +20 -0
- package/src/helpers/getTimeInfoInET.test.ts +72 -0
- package/src/helpers/getTimeInfoInET.ts +79 -0
- package/src/helpers/getTimestampFromTimeInfoInET.ts +179 -0
- package/src/helpers/getWordCount.ts +26 -0
- package/src/helpers/idify.ts +24 -0
- package/src/helpers/onlyKeepLetters.ts +11 -0
- package/src/helpers/padDecimalZeros.ts +32 -0
- package/src/helpers/padZerosLeft.ts +21 -0
- package/src/helpers/parallelLimit.ts +63 -0
- package/src/helpers/prefixWithAOrAn.ts +29 -0
- package/src/helpers/roundToNumDecimals.ts +13 -0
- package/src/helpers/shuffleArray.ts +19 -0
- package/src/helpers/startMinWait.ts +33 -0
- package/src/helpers/stringsToHumanReadableList.ts +39 -0
- package/src/helpers/sum.ts +16 -0
- package/src/helpers/validators/ChicagoTitleCase.test.ts +85 -0
- package/src/helpers/validators/ChicagoTitleCase.ts +32 -0
- package/src/helpers/validators/findURL.test.ts +83 -0
- package/src/helpers/validators/findURL.ts +43 -0
- package/src/helpers/validators/shared/constants/ERROR_MESSAGES.ts +18 -0
- package/src/helpers/validators/shared/helpers/validateRegex.ts +47 -0
- package/src/helpers/validators/shared/types/ValidationResult.ts +20 -0
- package/src/helpers/validators/validURL.test.ts +90 -0
- package/src/helpers/validators/validURL.ts +18 -0
- package/src/helpers/validators/validateEmail.test.ts +110 -0
- package/src/helpers/validators/validateEmail.ts +47 -0
- package/src/helpers/validators/validatePhoneNumber.test.ts +94 -0
- package/src/helpers/validators/validatePhoneNumber.ts +49 -0
- package/src/helpers/validators/validateString.test.ts +173 -0
- package/src/helpers/validators/validateString.ts +171 -0
- package/src/helpers/waitMs.ts +12 -0
- package/src/index.ts +139 -0
- package/src/types/CommonKitErrorCode.ts +13 -0
- package/src/types/DayOfWeek.ts +15 -0
- package/src/types/Log/LogMainInfo.ts +69 -0
- package/src/types/Log/LogSourceSpecificInfo.ts +25 -0
- package/src/types/Log/LogTypeSpecificInfo.ts +33 -0
- package/src/types/Log/index.ts +17 -0
- package/src/types/LogAction.ts +52 -0
- package/src/types/LogBuiltInMetadata.ts +19 -0
- package/src/types/LogFunction.ts +46 -0
- package/src/types/LogLevel.ts +11 -0
- package/src/types/LogMetadataContextMap.ts +15 -0
- package/src/types/LogMetadataTagMap.ts +9 -0
- package/src/types/LogMetadataTargetMap.ts +9 -0
- package/src/types/LogMetadataType.ts +16 -0
- package/src/types/LogSource.ts +12 -0
- package/src/types/LogType.ts +12 -0
- package/src/types/ParamType.ts +18 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Test file for the getPartOfDay 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 getPartOfDay_1 = __importDefault(require("./getPartOfDay"));
|
|
11
|
+
describe('getPartOfDay', function () {
|
|
12
|
+
it('should return "morning" if the current hour is less than 12', function () {
|
|
13
|
+
// Mock the current hour to be 9am
|
|
14
|
+
jest.spyOn(Date.prototype, 'getHours').mockReturnValue(9);
|
|
15
|
+
var result = (0, getPartOfDay_1.default)();
|
|
16
|
+
expect(result).toEqual('morning');
|
|
17
|
+
});
|
|
18
|
+
it('should return "afternoon" if the current hour is between 12 and 16 (inclusive)', function () {
|
|
19
|
+
// Mock the current hour to be 2pm
|
|
20
|
+
jest.spyOn(Date.prototype, 'getHours').mockReturnValue(14);
|
|
21
|
+
var result = (0, getPartOfDay_1.default)();
|
|
22
|
+
expect(result).toEqual('afternoon');
|
|
23
|
+
});
|
|
24
|
+
it('should return "evening" if the current hour is between 17 and 24 (inclusive)', function () {
|
|
25
|
+
// Mock the current hour to be 8pm
|
|
26
|
+
jest.spyOn(Date.prototype, 'getHours').mockReturnValue(20);
|
|
27
|
+
var result = (0, getPartOfDay_1.default)();
|
|
28
|
+
expect(result).toEqual('evening');
|
|
29
|
+
});
|
|
30
|
+
it('should return "evening" if the current hour is 17', function () {
|
|
31
|
+
// Mock the current hour to be 5pm
|
|
32
|
+
jest.spyOn(Date.prototype, 'getHours').mockReturnValue(17);
|
|
33
|
+
var result = (0, getPartOfDay_1.default)();
|
|
34
|
+
expect(result).toEqual('evening');
|
|
35
|
+
});
|
|
36
|
+
it('should return "evening" if the current hour is 24', function () {
|
|
37
|
+
// Mock the current hour to be midnight
|
|
38
|
+
jest.spyOn(Date.prototype, 'getHours').mockReturnValue(24);
|
|
39
|
+
var result = (0, getPartOfDay_1.default)();
|
|
40
|
+
expect(result).toEqual('evening');
|
|
41
|
+
});
|
|
42
|
+
it('should return "morning" if the current hour is 0', function () {
|
|
43
|
+
// Mock the current hour to be midnight
|
|
44
|
+
jest.spyOn(Date.prototype, 'getHours').mockReturnValue(0);
|
|
45
|
+
var result = (0, getPartOfDay_1.default)();
|
|
46
|
+
expect(result).toEqual('morning');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=getPartOfDay.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPartOfDay.test.js","sourceRoot":"","sources":["../../src/helpers/getPartOfDay.test.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAEH,gEAA0C;AAE1C,QAAQ,CAAC,cAAc,EAAE;IACvB,EAAE,CAAC,6DAA6D,EAAE;QAChE,kCAAkC;QAClC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAE1D,IAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gFAAgF,EAAE;QACnF,kCAAkC;QAClC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,eAAe,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,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get current time info in US Boston Eastern Time, independent of machine
|
|
3
|
+
* timezone
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
6
|
+
* @returns object with timestamp (ms since epoch) and numbers
|
|
7
|
+
* corresponding to ET time values for year, month, day, hour, hour12, minute, second, isPM
|
|
8
|
+
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
9
|
+
*/
|
|
10
|
+
declare const getTimeInfoInET: (dateOrTimestamp?: Date | number) => {
|
|
11
|
+
timestamp: number;
|
|
12
|
+
year: number;
|
|
13
|
+
month: number;
|
|
14
|
+
day: number;
|
|
15
|
+
hour: number;
|
|
16
|
+
hour12: number;
|
|
17
|
+
minute: number;
|
|
18
|
+
second: number;
|
|
19
|
+
isPM: boolean;
|
|
20
|
+
};
|
|
21
|
+
export default getTimeInfoInET;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Get current time info in US Boston Eastern Time, independent of machine
|
|
5
|
+
* timezone
|
|
6
|
+
* @author Gabe Abrams
|
|
7
|
+
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
8
|
+
* @returns object with timestamp (ms since epoch) and numbers
|
|
9
|
+
* corresponding to ET time values for year, month, day, hour, hour12, minute, second, isPM
|
|
10
|
+
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
11
|
+
*/
|
|
12
|
+
var getTimeInfoInET = function (dateOrTimestamp) {
|
|
13
|
+
// Create a time string
|
|
14
|
+
var d;
|
|
15
|
+
if (!dateOrTimestamp) {
|
|
16
|
+
// Use now
|
|
17
|
+
d = new Date();
|
|
18
|
+
}
|
|
19
|
+
else if (typeof dateOrTimestamp === 'number') {
|
|
20
|
+
// Convert to date
|
|
21
|
+
d = new Date(dateOrTimestamp);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// Already a date
|
|
25
|
+
d = dateOrTimestamp;
|
|
26
|
+
}
|
|
27
|
+
var str = d.toLocaleString('en-US', // Using US encoding (it's the only one installed on containers)
|
|
28
|
+
{ timeZone: 'America/New_York' });
|
|
29
|
+
// Parse the string for the date/time info
|
|
30
|
+
var _a = str.split(', '), dateStr = _a[0], timeStr = _a[1]; // Format: MM/DD/YYYY, HH:MM:SS AM
|
|
31
|
+
var _b = dateStr.split('/'), monthStr = _b[0], dayStr = _b[1], yearStr = _b[2]; // Format: MM/DD/YYYY
|
|
32
|
+
var _c = timeStr.split(':'), hourStr = _c[0], minStr = _c[1], ending = _c[2]; // Format: HH:MM:SS AM
|
|
33
|
+
// Create all time numbers
|
|
34
|
+
var timestamp = d.getTime();
|
|
35
|
+
var year = Number.parseInt(yearStr, 10);
|
|
36
|
+
var month = Number.parseInt(monthStr, 10);
|
|
37
|
+
var day = Number.parseInt(dayStr, 10);
|
|
38
|
+
var minute = Number.parseInt(minStr, 10);
|
|
39
|
+
var second = (ending.split(' ')[0]
|
|
40
|
+
? Number.parseInt(ending.split(' ')[0], 10)
|
|
41
|
+
: 0);
|
|
42
|
+
var hour12 = Number.parseInt(hourStr, 10);
|
|
43
|
+
// Convert from am/pm to 24hr
|
|
44
|
+
var isAM = ending.toLowerCase().includes('am');
|
|
45
|
+
var isPM = !isAM;
|
|
46
|
+
var hour = hour12;
|
|
47
|
+
if (isPM && hour12 !== 12) {
|
|
48
|
+
hour += 12;
|
|
49
|
+
}
|
|
50
|
+
else if (isAM && hour12 === 12) {
|
|
51
|
+
hour = 0;
|
|
52
|
+
}
|
|
53
|
+
// Return
|
|
54
|
+
return {
|
|
55
|
+
timestamp: timestamp,
|
|
56
|
+
year: year,
|
|
57
|
+
month: month,
|
|
58
|
+
day: day,
|
|
59
|
+
hour: hour,
|
|
60
|
+
hour12: hour12,
|
|
61
|
+
isPM: isPM,
|
|
62
|
+
minute: minute,
|
|
63
|
+
second: second,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
exports.default = getTimeInfoInET;
|
|
67
|
+
//# sourceMappingURL=getTimeInfoInET.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTimeInfoInET.js","sourceRoot":"","sources":["../../src/helpers/getTimeInfoInET.ts"],"names":[],"mappings":";;AAAA;;;;;;;;GAQG;AACH,IAAM,eAAe,GAAG,UAAC,eAA+B;IAWtD,uBAAuB;IACvB,IAAI,CAAO,CAAC;IACZ,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,UAAU;QACV,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;IACjB,CAAC;SAAM,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE,CAAC;QAC/C,kBAAkB;QAClB,CAAC,GAAG,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,iBAAiB;QACjB,CAAC,GAAG,eAAe,CAAC;IACtB,CAAC;IACD,IAAM,GAAG,GAAG,CAAC,CAAC,cAAc,CAC1B,OAAO,EAAE,gEAAgE;IACzE,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CACjC,CAAC;IAEF,0CAA0C;IACpC,IAAA,KAAqB,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAnC,OAAO,QAAA,EAAE,OAAO,QAAmB,CAAC,CAAC,kCAAkC;IACxE,IAAA,KAA8B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAA/C,QAAQ,QAAA,EAAE,MAAM,QAAA,EAAE,OAAO,QAAsB,CAAC,CAAC,qBAAqB;IACvE,IAAA,KAA4B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAA7C,OAAO,QAAA,EAAE,M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AAA;QACJ,MAAM,QAAA;QACN,IAAI,MAAA;QACJ,MAAM,QAAA;QACN,MAAM,QAAA;KACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Test file for the getTimeInfoInET 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
|
+
// Import main function
|
|
11
|
+
var getTimeInfoInET_1 = __importDefault(require("./getTimeInfoInET"));
|
|
12
|
+
describe('getTimeInfoInET', function () {
|
|
13
|
+
it('should return the current time info in ET if no argument is passed', function () {
|
|
14
|
+
var result = (0, getTimeInfoInET_1.default)();
|
|
15
|
+
var now = new Date();
|
|
16
|
+
var expectedTimestamp = now.getTime();
|
|
17
|
+
var expectedYear = now.getFullYear();
|
|
18
|
+
var expectedMonth = now.getMonth() + 1;
|
|
19
|
+
var expectedDay = now.getDate();
|
|
20
|
+
var expectedHour = now.getHours();
|
|
21
|
+
var expectedHour12 = expectedHour % 12 || 12;
|
|
22
|
+
var expectedMinute = now.getMinutes();
|
|
23
|
+
var expectedIsPM = expectedHour >= 12;
|
|
24
|
+
expect(result.timestamp).toBeCloseTo(expectedTimestamp, -2);
|
|
25
|
+
expect(result.year).toEqual(expectedYear);
|
|
26
|
+
expect(result.month).toEqual(expectedMonth);
|
|
27
|
+
expect(result.day).toEqual(expectedDay);
|
|
28
|
+
expect(result.hour).toEqual(expectedHour);
|
|
29
|
+
expect(result.hour12).toEqual(expectedHour12);
|
|
30
|
+
expect(result.minute).toEqual(expectedMinute);
|
|
31
|
+
expect(result.isPM).toEqual(expectedIsPM);
|
|
32
|
+
});
|
|
33
|
+
it('should return the time info in ET for a specified date', function () {
|
|
34
|
+
var date = new Date('2022-01-01T00:00:00Z');
|
|
35
|
+
var result = (0, getTimeInfoInET_1.default)(date);
|
|
36
|
+
var expectedTimestamp = date.getTime();
|
|
37
|
+
var expectedYear = 2021;
|
|
38
|
+
var expectedMonth = 12;
|
|
39
|
+
var expectedDay = 31;
|
|
40
|
+
var expectedHour = 19;
|
|
41
|
+
var expectedHour12 = 7;
|
|
42
|
+
var expectedMinute = 0;
|
|
43
|
+
var expectedIsPM = true;
|
|
44
|
+
expect(result.timestamp).toEqual(expectedTimestamp);
|
|
45
|
+
expect(result.year).toEqual(expectedYear);
|
|
46
|
+
expect(result.month).toEqual(expectedMonth);
|
|
47
|
+
expect(result.day).toEqual(expectedDay);
|
|
48
|
+
expect(result.hour).toEqual(expectedHour);
|
|
49
|
+
expect(result.hour12).toEqual(expectedHour12);
|
|
50
|
+
expect(result.minute).toEqual(expectedMinute);
|
|
51
|
+
expect(result.isPM).toEqual(expectedIsPM);
|
|
52
|
+
});
|
|
53
|
+
it('should return the time info in ET for a specified timestamp', function () {
|
|
54
|
+
var timestamp = 1640995200000; // 2022-01-01T00:00:00Z
|
|
55
|
+
var result = (0, getTimeInfoInET_1.default)(timestamp);
|
|
56
|
+
var expectedTimestamp = timestamp;
|
|
57
|
+
var expectedYear = 2021;
|
|
58
|
+
var expectedMonth = 12;
|
|
59
|
+
var expectedDay = 31;
|
|
60
|
+
var expectedHour = 19;
|
|
61
|
+
var expectedHour12 = 7;
|
|
62
|
+
var expectedMinute = 0;
|
|
63
|
+
var expectedIsPM = true;
|
|
64
|
+
expect(result.timestamp).toEqual(expectedTimestamp);
|
|
65
|
+
expect(result.year).toEqual(expectedYear);
|
|
66
|
+
expect(result.month).toEqual(expectedMonth);
|
|
67
|
+
expect(result.day).toEqual(expectedDay);
|
|
68
|
+
expect(result.hour).toEqual(expectedHour);
|
|
69
|
+
expect(result.hour12).toEqual(expectedHour12);
|
|
70
|
+
expect(result.minute).toEqual(expectedMinute);
|
|
71
|
+
expect(result.isPM).toEqual(expectedIsPM);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=getTimeInfoInET.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTimeInfoInET.test.js","sourceRoot":"","sources":["../../src/helpers/getTimeInfoInET.test.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAEH,uBAAuB;AACvB,sEAAgD;AAEhD,QAAQ,CAAC,iBAAiB,EAAE;IAC1B,EAAE,CAAC,oEAAoE,EAAE;QACvE,IAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;QACjC,IAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAM,iBAAiB,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;QACxC,IAAM,YAAY,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACvC,IAAM,aAAa,GAAG,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACzC,IAAM,WAAW,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;QAClC,IAAM,YAAY,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;QACpC,IAAM,cAAc,GAAG,YAAY,GAAG,EAAE,IAAI,EAAE,CAAC;QAC/C,IAAM,cAAc,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QACxC,IAAM,YAAY,GAAG,YAAY,IAAI,EAAE,CAAC;QACxC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,CAAC;QAC5D,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC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C;QAC9C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a timestamp (ms since epoch) from time info (year, month, day, hour, minute, etc.) in Eastern Time (ET)
|
|
3
|
+
* @author Gardenia Liu
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @param opts object containing all arguments
|
|
6
|
+
* @param opts.year Year (e.g. 2023)
|
|
7
|
+
* @param opts.month Month (1-12)
|
|
8
|
+
* @param opts.day Day of the month (1-31)
|
|
9
|
+
* @param opts.hour Hour (0-23)
|
|
10
|
+
* @param opts.minute Minute (0-59)
|
|
11
|
+
* @returns Timestamp in milliseconds since epoch
|
|
12
|
+
*/
|
|
13
|
+
declare const getTimestampFromTimeInfoInET: (opts: {
|
|
14
|
+
year: number;
|
|
15
|
+
month: number;
|
|
16
|
+
day: number;
|
|
17
|
+
hour: number;
|
|
18
|
+
minute: number;
|
|
19
|
+
}) => number;
|
|
20
|
+
export default getTimestampFromTimeInfoInET;
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
// Import shared types
|
|
7
|
+
var ErrorWithCode_1 = __importDefault(require("../errors/ErrorWithCode"));
|
|
8
|
+
var CommonKitErrorCode_1 = __importDefault(require("../types/CommonKitErrorCode"));
|
|
9
|
+
// Import shared helpers
|
|
10
|
+
var getTimeInfoInET_1 = __importDefault(require("./getTimeInfoInET"));
|
|
11
|
+
var padZerosLeft_1 = __importDefault(require("./padZerosLeft"));
|
|
12
|
+
/*----------------------------------------*/
|
|
13
|
+
/* --------------- Helpers -------------- */
|
|
14
|
+
/*----------------------------------------*/
|
|
15
|
+
/**
|
|
16
|
+
* Check if a timestamp is valid
|
|
17
|
+
* @author Gabe Abrams
|
|
18
|
+
* @author Gardenia Liu
|
|
19
|
+
* @param opts object containing all arguments
|
|
20
|
+
* @param opts.timestamp Timestamp in milliseconds since epoch
|
|
21
|
+
* @param opts.expectedYear Expected year
|
|
22
|
+
* @param opts.expectedMonth Expected month
|
|
23
|
+
* @param opts.expectedDay Expected day
|
|
24
|
+
* @param opts.expectedHour Expected hour
|
|
25
|
+
* @param opts.expectedMinute Expected minute
|
|
26
|
+
* @returns 1 if the timestamp needs to be increased, -1 if it needs to be decreased, 0 if it is valid
|
|
27
|
+
*/
|
|
28
|
+
var checkTimestamp = function (opts) {
|
|
29
|
+
var timestamp = opts.timestamp, expectedYear = opts.expectedYear, expectedMonth = opts.expectedMonth, expectedDay = opts.expectedDay, expectedHour = opts.expectedHour, expectedMinute = opts.expectedMinute;
|
|
30
|
+
var timeInfoInET = (0, getTimeInfoInET_1.default)(timestamp);
|
|
31
|
+
if (timeInfoInET.year < expectedYear) {
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
if (timeInfoInET.year > expectedYear) {
|
|
35
|
+
return -1;
|
|
36
|
+
}
|
|
37
|
+
if (timeInfoInET.month < expectedMonth) {
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
if (timeInfoInET.month > expectedMonth) {
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
if (timeInfoInET.day < expectedDay) {
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
if (timeInfoInET.day > expectedDay) {
|
|
47
|
+
return -1;
|
|
48
|
+
}
|
|
49
|
+
if (timeInfoInET.hour < expectedHour) {
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
if (timeInfoInET.hour > expectedHour) {
|
|
53
|
+
return -1;
|
|
54
|
+
}
|
|
55
|
+
if (timeInfoInET.minute < expectedMinute) {
|
|
56
|
+
return 1;
|
|
57
|
+
}
|
|
58
|
+
if (timeInfoInET.minute > expectedMinute) {
|
|
59
|
+
return -1;
|
|
60
|
+
}
|
|
61
|
+
return 0;
|
|
62
|
+
};
|
|
63
|
+
/*----------------------------------------*/
|
|
64
|
+
/* ---------------- Main ---------------- */
|
|
65
|
+
/*----------------------------------------*/
|
|
66
|
+
/**
|
|
67
|
+
* Get a timestamp (ms since epoch) from time info (year, month, day, hour, minute, etc.) in Eastern Time (ET)
|
|
68
|
+
* @author Gardenia Liu
|
|
69
|
+
* @author Gabe Abrams
|
|
70
|
+
* @param opts object containing all arguments
|
|
71
|
+
* @param opts.year Year (e.g. 2023)
|
|
72
|
+
* @param opts.month Month (1-12)
|
|
73
|
+
* @param opts.day Day of the month (1-31)
|
|
74
|
+
* @param opts.hour Hour (0-23)
|
|
75
|
+
* @param opts.minute Minute (0-59)
|
|
76
|
+
* @returns Timestamp in milliseconds since epoch
|
|
77
|
+
*/
|
|
78
|
+
var getTimestampFromTimeInfoInET = function (opts) {
|
|
79
|
+
// Destructure opts
|
|
80
|
+
var year = opts.year, month = opts.month, day = opts.day, hour = opts.hour, minute = opts.minute;
|
|
81
|
+
// Determine if the date is in DST in Eastern Time
|
|
82
|
+
var tempDate = new Date(year, month - 1, day);
|
|
83
|
+
var janOffset = new Date(year, 0, 1).getTimezoneOffset();
|
|
84
|
+
var isDST = tempDate.getTimezoneOffset() < janOffset;
|
|
85
|
+
var etOffset = isDST ? '-04:00' : '-05:00';
|
|
86
|
+
// Format with leading zeroes
|
|
87
|
+
var mm = (0, padZerosLeft_1.default)(month, 2);
|
|
88
|
+
var dd = (0, padZerosLeft_1.default)(day, 2);
|
|
89
|
+
var hh = (0, padZerosLeft_1.default)(hour, 2);
|
|
90
|
+
var min = (0, padZerosLeft_1.default)(minute, 2);
|
|
91
|
+
// Build ET ISO string and convert to UTC timestamp
|
|
92
|
+
var etISOString = "".concat(year, "-").concat(mm, "-").concat(dd, "T").concat(hh, ":").concat(min, ":00").concat(etOffset);
|
|
93
|
+
var baseTimestamp = (new Date(etISOString)).getTime();
|
|
94
|
+
var timestamp = baseTimestamp;
|
|
95
|
+
// Heat seek to get the right timestamp
|
|
96
|
+
var maxOffset = 24 * 60; // 24 hours in minutes
|
|
97
|
+
var currentOffset = 0; // minutes
|
|
98
|
+
var offsetIncrement = 15; // minutes
|
|
99
|
+
var offsetDirection = checkTimestamp({
|
|
100
|
+
timestamp: timestamp,
|
|
101
|
+
expectedYear: year,
|
|
102
|
+
expectedMonth: month,
|
|
103
|
+
expectedDay: day,
|
|
104
|
+
expectedHour: hour,
|
|
105
|
+
expectedMinute: minute,
|
|
106
|
+
});
|
|
107
|
+
if (offsetDirection === 0) {
|
|
108
|
+
// Valid! Return the timestamp
|
|
109
|
+
return timestamp;
|
|
110
|
+
}
|
|
111
|
+
// Heat seek
|
|
112
|
+
while (Math.abs(currentOffset) < maxOffset) {
|
|
113
|
+
// Update offset
|
|
114
|
+
currentOffset += (offsetDirection * offsetIncrement);
|
|
115
|
+
// Update timestamp
|
|
116
|
+
var offsetMs = currentOffset * 60 * 1000;
|
|
117
|
+
timestamp = baseTimestamp + offsetMs;
|
|
118
|
+
// Check timestamp again
|
|
119
|
+
var newDirection = checkTimestamp({
|
|
120
|
+
timestamp: timestamp,
|
|
121
|
+
expectedYear: year,
|
|
122
|
+
expectedMonth: month,
|
|
123
|
+
expectedDay: day,
|
|
124
|
+
expectedHour: hour,
|
|
125
|
+
expectedMinute: minute,
|
|
126
|
+
});
|
|
127
|
+
if (newDirection === 0) {
|
|
128
|
+
// Valid! Return the timestamp
|
|
129
|
+
return timestamp;
|
|
130
|
+
}
|
|
131
|
+
// Invalid. Keep looping.
|
|
132
|
+
}
|
|
133
|
+
throw new ErrorWithCode_1.default("Timestamp mismatch: expected ".concat(year, "-").concat(mm, "-").concat(dd, " ").concat(hh, ":").concat(min, ", seeked to offset ").concat(currentOffset, " minutes but could not find a valid timestamp."), CommonKitErrorCode_1.default.ETTimestampInvalid);
|
|
134
|
+
};
|
|
135
|
+
exports.default = getTimestampFromTimeInfoInET;
|
|
136
|
+
//# sourceMappingURL=getTimestampFromTimeInfoInET.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTimestampFromTimeInfoInET.js","sourceRoot":"","sources":["../../src/helpers/getTimestampFromTimeInfoInET.ts"],"names":[],"mappings":";;;;;AAAA,sBAAsB;AACtB,0EAAoD;AACpD,mFAA6D;AAE7D,wBAAwB;AACxB,sEAAgD;AAChD,gEAA0C;AAE1C,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C;;;;;;;;;;;;GAYG;AACH,IAAM,cAAc,GAAG,UACrB,IAOC;IAGC,IAAA,SAAS,GAMP,IAAI,UANG,EACT,YAAY,GAKV,IAAI,aALM,EACZ,aAAa,GAIX,IAAI,cAJO,EACb,WAAW,GAGT,IAAI,YAHK,EACX,YAAY,GAEV,IAAI,aAFM,EACZ,cAAc,GACZ,IAAI,eADQ,CACP;IAET,IAAM,YAAY,GAAG,IAAA,yBAAe,EAAC,SAAS,CAAC,CAAC;IAChD,IAAI,YAAY,CAAC,IAAI,GAAG,YAAY,EAAE,CAAC;QACrC,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,YAAY,CAAC,IAAI,GAAG,YAAY,EAAE,CAAC;QACrC,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IACD,IAAI,YAAY,CAAC,KAAK,GAAG,aAAa,EAAE,CAAC;QACvC,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,YAAY,CAAC,KAAK,GAAG,aAAa,EAAE,CAAC;QACvC,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IACD,IAAI,YAAY,CAAC,GAAG,GAAG,WAAW,EAAE,CAAC;QACnC,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,YAAY,CAAC,GAAG,GAAG,WAAW,EAAE,CAAC;QACnC,OAAO,CAAC,CAAC,CAAC;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aAAa,EAAE,KAAK;YACpB,WAAW,EAAE,GAAG;YAChB,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,MAAM;SACvB,CAAC,CAAC;QACH,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;YACvB,8BAA8B;YAC9B,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,yBAAyB;IAC3B,CAAC;IAED,MAAM,IAAI,uBAAa,CACrB,uCAAgC,IAAI,cAAI,EAAE,cAAI,EAAE,cAAI,EAAE,cAAI,GAAG,gCAAsB,aAAa,mDAAgD,EAChJ,4BAAkB,CAAC,kBAAkB,CACtC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get number of words in string
|
|
3
|
+
* @author Gardenia Liu
|
|
4
|
+
* @author Allison Zhang
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
* @param text the string to check
|
|
7
|
+
* @returns number of words in the string
|
|
8
|
+
*/
|
|
9
|
+
declare const getWordCount: (text: string) => number;
|
|
10
|
+
export default getWordCount;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var punctuationRegex = /[!@#$%^&*(),.?\/;:'"\-\[\]]/g;
|
|
4
|
+
/**
|
|
5
|
+
* Get number of words in string
|
|
6
|
+
* @author Gardenia Liu
|
|
7
|
+
* @author Allison Zhang
|
|
8
|
+
* @author Gabe Abrams
|
|
9
|
+
* @param text the string to check
|
|
10
|
+
* @returns number of words in the string
|
|
11
|
+
*/
|
|
12
|
+
var getWordCount = function (text) {
|
|
13
|
+
var trimmedTextWithoutPunctuation = (text
|
|
14
|
+
// Remove leading and trailing whitespace
|
|
15
|
+
.trim()
|
|
16
|
+
// Remove punctuation
|
|
17
|
+
.replace(punctuationRegex, ''));
|
|
18
|
+
if (trimmedTextWithoutPunctuation.length === 0) {
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
return trimmedTextWithoutPunctuation.split(/\s+/g).length;
|
|
22
|
+
};
|
|
23
|
+
exports.default = getWordCount;
|
|
24
|
+
//# sourceMappingURL=getWordCount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWordCount.js","sourceRoot":"","sources":["../../src/helpers/getWordCount.ts"],"names":[],"mappings":";;AAAA,IAAM,gBAAgB,GAAG,8BAA8B,CAAC;AAExD;;;;;;;GAOG;AACH,IAAM,YAAY,GAAG,UAAC,IAAY;IAChC,IAAM,6BAA6B,GAAG,CACpC,IAAI;QACF,yCAAyC;SACxC,IAAI,EAAE;QACP,qBAAqB;SACpB,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CACjC,CAAC;IACF,IAAI,6BAA6B,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/C,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,6BAA6B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;AAC5D,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a string to hyphenated lowercase format with no space or
|
|
3
|
+
* non-alphanumeric characters
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @param str the string to convert
|
|
6
|
+
* @returns the idified string
|
|
7
|
+
*/
|
|
8
|
+
declare const idify: (str: string) => string;
|
|
9
|
+
export default idify;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Convert a string to hyphenated lowercase format with no space or
|
|
5
|
+
* non-alphanumeric characters
|
|
6
|
+
* @author Gabe Abrams
|
|
7
|
+
* @param str the string to convert
|
|
8
|
+
* @returns the idified string
|
|
9
|
+
*/
|
|
10
|
+
var idify = function (str) {
|
|
11
|
+
return (str
|
|
12
|
+
// Trim whitespace
|
|
13
|
+
.trim()
|
|
14
|
+
// Convert to lowercase
|
|
15
|
+
.toLowerCase()
|
|
16
|
+
// Replace non-alphanumeric characters with hyphens
|
|
17
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
18
|
+
// Change multiple hyphens in a row for a single hyphen
|
|
19
|
+
.replace(/-+/g, '-')
|
|
20
|
+
// Remove hyphens at the beginning and end of the string
|
|
21
|
+
.replace(/^-+|-+$/g, ''));
|
|
22
|
+
};
|
|
23
|
+
exports.default = idify;
|
|
24
|
+
//# sourceMappingURL=idify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idify.js","sourceRoot":"","sources":["../../src/helpers/idify.ts"],"names":[],"mappings":";;AAAA;;;;;;GAMG;AACH,IAAM,KAAK,GAAG,UAAC,GAAW;IACxB,OAAO,CACL,GAAG;QACD,kBAAkB;SACjB,IAAI,EAAE;QACP,uBAAuB;SACtB,WAAW,EAAE;QACd,mDAAmD;SAClD,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;QAC5B,uDAAuD;SACtD,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;QACpB,wDAAwD;SACvD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAC3B,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Given a string, only keep the letters inside it
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
* @param str the string to parse
|
|
7
|
+
* @returns only the letters inside of the string
|
|
8
|
+
*/
|
|
9
|
+
var onlyKeepLetters = function (str) {
|
|
10
|
+
return str.replace(/[^a-zA-Z]+/g, '');
|
|
11
|
+
};
|
|
12
|
+
exports.default = onlyKeepLetters;
|
|
13
|
+
//# sourceMappingURL=onlyKeepLetters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onlyKeepLetters.js","sourceRoot":"","sources":["../../src/helpers/onlyKeepLetters.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,IAAM,eAAe,GAAG,UAAC,GAAW;IAClC,OAAO,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pad a number's decimal with zeros on the right
|
|
3
|
+
* (e.g. 5.2 becomes 5.20 with 2 digit padding)
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @param num the number to pad
|
|
6
|
+
* @param numDigits the minimum number of digits after the decimal
|
|
7
|
+
* @returns padded number
|
|
8
|
+
*/
|
|
9
|
+
declare const padDecimalZeros: (num: number, numDigits: number) => string;
|
|
10
|
+
export default padDecimalZeros;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Pad a number's decimal with zeros on the right
|
|
5
|
+
* (e.g. 5.2 becomes 5.20 with 2 digit padding)
|
|
6
|
+
* @author Gabe Abrams
|
|
7
|
+
* @param num the number to pad
|
|
8
|
+
* @param numDigits the minimum number of digits after the decimal
|
|
9
|
+
* @returns padded number
|
|
10
|
+
*/
|
|
11
|
+
var padDecimalZeros = function (num, numDigits) {
|
|
12
|
+
// Skip if nothing to do
|
|
13
|
+
if (numDigits < 1) {
|
|
14
|
+
return String(num);
|
|
15
|
+
}
|
|
16
|
+
// Convert to string
|
|
17
|
+
var out = String(num);
|
|
18
|
+
// Add a decimal point if there isn't one
|
|
19
|
+
if (!out.includes('.')) {
|
|
20
|
+
out += '.';
|
|
21
|
+
}
|
|
22
|
+
// Add zeros
|
|
23
|
+
while (out.split('.')[1].length < numDigits) {
|
|
24
|
+
out = "".concat(out, "0");
|
|
25
|
+
}
|
|
26
|
+
// Return
|
|
27
|
+
return out;
|
|
28
|
+
};
|
|
29
|
+
exports.default = padDecimalZeros;
|
|
30
|
+
//# sourceMappingURL=padDecimalZeros.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"padDecimalZeros.js","sourceRoot":"","sources":["../../src/helpers/padDecimalZeros.ts"],"names":[],"mappings":";;AAAA;;;;;;;GAOG;AACH,IAAM,eAAe,GAAG,UAAC,GAAW,EAAE,SAAiB;IACrD,wBAAwB;IACxB,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAED,oBAAoB;IACpB,IAAI,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAEtB,yCAAyC;IACzC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,GAAG,IAAI,GAAG,CAAC;IACb,CAAC;IAED,YAAY;IACZ,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;QAC5C,GAAG,GAAG,UAAG,GAAG,MAAG,CAAC;IAClB,CAAC;IAED,SAAS;IACT,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pad a number with zeros on the left (e.g. 5 becomes 05 with 2 digit padding)
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param num the number to pad
|
|
5
|
+
* @param numDigits the minimum number of digits before the decimal
|
|
6
|
+
* @returns padded number
|
|
7
|
+
*/
|
|
8
|
+
declare const padZerosLeft: (num: number, numDigits: number) => string;
|
|
9
|
+
export default padZerosLeft;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Pad a number with zeros on the left (e.g. 5 becomes 05 with 2 digit padding)
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
* @param num the number to pad
|
|
7
|
+
* @param numDigits the minimum number of digits before the decimal
|
|
8
|
+
* @returns padded number
|
|
9
|
+
*/
|
|
10
|
+
var padZerosLeft = function (num, numDigits) {
|
|
11
|
+
// Convert to string
|
|
12
|
+
var out = String(num);
|
|
13
|
+
// Add zeros
|
|
14
|
+
while (out.split('.')[0].length < numDigits) {
|
|
15
|
+
out = "0".concat(out);
|
|
16
|
+
}
|
|
17
|
+
// Return
|
|
18
|
+
return out;
|
|
19
|
+
};
|
|
20
|
+
exports.default = padZerosLeft;
|
|
21
|
+
//# sourceMappingURL=padZerosLeft.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"padZerosLeft.js","sourceRoot":"","sources":["../../src/helpers/padZerosLeft.ts"],"names":[],"mappings":";;AAAA;;;;;;GAMG;AACH,IAAM,YAAY,GAAG,UAAC,GAAW,EAAE,SAAiB;IAClD,oBAAoB;IACpB,IAAI,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAEtB,YAAY;IACZ,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;QAC5C,GAAG,GAAG,WAAI,GAAG,CAAE,CAAC;IAClB,CAAC;IAED,SAAS;IACT,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run tasks in parallel with a limit on how many tasks can execute at once.
|
|
3
|
+
* No guarantees are made about the order of task execution
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @param taskFunctions functions that start asynchronous tasks and optionally
|
|
6
|
+
* resolve with values
|
|
7
|
+
* @param [limit=no limit] maximum number of asynchronous tasks to permit to run at
|
|
8
|
+
* once
|
|
9
|
+
* @returns array of resolved values in the same order as the task functions
|
|
10
|
+
*/
|
|
11
|
+
declare const parallelLimit: (taskFunctions: (() => Promise<any>)[], limit?: number) => Promise<any[]>;
|
|
12
|
+
export default parallelLimit;
|