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,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
// Import function
|
|
43
|
+
var genCommaList_1 = __importDefault(require("./genCommaList"));
|
|
44
|
+
test('Empty list.', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
+
var emptyList, emptyListResponse, result;
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
emptyList = [];
|
|
48
|
+
emptyListResponse = '';
|
|
49
|
+
result = (0, genCommaList_1.default)(emptyList);
|
|
50
|
+
expect(result).toStrictEqual(emptyListResponse);
|
|
51
|
+
return [2 /*return*/];
|
|
52
|
+
});
|
|
53
|
+
}); });
|
|
54
|
+
test('One word list.', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
|
+
var oneList, oneListResponse, result;
|
|
56
|
+
return __generator(this, function (_a) {
|
|
57
|
+
oneList = ['apples'];
|
|
58
|
+
oneListResponse = 'apples';
|
|
59
|
+
result = (0, genCommaList_1.default)(oneList);
|
|
60
|
+
expect(result).toStrictEqual(oneListResponse);
|
|
61
|
+
return [2 /*return*/];
|
|
62
|
+
});
|
|
63
|
+
}); });
|
|
64
|
+
test('Two word list.', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
65
|
+
var twoList, twoListResponse, result;
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
twoList = ['apples', 'oranges'];
|
|
68
|
+
twoListResponse = 'apples and oranges';
|
|
69
|
+
result = (0, genCommaList_1.default)(twoList);
|
|
70
|
+
expect(result).toStrictEqual(twoListResponse);
|
|
71
|
+
return [2 /*return*/];
|
|
72
|
+
});
|
|
73
|
+
}); });
|
|
74
|
+
test('Three word list.', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
+
var threeList, threeListResponse, result;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
threeList = ['apples', 'oranges', 'bananas'];
|
|
78
|
+
threeListResponse = 'apples, oranges, and bananas';
|
|
79
|
+
result = (0, genCommaList_1.default)(threeList);
|
|
80
|
+
expect(result).toStrictEqual(threeListResponse);
|
|
81
|
+
return [2 /*return*/];
|
|
82
|
+
});
|
|
83
|
+
}); });
|
|
84
|
+
test('Four word list.', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
85
|
+
var fourList, fourListResponse, result;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
fourList = ['apples', 'oranges', 'bananas', 'grapes'];
|
|
88
|
+
fourListResponse = 'apples, oranges, bananas, and grapes';
|
|
89
|
+
result = (0, genCommaList_1.default)(fourList);
|
|
90
|
+
expect(result).toStrictEqual(fourListResponse);
|
|
91
|
+
return [2 /*return*/];
|
|
92
|
+
});
|
|
93
|
+
}); });
|
|
94
|
+
//# sourceMappingURL=genCommaList.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genCommaList.test.js","sourceRoot":"","sources":["../../src/helpers/genCommaList.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAAkB;AAClB,gEAA0C;AAE1C,IAAI,CACF,aAAa,EACb;;;QACQ,SAAS,GAAa,EAAE,CAAC;QACzB,iBAAiB,GAAW,EAAE,CAAC;QAE/B,MAAM,GAAG,IAAA,sBAAY,EAAC,SAAS,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;;;KACjD,CACF,CAAC;AAEF,IAAI,CACF,gBAAgB,EAChB;;;QACQ,OAAO,GAAa,CAAC,QAAQ,CAAC,CAAC;QAC/B,eAAe,GAAW,QAAQ,CAAC;QAEnC,MAAM,GAAG,IAAA,sBAAY,EAAC,OAAO,CAAC,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;;;KAC/C,CACF,CAAC;AAEF,IAAI,CACF,gBAAgB,EAChB;;;QACQ,OAAO,GAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC1C,eAAe,GAAW,oBAAoB,CAAC;QAE/C,MAAM,GAAG,IAAA,sBAAY,EAAC,OAAO,CAAC,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;;;KAC/C,CACF,CAAC;AAEF,IAAI,CACF,kBAAkB,EAClB;;;QACQ,SAAS,GAAa,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QACvD,iBAAiB,GAAW,8BAA8B,CAAC;QAE3D,MAAM,GAAG,IAAA,sBAAY,EAAC,SAAS,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;;;KACjD,CACF,CAAC;AAEF,IAAI,CACF,iBAAiB,EACjB;;;QACQ,QAAQ,GAAa,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QAChE,gBAAgB,GAAW,sCAAsC,CAAC;QAElE,MAAM,GAAG,IAAA,sBAAY,EAAC,QAAQ,CAAC,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;;;KAChD,CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a human-readable description of a date (all in ET)
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param [dateOrTimestamp=today] the date or timestamp for the date to describe
|
|
5
|
+
* @returns human-readable description of the date
|
|
6
|
+
*/
|
|
7
|
+
declare const getHumanReadableDate: (dateOrTimestamp?: Date | number) => string;
|
|
8
|
+
export default getHumanReadableDate;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 helpers
|
|
7
|
+
var getTimeInfoInET_1 = __importDefault(require("./getTimeInfoInET"));
|
|
8
|
+
var getOrdinal_1 = __importDefault(require("./getOrdinal"));
|
|
9
|
+
var getMonthName_1 = __importDefault(require("./getMonthName"));
|
|
10
|
+
/**
|
|
11
|
+
* Get a human-readable description of a date (all in ET)
|
|
12
|
+
* @author Gabe Abrams
|
|
13
|
+
* @param [dateOrTimestamp=today] the date or timestamp for the date to describe
|
|
14
|
+
* @returns human-readable description of the date
|
|
15
|
+
*/
|
|
16
|
+
var getHumanReadableDate = function (dateOrTimestamp) {
|
|
17
|
+
// Get the date info
|
|
18
|
+
var _a = (0, getTimeInfoInET_1.default)(dateOrTimestamp), month = _a.month, day = _a.day, year = _a.year;
|
|
19
|
+
var currYear = (0, getTimeInfoInET_1.default)().year;
|
|
20
|
+
// Get the short month description
|
|
21
|
+
var monthName = (0, getMonthName_1.default)(month).short;
|
|
22
|
+
// Create start of description
|
|
23
|
+
var description = "".concat(monthName, " ").concat(day).concat((0, getOrdinal_1.default)(day));
|
|
24
|
+
// Add on year if it's different
|
|
25
|
+
if (year !== currYear) {
|
|
26
|
+
description += " ".concat(year);
|
|
27
|
+
}
|
|
28
|
+
// Return description
|
|
29
|
+
return description;
|
|
30
|
+
};
|
|
31
|
+
exports.default = getHumanReadableDate;
|
|
32
|
+
//# sourceMappingURL=getHumanReadableDate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHumanReadableDate.js","sourceRoot":"","sources":["../../src/helpers/getHumanReadableDate.ts"],"names":[],"mappings":";;;;;AAAA,wBAAwB;AACxB,sEAAgD;AAChD,4DAAsC;AACtC,gEAA0C;AAE1C;;;;;GAKG;AACH,IAAM,oBAAoB,GAAG,UAAC,eAA+B;IAC3D,oBAAoB;IACd,IAAA,KAIF,IAAA,yBAAe,EAAC,eAAe,CAAC,EAHlC,KAAK,WAAA,EACL,GAAG,SAAA,EACH,IAAI,UAC8B,CAAC;IACrC,IAAM,QAAQ,GAAG,IAAA,yBAAe,GAAE,CAAC,IAAI,CAAC;IAExC,kCAAkC;IAClC,IAAM,SAAS,GAAG,IAAA,sBAAY,EAAC,KAAK,CAAC,CAAC,KAAK,CAAC;IAE5C,8BAA8B;IAC9B,IAAI,WAAW,GAAG,UAAG,SAAS,cAAI,GAAG,SAAG,IAAA,oBAAU,EAAC,GAAG,CAAC,CAAE,CAAC;IAE1D,gCAAgC;IAChC,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,WAAW,IAAI,WAAI,IAAI,CAAE,CAAC;IAC5B,CAAC;IAED,qBAAqB;IACrB,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,kBAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Test file for the getHumanReadableDate 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 helpers
|
|
11
|
+
var getHumanReadableDate_1 = __importDefault(require("./getHumanReadableDate"));
|
|
12
|
+
var getOrdinal_1 = __importDefault(require("./getOrdinal"));
|
|
13
|
+
describe('getHumanReadableDate', function () {
|
|
14
|
+
it('should return the current date if no argument is passed', function () {
|
|
15
|
+
var result = (0, getHumanReadableDate_1.default)();
|
|
16
|
+
var now = new Date();
|
|
17
|
+
var expected = "".concat(now.toLocaleString('default', { month: 'short' }), " ").concat(now.getDate()).concat((0, getOrdinal_1.default)(now.getDate()));
|
|
18
|
+
expect(result).toEqual(expected);
|
|
19
|
+
});
|
|
20
|
+
it('should return the correct date for a given timestamp', function () {
|
|
21
|
+
var timestamp = 1629822000000; // 2021-08-24T12:20:00.000Z
|
|
22
|
+
var result = (0, getHumanReadableDate_1.default)(timestamp);
|
|
23
|
+
expect(result).toEqual('Aug 24th 2021');
|
|
24
|
+
});
|
|
25
|
+
it('should return the correct date for a given Date object', function () {
|
|
26
|
+
var date = new Date('2021-08-24T12:20:00.000Z');
|
|
27
|
+
var result = (0, getHumanReadableDate_1.default)(date);
|
|
28
|
+
expect(result).toEqual('Aug 24th 2021');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=getHumanReadableDate.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHumanReadableDate.test.js","sourceRoot":"","sources":["../../src/helpers/getHumanReadableDate.test.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAEH,iBAAiB;AACjB,gFAA0D;AAC1D,4DAAsC;AAEtC,QAAQ,CAAC,sBAAsB,EAAE;IAC/B,EAAE,CAAC,yDAAyD,EAAE;QAC5D,IAAM,MAAM,GAAG,IAAA,8BAAoB,GAAE,CAAC;QACtC,IAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAM,QAAQ,GAAG,UAAG,GAAG,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,cAAI,GAAG,CAAC,OAAO,EAAE,SAAG,IAAA,oBAAU,EAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAE,CAAC;QACrH,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE;QACzD,IAAM,SAAS,GAAG,aAAa,CAAC,CAAC,2BAA2B;QAC5D,IAAM,MAAM,GAAG,IAAA,8BAAoB,EAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE;QAC3D,IAAM,IAAI,GAAG,IAAI,IAAI,CAAC,0BAA0B,CAAC,CAAC;QAClD,IAAM,MAAM,GAAG,IAAA,8BAAoB,EAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get current time info in local time
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
5
|
+
* @returns object with timestamp (ms since epoch) and numbers
|
|
6
|
+
* corresponding to time values for year, month, day, hour, hour12, minute, isPM
|
|
7
|
+
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
8
|
+
*/
|
|
9
|
+
declare const getLocalTimeInfo: (dateOrTimestamp?: Date | number) => {
|
|
10
|
+
timestamp: number;
|
|
11
|
+
year: number;
|
|
12
|
+
month: number;
|
|
13
|
+
day: number;
|
|
14
|
+
hour: number;
|
|
15
|
+
hour12: number;
|
|
16
|
+
minute: number;
|
|
17
|
+
isPM: boolean;
|
|
18
|
+
};
|
|
19
|
+
export default getLocalTimeInfo;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Get current time info in local time
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
7
|
+
* @returns object with timestamp (ms since epoch) and numbers
|
|
8
|
+
* corresponding to time values for year, month, day, hour, hour12, minute, isPM
|
|
9
|
+
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
10
|
+
*/
|
|
11
|
+
var getLocalTimeInfo = function (dateOrTimestamp) {
|
|
12
|
+
// Create a time string
|
|
13
|
+
var d;
|
|
14
|
+
if (!dateOrTimestamp) {
|
|
15
|
+
// Use now
|
|
16
|
+
d = new Date();
|
|
17
|
+
}
|
|
18
|
+
else if (typeof dateOrTimestamp === 'number') {
|
|
19
|
+
// Convert to date
|
|
20
|
+
d = new Date(dateOrTimestamp);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// Already a date
|
|
24
|
+
d = dateOrTimestamp;
|
|
25
|
+
}
|
|
26
|
+
// Create all time numbers
|
|
27
|
+
var timestamp = d.getTime();
|
|
28
|
+
var year = d.getFullYear();
|
|
29
|
+
var month = d.getMonth() + 1;
|
|
30
|
+
var day = d.getDate();
|
|
31
|
+
var hour = d.getHours();
|
|
32
|
+
var isPM = hour >= 12;
|
|
33
|
+
var hour12 = hour % 12;
|
|
34
|
+
if (hour12 === 0) {
|
|
35
|
+
hour12 = 12;
|
|
36
|
+
}
|
|
37
|
+
var minute = d.getMinutes();
|
|
38
|
+
// Return
|
|
39
|
+
return {
|
|
40
|
+
timestamp: timestamp,
|
|
41
|
+
year: year,
|
|
42
|
+
month: month,
|
|
43
|
+
day: day,
|
|
44
|
+
hour: hour,
|
|
45
|
+
hour12: hour12,
|
|
46
|
+
isPM: isPM,
|
|
47
|
+
minute: minute,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
exports.default = getLocalTimeInfo;
|
|
51
|
+
//# sourceMappingURL=getLocalTimeInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocalTimeInfo.js","sourceRoot":"","sources":["../../src/helpers/getLocalTimeInfo.ts"],"names":[],"mappings":";;AAAA;;;;;;;GAOG;AACH,IAAM,gBAAgB,GAAG,UAAC,eAA+B;IAUvD,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;IAED,0BAA0B;IAC1B,IAAM,SAAS,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9B,IAAM,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAC7B,IAAM,KAAK,GAAG,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC/B,IAAM,GAAG,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IACxB,IAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC1B,IAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACxB,IAAI,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;IACvB,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;QACjB,MAAM,GAAG,EAAE,CAAC;IACd,CAAC;IACD,IAAM,MAAM,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;IAE9B,SAAS;IACT,OAAO;QACL,SAAS,WAAA;QACT,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,GAAG,KAAA;QACH,IAAI,MAAA;QACJ,MAAM,QAAA;QACN,IAAI,MAAA;QACJ,MAAM,QAAA;KACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Test for getLocalTimeInfo helper function
|
|
4
|
+
* NOTE: only works if this test is run on a machine in ET
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
// Import main function
|
|
12
|
+
var getLocalTimeInfo_1 = __importDefault(require("./getLocalTimeInfo"));
|
|
13
|
+
describe('getLocalTimeInfo', function () {
|
|
14
|
+
it('should return current time info if no argument is passed', function () {
|
|
15
|
+
var result = (0, getLocalTimeInfo_1.default)();
|
|
16
|
+
var now = new Date();
|
|
17
|
+
expect(result.timestamp).toBeCloseTo(now.getTime(), -3);
|
|
18
|
+
expect(result.year).toEqual(now.getFullYear());
|
|
19
|
+
expect(result.month).toEqual(now.getMonth() + 1);
|
|
20
|
+
expect(result.day).toEqual(now.getDate());
|
|
21
|
+
expect(result.hour).toEqual(now.getHours());
|
|
22
|
+
expect(result.minute).toEqual(now.getMinutes());
|
|
23
|
+
expect(result.isPM).toEqual(now.getHours() >= 12);
|
|
24
|
+
});
|
|
25
|
+
it('should return correct time info for a given timestamp', function () {
|
|
26
|
+
var timestamp = 1629822000000; // 2021-08-24T12:20:00.000Z
|
|
27
|
+
var result = (0, getLocalTimeInfo_1.default)(timestamp);
|
|
28
|
+
expect(result.timestamp).toEqual(timestamp);
|
|
29
|
+
expect(result.year).toEqual(2021);
|
|
30
|
+
expect(result.month).toEqual(8);
|
|
31
|
+
expect(result.day).toEqual(24);
|
|
32
|
+
expect(result.hour).toEqual(12);
|
|
33
|
+
expect(result.hour12).toEqual(12);
|
|
34
|
+
expect(result.minute).toEqual(20);
|
|
35
|
+
expect(result.isPM).toEqual(true);
|
|
36
|
+
});
|
|
37
|
+
it('should return correct time info for a given Date object', function () {
|
|
38
|
+
var date = new Date('2021-08-24T12:20:00.000Z');
|
|
39
|
+
var result = (0, getLocalTimeInfo_1.default)(date);
|
|
40
|
+
expect(result.timestamp).toEqual(date.getTime());
|
|
41
|
+
expect(result.year).toEqual(2021);
|
|
42
|
+
expect(result.month).toEqual(8);
|
|
43
|
+
expect(result.day).toEqual(24);
|
|
44
|
+
expect(result.hour).toEqual(8);
|
|
45
|
+
expect(result.hour12).toEqual(8);
|
|
46
|
+
expect(result.minute).toEqual(20);
|
|
47
|
+
expect(result.isPM).toEqual(false);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=getLocalTimeInfo.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocalTimeInfo.test.js","sourceRoot":"","sources":["../../src/helpers/getLocalTimeInfo.test.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;AAEH,uBAAuB;AACvB,wEAAkD;AAElD,QAAQ,CAAC,kBAAkB,EAAE;IAC3B,EAAE,CAAC,0DAA0D,EAAE;QAC7D,IAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;Q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+1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the name of a month given the month number (1 = January, etc.)
|
|
3
|
+
* If an invalid number is provided, we will treat it like January
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @param month the number of the month
|
|
6
|
+
* @returns object containing multiple month name formats:
|
|
7
|
+
* { short, full } where short will look like "Jan" and full will look like
|
|
8
|
+
* "January"
|
|
9
|
+
*/
|
|
10
|
+
declare const getMonthName: (month: number) => {
|
|
11
|
+
short: string;
|
|
12
|
+
full: string;
|
|
13
|
+
};
|
|
14
|
+
export default getMonthName;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var monthNames = [
|
|
4
|
+
{ short: 'Jan', full: 'January' },
|
|
5
|
+
{ short: 'Feb', full: 'February' },
|
|
6
|
+
{ short: 'Mar', full: 'March' },
|
|
7
|
+
{ short: 'Apr', full: 'April' },
|
|
8
|
+
{ short: 'May', full: 'May' },
|
|
9
|
+
{ short: 'Jun', full: 'June' },
|
|
10
|
+
{ short: 'Jul', full: 'July' },
|
|
11
|
+
{ short: 'Aug', full: 'August' },
|
|
12
|
+
{ short: 'Sep', full: 'September' },
|
|
13
|
+
{ short: 'Oct', full: 'October' },
|
|
14
|
+
{ short: 'Nov', full: 'November' },
|
|
15
|
+
{ short: 'Dec', full: 'December' },
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Get the name of a month given the month number (1 = January, etc.)
|
|
19
|
+
* If an invalid number is provided, we will treat it like January
|
|
20
|
+
* @author Gabe Abrams
|
|
21
|
+
* @param month the number of the month
|
|
22
|
+
* @returns object containing multiple month name formats:
|
|
23
|
+
* { short, full } where short will look like "Jan" and full will look like
|
|
24
|
+
* "January"
|
|
25
|
+
*/
|
|
26
|
+
var getMonthName = function (month) {
|
|
27
|
+
var _a;
|
|
28
|
+
return ((_a = monthNames[month - 1]) !== null && _a !== void 0 ? _a : monthNames[0]);
|
|
29
|
+
};
|
|
30
|
+
exports.default = getMonthName;
|
|
31
|
+
//# sourceMappingURL=getMonthName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMonthName.js","sourceRoot":"","sources":["../../src/helpers/getMonthName.ts"],"names":[],"mappings":";;AAAA,IAAM,UAAU,GAAG;IACjB,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE;IACjC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE;IAClC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE;IAC/B,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE;IAC/B,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IAC7B,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;IAC9B,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;IAC9B,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE;IAChC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE;IACnC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE;IACjC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE;IAClC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE;CACnC,CAAC;AAEF;;;;;;;;GAQG;AACH,IAAM,YAAY,GAAG,UAAC,KAAa;;IACjC,OAAO,CAAC,MAAA,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,mCAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Test for getMonthName 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 helper
|
|
11
|
+
var getMonthName_1 = __importDefault(require("./getMonthName"));
|
|
12
|
+
describe('getMonthName', function () {
|
|
13
|
+
it('should return January for 1', function () {
|
|
14
|
+
var result = (0, getMonthName_1.default)(1);
|
|
15
|
+
expect(result).toEqual({ short: 'Jan', full: 'January' });
|
|
16
|
+
});
|
|
17
|
+
it('should return February for 2', function () {
|
|
18
|
+
var result = (0, getMonthName_1.default)(2);
|
|
19
|
+
expect(result).toEqual({ short: 'Feb', full: 'February' });
|
|
20
|
+
});
|
|
21
|
+
it('should return March for 3', function () {
|
|
22
|
+
var result = (0, getMonthName_1.default)(3);
|
|
23
|
+
expect(result).toEqual({ short: 'Mar', full: 'March' });
|
|
24
|
+
});
|
|
25
|
+
it('should return April for 4', function () {
|
|
26
|
+
var result = (0, getMonthName_1.default)(4);
|
|
27
|
+
expect(result).toEqual({ short: 'Apr', full: 'April' });
|
|
28
|
+
});
|
|
29
|
+
it('should return May for 5', function () {
|
|
30
|
+
var result = (0, getMonthName_1.default)(5);
|
|
31
|
+
expect(result).toEqual({ short: 'May', full: 'May' });
|
|
32
|
+
});
|
|
33
|
+
it('should return June for 6', function () {
|
|
34
|
+
var result = (0, getMonthName_1.default)(6);
|
|
35
|
+
expect(result).toEqual({ short: 'Jun', full: 'June' });
|
|
36
|
+
});
|
|
37
|
+
it('should return July for 7', function () {
|
|
38
|
+
var result = (0, getMonthName_1.default)(7);
|
|
39
|
+
expect(result).toEqual({ short: 'Jul', full: 'July' });
|
|
40
|
+
});
|
|
41
|
+
it('should return August for 8', function () {
|
|
42
|
+
var result = (0, getMonthName_1.default)(8);
|
|
43
|
+
expect(result).toEqual({ short: 'Aug', full: 'August' });
|
|
44
|
+
});
|
|
45
|
+
it('should return September for 9', function () {
|
|
46
|
+
var result = (0, getMonthName_1.default)(9);
|
|
47
|
+
expect(result).toEqual({ short: 'Sep', full: 'September' });
|
|
48
|
+
});
|
|
49
|
+
it('should return October for 10', function () {
|
|
50
|
+
var result = (0, getMonthName_1.default)(10);
|
|
51
|
+
expect(result).toEqual({ short: 'Oct', full: 'October' });
|
|
52
|
+
});
|
|
53
|
+
it('should return November for 11', function () {
|
|
54
|
+
var result = (0, getMonthName_1.default)(11);
|
|
55
|
+
expect(result).toEqual({ short: 'Nov', full: 'November' });
|
|
56
|
+
});
|
|
57
|
+
it('should return December for 12', function () {
|
|
58
|
+
var result = (0, getMonthName_1.default)(12);
|
|
59
|
+
expect(result).toEqual({ short: 'Dec', full: 'December' });
|
|
60
|
+
});
|
|
61
|
+
it('should return January for 0', function () {
|
|
62
|
+
var result = (0, getMonthName_1.default)(0);
|
|
63
|
+
expect(result).toEqual({ short: 'Jan', full: 'January' });
|
|
64
|
+
});
|
|
65
|
+
it('should return January for 13', function () {
|
|
66
|
+
var result = (0, getMonthName_1.default)(13);
|
|
67
|
+
expect(result).toEqual({ short: 'Jan', full: 'January' });
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=getMonthName.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMonthName.test.js","sourceRoot":"","sources":["../../src/helpers/getMonthName.test.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAEH,qBAAqB;AACrB,gEAA0C;AAE1C,QAAQ,CAAC,cAAc,EAAE;IACvB,EAAE,CAAC,6BAA6B,EAAE;QAChC,IAAM,MAAM,GAAG,IAAA,sBAAY,EAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAA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CAAC,CAAC;QAChC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE;QAChC,IAAM,MAAM,GAAG,IAAA,sBAAY,EAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE;QACjC,IAAM,MAAM,GAAG,IAAA,sBAAY,EAAC,EAAE,CAAC,CAAC;QAChC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Constants
|
|
4
|
+
var ORDINALS = ['th', 'st', 'nd', 'rd'];
|
|
5
|
+
/**
|
|
6
|
+
* Get a number's ordinal
|
|
7
|
+
* @author Gabe Abrams
|
|
8
|
+
* @param num the number being analyzed
|
|
9
|
+
* @returns ordinal
|
|
10
|
+
*/
|
|
11
|
+
var getOrdinal = function (num) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
return ((_b = (_a = ORDINALS[(num - 20) % 10]) !== null && _a !== void 0 ? _a : ORDINALS[num]) !== null && _b !== void 0 ? _b : ORDINALS[0]);
|
|
14
|
+
};
|
|
15
|
+
exports.default = getOrdinal;
|
|
16
|
+
//# sourceMappingURL=getOrdinal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrdinal.js","sourceRoot":"","sources":["../../src/helpers/getOrdinal.ts"],"names":[],"mappings":";;AAAA,YAAY;AACZ,IAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,IAAM,UAAU,GAAG,UAAC,GAAW;;IAC7B,OAAO,CAAC,MAAA,MAAA,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,mCAAI,QAAQ,CAAC,GAAG,CAAC,mCAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Test file for the getOrdinal 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 getOrdinal_1 = __importDefault(require("./getOrdinal"));
|
|
12
|
+
describe('getOrdinal', function () {
|
|
13
|
+
it('should return "th" for 0', function () {
|
|
14
|
+
var result = (0, getOrdinal_1.default)(0);
|
|
15
|
+
expect(result).toEqual('th');
|
|
16
|
+
});
|
|
17
|
+
it('should return "st" for 1', function () {
|
|
18
|
+
var result = (0, getOrdinal_1.default)(1);
|
|
19
|
+
expect(result).toEqual('st');
|
|
20
|
+
});
|
|
21
|
+
it('should return "nd" for 2', function () {
|
|
22
|
+
var result = (0, getOrdinal_1.default)(2);
|
|
23
|
+
expect(result).toEqual('nd');
|
|
24
|
+
});
|
|
25
|
+
it('should return "rd" for 3', function () {
|
|
26
|
+
var result = (0, getOrdinal_1.default)(3);
|
|
27
|
+
expect(result).toEqual('rd');
|
|
28
|
+
});
|
|
29
|
+
it('should return "th" for 4', function () {
|
|
30
|
+
var result = (0, getOrdinal_1.default)(4);
|
|
31
|
+
expect(result).toEqual('th');
|
|
32
|
+
});
|
|
33
|
+
it('should return "th" for 11', function () {
|
|
34
|
+
var result = (0, getOrdinal_1.default)(11);
|
|
35
|
+
expect(result).toEqual('th');
|
|
36
|
+
});
|
|
37
|
+
it('should return "st" for 21', function () {
|
|
38
|
+
var result = (0, getOrdinal_1.default)(21);
|
|
39
|
+
expect(result).toEqual('st');
|
|
40
|
+
});
|
|
41
|
+
it('should return "nd" for 22', function () {
|
|
42
|
+
var result = (0, getOrdinal_1.default)(22);
|
|
43
|
+
expect(result).toEqual('nd');
|
|
44
|
+
});
|
|
45
|
+
it('should return "rd" for 23', function () {
|
|
46
|
+
var result = (0, getOrdinal_1.default)(23);
|
|
47
|
+
expect(result).toEqual('rd');
|
|
48
|
+
});
|
|
49
|
+
it('should return "th" for 24', function () {
|
|
50
|
+
var result = (0, getOrdinal_1.default)(24);
|
|
51
|
+
expect(result).toEqual('th');
|
|
52
|
+
});
|
|
53
|
+
it('should return "th" for 100', function () {
|
|
54
|
+
var result = (0, getOrdinal_1.default)(100);
|
|
55
|
+
expect(result).toEqual('th');
|
|
56
|
+
});
|
|
57
|
+
it('should return "st" for 101', function () {
|
|
58
|
+
var result = (0, getOrdinal_1.default)(101);
|
|
59
|
+
expect(result).toEqual('st');
|
|
60
|
+
});
|
|
61
|
+
it('should return "nd" for 102', function () {
|
|
62
|
+
var result = (0, getOrdinal_1.default)(102);
|
|
63
|
+
expect(result).toEqual('nd');
|
|
64
|
+
});
|
|
65
|
+
it('should return "rd" for 103', function () {
|
|
66
|
+
var result = (0, getOrdinal_1.default)(103);
|
|
67
|
+
expect(result).toEqual('rd');
|
|
68
|
+
});
|
|
69
|
+
it('should return "th" for 104', function () {
|
|
70
|
+
var result = (0, getOrdinal_1.default)(104);
|
|
71
|
+
expect(result).toEqual('th');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
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B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE;QAC/B,IAAM,MAAM,GAAG,IAAA,oBAAU,EAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE;QAC/B,IAAM,MAAM,GAAG,IAAA,oBAAU,EAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE;QAC/B,IAAM,MAAM,GAAG,IAAA,oBAAU,EAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Get the current part of day (morning, evening, etc.)
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
* @returns the part of day (morning, evening, etc.)
|
|
7
|
+
*/
|
|
8
|
+
var getPartOfDay = function () {
|
|
9
|
+
// Setup the post-it time of day
|
|
10
|
+
var partOfDay = 'day';
|
|
11
|
+
var hours = new Date().getHours();
|
|
12
|
+
if (hours < 12) {
|
|
13
|
+
partOfDay = 'morning';
|
|
14
|
+
}
|
|
15
|
+
else if (hours >= 12 && hours <= 16) {
|
|
16
|
+
partOfDay = 'afternoon';
|
|
17
|
+
}
|
|
18
|
+
else if (hours > 16 && hours <= 24) {
|
|
19
|
+
partOfDay = 'evening';
|
|
20
|
+
}
|
|
21
|
+
return partOfDay;
|
|
22
|
+
};
|
|
23
|
+
exports.default = getPartOfDay;
|
|
24
|
+
//# sourceMappingURL=getPartOfDay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPartOfDay.js","sourceRoot":"","sources":["../../src/helpers/getPartOfDay.ts"],"names":[],"mappings":";;AAAA;;;;GAIG;AACH,IAAM,YAAY,GAAG;IACnB,gCAAgC;IAChC,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC;IACpC,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QACf,SAAS,GAAG,SAAS,CAAC;IACxB,CAAC;SAAM,IAAI,KAAK,IAAI,EAAE,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;QACtC,SAAS,GAAG,WAAW,CAAC;IAC1B,CAAC;SAAM,IAAI,KAAK,GAAG,EAAE,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;QACrC,SAAS,GAAG,SAAS,CAAC;IACxB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|