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,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
/**
|
|
40
|
+
* Run the operator function on each item in the array
|
|
41
|
+
* @author Gabe Abrams
|
|
42
|
+
* @param operatorFunction the operator function to apply
|
|
43
|
+
*/
|
|
44
|
+
var forEachAsync = function (array, operatorFunction) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
+
var done, breakNow, i;
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0:
|
|
49
|
+
done = false;
|
|
50
|
+
breakNow = function () {
|
|
51
|
+
done = true;
|
|
52
|
+
};
|
|
53
|
+
i = 0;
|
|
54
|
+
_a.label = 1;
|
|
55
|
+
case 1:
|
|
56
|
+
if (!(i < array.length && !done)) return [3 /*break*/, 4];
|
|
57
|
+
return [4 /*yield*/, operatorFunction(array[i], i, {
|
|
58
|
+
breakNow: breakNow,
|
|
59
|
+
array: array,
|
|
60
|
+
})];
|
|
61
|
+
case 2:
|
|
62
|
+
_a.sent();
|
|
63
|
+
_a.label = 3;
|
|
64
|
+
case 3:
|
|
65
|
+
i++;
|
|
66
|
+
return [3 /*break*/, 1];
|
|
67
|
+
case 4: return [2 /*return*/];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}); };
|
|
71
|
+
exports.default = forEachAsync;
|
|
72
|
+
//# sourceMappingURL=forEachAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forEachAsync.js","sourceRoot":"","sources":["../../../src/helpers/asyncArrayFunctions/forEachAsync.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,IAAM,YAAY,GAAG,UACnB,KAAU,EACV,gBAOS;;;;;gBAGL,IAAI,GAAG,KAAK,CAAC;gBAKX,QAAQ,GAAG;oBACf,IAAI,GAAG,IAAI,CAAC;gBACd,CAAC,CAAC;gBAGO,CAAC,GAAG,CAAC;;;qBAAE,CAAA,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,CAAA;gBACvC,qBAAM,gBAAgB,CACpB,KAAK,CAAC,CAAC,CAAC,EACR,CAAC,EACD;wBACE,QAAQ,UAAA;wBACR,KAAK,OAAA;qBACN,CACF,EAAA;;gBAPD,SAOC,CAAC;;;gBARuC,CAAC,EAAE,CAAA;;;;;KAU/C,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var forEachAsync_1 = __importDefault(require("./forEachAsync"));
|
|
43
|
+
describe('forEachAsync', function () {
|
|
44
|
+
it('should call the operator function for each item in the array', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
+
var array, operatorFunction;
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0:
|
|
49
|
+
array = [1, 2, 3];
|
|
50
|
+
operatorFunction = jest.fn();
|
|
51
|
+
return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
|
|
52
|
+
case 1:
|
|
53
|
+
_a.sent();
|
|
54
|
+
expect(operatorFunction).toHaveBeenCalledTimes(3);
|
|
55
|
+
expect(operatorFunction).toHaveBeenCalledWith(1, 0, expect.any(Object));
|
|
56
|
+
expect(operatorFunction).toHaveBeenCalledWith(2, 1, expect.any(Object));
|
|
57
|
+
expect(operatorFunction).toHaveBeenCalledWith(3, 2, expect.any(Object));
|
|
58
|
+
return [2 /*return*/];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}); });
|
|
62
|
+
it('should pass the correct arguments to the operator function', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
63
|
+
var array, operatorFunction;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0:
|
|
67
|
+
array = ['a', 'b', 'c'];
|
|
68
|
+
operatorFunction = jest.fn();
|
|
69
|
+
return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
|
|
70
|
+
case 1:
|
|
71
|
+
_a.sent();
|
|
72
|
+
expect(operatorFunction).toHaveBeenCalledTimes(3);
|
|
73
|
+
expect(operatorFunction).toHaveBeenCalledWith('a', 0, expect.any(Object));
|
|
74
|
+
expect(operatorFunction).toHaveBeenCalledWith('b', 1, expect.any(Object));
|
|
75
|
+
expect(operatorFunction).toHaveBeenCalledWith('c', 2, expect.any(Object));
|
|
76
|
+
return [2 /*return*/];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}); });
|
|
80
|
+
it('should allow the operator function to break out of the loop', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
|
+
var array, operatorFunction;
|
|
82
|
+
return __generator(this, function (_a) {
|
|
83
|
+
switch (_a.label) {
|
|
84
|
+
case 0:
|
|
85
|
+
array = [1, 2, 3];
|
|
86
|
+
operatorFunction = jest.fn(function (item, index, _a) {
|
|
87
|
+
var breakNow = _a.breakNow;
|
|
88
|
+
if (item === 2) {
|
|
89
|
+
breakNow();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
|
|
93
|
+
case 1:
|
|
94
|
+
_a.sent();
|
|
95
|
+
expect(operatorFunction).toHaveBeenCalledTimes(2);
|
|
96
|
+
expect(operatorFunction).toHaveBeenCalledWith(1, 0, expect.any(Object));
|
|
97
|
+
expect(operatorFunction).toHaveBeenCalledWith(2, 1, expect.any(Object));
|
|
98
|
+
return [2 /*return*/];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}); });
|
|
102
|
+
it('should not call the operator function if the array is empty', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
103
|
+
var array, operatorFunction;
|
|
104
|
+
return __generator(this, function (_a) {
|
|
105
|
+
switch (_a.label) {
|
|
106
|
+
case 0:
|
|
107
|
+
array = [];
|
|
108
|
+
operatorFunction = jest.fn();
|
|
109
|
+
return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
|
|
110
|
+
case 1:
|
|
111
|
+
_a.sent();
|
|
112
|
+
expect(operatorFunction).not.toHaveBeenCalled();
|
|
113
|
+
return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}); });
|
|
117
|
+
it('should return undefined', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
118
|
+
var array, operatorFunction, result;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
switch (_a.label) {
|
|
121
|
+
case 0:
|
|
122
|
+
array = [1, 2, 3];
|
|
123
|
+
operatorFunction = jest.fn();
|
|
124
|
+
return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
|
|
125
|
+
case 1:
|
|
126
|
+
result = _a.sent();
|
|
127
|
+
expect(result).toBeUndefined();
|
|
128
|
+
return [2 /*return*/];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}); });
|
|
132
|
+
it('should work with an array of objects', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
133
|
+
var array, operatorFunction;
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
switch (_a.label) {
|
|
136
|
+
case 0:
|
|
137
|
+
array = [
|
|
138
|
+
{ name: 'Alice', age: 30 },
|
|
139
|
+
{ name: 'Bob', age: 25 },
|
|
140
|
+
{ name: 'Charlie', age: 40 },
|
|
141
|
+
];
|
|
142
|
+
operatorFunction = jest.fn();
|
|
143
|
+
return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
|
|
144
|
+
case 1:
|
|
145
|
+
_a.sent();
|
|
146
|
+
expect(operatorFunction).toHaveBeenCalledTimes(3);
|
|
147
|
+
expect(operatorFunction).toHaveBeenCalledWith({ name: 'Alice', age: 30 }, 0, expect.any(Object));
|
|
148
|
+
expect(operatorFunction).toHaveBeenCalledWith({ name: 'Bob', age: 25 }, 1, expect.any(Object));
|
|
149
|
+
expect(operatorFunction).toHaveBeenCalledWith({ name: 'Charlie', age: 40 }, 2, expect.any(Object));
|
|
150
|
+
return [2 /*return*/];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}); });
|
|
154
|
+
it('should work with an array of mixed types', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
155
|
+
var array, operatorFunction;
|
|
156
|
+
return __generator(this, function (_a) {
|
|
157
|
+
switch (_a.label) {
|
|
158
|
+
case 0:
|
|
159
|
+
array = [1, 'two', { three: 3 }];
|
|
160
|
+
operatorFunction = jest.fn();
|
|
161
|
+
return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
|
|
162
|
+
case 1:
|
|
163
|
+
_a.sent();
|
|
164
|
+
expect(operatorFunction).toHaveBeenCalledTimes(3);
|
|
165
|
+
expect(operatorFunction).toHaveBeenCalledWith(1, 0, expect.any(Object));
|
|
166
|
+
expect(operatorFunction).toHaveBeenCalledWith('two', 1, expect.any(Object));
|
|
167
|
+
expect(operatorFunction).toHaveBeenCalledWith({ three: 3 }, 2, expect.any(Object));
|
|
168
|
+
return [2 /*return*/];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}); });
|
|
172
|
+
it('should work with an array of length 1', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
173
|
+
var array, operatorFunction;
|
|
174
|
+
return __generator(this, function (_a) {
|
|
175
|
+
switch (_a.label) {
|
|
176
|
+
case 0:
|
|
177
|
+
array = ['a'];
|
|
178
|
+
operatorFunction = jest.fn();
|
|
179
|
+
return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
|
|
180
|
+
case 1:
|
|
181
|
+
_a.sent();
|
|
182
|
+
expect(operatorFunction).toHaveBeenCalledTimes(1);
|
|
183
|
+
expect(operatorFunction).toHaveBeenCalledWith('a', 0, expect.any(Object));
|
|
184
|
+
return [2 /*return*/];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}); });
|
|
188
|
+
it('should work with an array of length 100', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
189
|
+
var array, operatorFunction;
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
switch (_a.label) {
|
|
192
|
+
case 0:
|
|
193
|
+
array = Array.from({ length: 100 }, function (_, i) { return i; });
|
|
194
|
+
operatorFunction = jest.fn();
|
|
195
|
+
return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
|
|
196
|
+
case 1:
|
|
197
|
+
_a.sent();
|
|
198
|
+
expect(operatorFunction).toHaveBeenCalledTimes(100);
|
|
199
|
+
expect(operatorFunction).toHaveBeenCalledWith(0, 0, expect.any(Object));
|
|
200
|
+
expect(operatorFunction).toHaveBeenCalledWith(99, 99, expect.any(Object));
|
|
201
|
+
return [2 /*return*/];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}); });
|
|
205
|
+
it('should work with an array of length 1000', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
206
|
+
var array, operatorFunction;
|
|
207
|
+
return __generator(this, function (_a) {
|
|
208
|
+
switch (_a.label) {
|
|
209
|
+
case 0:
|
|
210
|
+
array = Array.from({ length: 1000 }, function (_, i) { return i; });
|
|
211
|
+
operatorFunction = jest.fn();
|
|
212
|
+
return [4 /*yield*/, (0, forEachAsync_1.default)(array, operatorFunction)];
|
|
213
|
+
case 1:
|
|
214
|
+
_a.sent();
|
|
215
|
+
expect(operatorFunction).toHaveBeenCalledTimes(1000);
|
|
216
|
+
expect(operatorFunction).toHaveBeenCalledWith(0, 0, expect.any(Object));
|
|
217
|
+
expect(operatorFunction).toHaveBeenCalledWith(999, 999, expect.any(Object));
|
|
218
|
+
return [2 /*return*/];
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}); });
|
|
222
|
+
});
|
|
223
|
+
//# sourceMappingURL=forEachAsync.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forEachAsync.test.js","sourceRoot":"","sources":["../../../src/helpers/asyncArrayFunctions/forEachAsync.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAA0C;AAE1C,QAAQ,CAAC,cAAc,EAAE;IACvB,EAAE,CAAC,8DAA8D,EAAE;;;;;oBAC3D,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;oBAClB,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;oBAEnC,qBAAM,IAAA,sBAAY,EAAC,KAAK,EAAE,gBAAgB,CAAC,EAAA;;oBAA3C,SAA2C,CAAC;oBAE5C,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;oBAClD,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;oBACxE,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;oBACxE,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;;;;SACzE,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE;;;;;oBACzD,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;oBACxB,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;oBAEnC,qBAAM,IAAA,sBAAY,EAAC,KAAK,EAAE,gBAAgB,CAAC,EAAA;;oBAA3C,SAA2C,CAAC;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,CAAC,CAAC,CAAC;oBAClD,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;oBAEnC,qBAAM,IAAA,sBAAY,EAAC,KAAK,EAAE,gBAAgB,CAAC,EAAA;;oBAA3C,SAA2C,CAAC;oBAE5C,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;oBACrD,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;oBACxE,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;;;;SAC7E,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run the operator function on each item in the array, collecting all results
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param operatorFunction the operator function to apply
|
|
5
|
+
* @returns the array of results
|
|
6
|
+
*/
|
|
7
|
+
declare const mapAsync: <T, U>(array: T[], operatorFunction: (item: T, index: number, opts: {
|
|
8
|
+
breakNow: () => void;
|
|
9
|
+
array: Array<T>;
|
|
10
|
+
}) => Promise<U>) => Promise<U[]>;
|
|
11
|
+
export default mapAsync;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
/**
|
|
40
|
+
* Run the operator function on each item in the array, collecting all results
|
|
41
|
+
* @author Gabe Abrams
|
|
42
|
+
* @param operatorFunction the operator function to apply
|
|
43
|
+
* @returns the array of results
|
|
44
|
+
*/
|
|
45
|
+
var mapAsync = function (array, operatorFunction) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
var done, breakNow, results, i, result;
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
done = false;
|
|
51
|
+
breakNow = function () {
|
|
52
|
+
done = true;
|
|
53
|
+
};
|
|
54
|
+
results = [];
|
|
55
|
+
i = 0;
|
|
56
|
+
_a.label = 1;
|
|
57
|
+
case 1:
|
|
58
|
+
if (!(i < array.length && !done)) return [3 /*break*/, 4];
|
|
59
|
+
return [4 /*yield*/, operatorFunction(array[i], i, {
|
|
60
|
+
breakNow: breakNow,
|
|
61
|
+
array: array,
|
|
62
|
+
})];
|
|
63
|
+
case 2:
|
|
64
|
+
result = _a.sent();
|
|
65
|
+
results.push(result);
|
|
66
|
+
_a.label = 3;
|
|
67
|
+
case 3:
|
|
68
|
+
i++;
|
|
69
|
+
return [3 /*break*/, 1];
|
|
70
|
+
case 4:
|
|
71
|
+
// Return results
|
|
72
|
+
return [2 /*return*/, results];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}); };
|
|
76
|
+
exports.default = mapAsync;
|
|
77
|
+
//# sourceMappingURL=mapAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapAsync.js","sourceRoot":"","sources":["../../../src/helpers/asyncArrayFunctions/mapAsync.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,IAAM,QAAQ,GAAG,UACf,KAAU,EACV,gBAOe;;;;;gBAGX,IAAI,GAAG,KAAK,CAAC;gBAKX,QAAQ,GAAG;oBACf,IAAI,GAAG,IAAI,CAAC;gBACd,CAAC,CAAC;gBAGI,OAAO,GAAQ,EAAE,CAAC;gBACf,CAAC,GAAG,CAAC;;;qBAAE,CAAA,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,CAAA;gBACxB,qBAAM,gBAAgB,CACnC,KAAK,CAAC,CAAC,CAAC,EACR,CAAC,EACD;wBACE,QAAQ,UAAA;wBACR,KAAK,OAAA;qBACN,CACF,EAAA;;gBAPK,MAAM,GAAG,SAOd;gBACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;;gBAToB,CAAC,EAAE,CAAA;;;YAY9C,iBAAiB;YACjB,sBAAO,OAAO,EAAC;;;KAChB,CAAC;AAEF,kBAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var waitMs_1 = __importDefault(require("../waitMs"));
|
|
43
|
+
var mapAsync_1 = __importDefault(require("./mapAsync"));
|
|
44
|
+
describe('mapAsync', function () {
|
|
45
|
+
it('should return an empty array when given an empty array', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
var result;
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0: return [4 /*yield*/, (0, mapAsync_1.default)([], function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
return [2 /*return*/];
|
|
52
|
+
});
|
|
53
|
+
}); })];
|
|
54
|
+
case 1:
|
|
55
|
+
result = _a.sent();
|
|
56
|
+
expect(result).toEqual([]);
|
|
57
|
+
return [2 /*return*/];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}); });
|
|
61
|
+
it('should apply the operator function to each item in the array', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
+
var array, operatorFunction;
|
|
63
|
+
return __generator(this, function (_a) {
|
|
64
|
+
switch (_a.label) {
|
|
65
|
+
case 0:
|
|
66
|
+
array = [1, 2, 3];
|
|
67
|
+
operatorFunction = jest.fn();
|
|
68
|
+
return [4 /*yield*/, (0, mapAsync_1.default)(array, operatorFunction)];
|
|
69
|
+
case 1:
|
|
70
|
+
_a.sent();
|
|
71
|
+
expect(operatorFunction).toHaveBeenCalledTimes(3);
|
|
72
|
+
expect(operatorFunction).toHaveBeenCalledWith(1, 0, expect.any(Object));
|
|
73
|
+
expect(operatorFunction).toHaveBeenCalledWith(2, 1, expect.any(Object));
|
|
74
|
+
expect(operatorFunction).toHaveBeenCalledWith(3, 2, expect.any(Object));
|
|
75
|
+
return [2 /*return*/];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}); });
|
|
79
|
+
it('should collect and return the results of the operator function', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
+
var array, operatorFunction, result;
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
array = [1, 2, 3];
|
|
85
|
+
operatorFunction = function (item) { return __awaiter(void 0, void 0, void 0, function () {
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
return [2 /*return*/, item * 2];
|
|
88
|
+
});
|
|
89
|
+
}); };
|
|
90
|
+
return [4 /*yield*/, (0, mapAsync_1.default)(array, operatorFunction)];
|
|
91
|
+
case 1:
|
|
92
|
+
result = _a.sent();
|
|
93
|
+
expect(result).toEqual([2, 4, 6]);
|
|
94
|
+
return [2 /*return*/];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}); });
|
|
98
|
+
it('should pass the correct index to the operator function', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
+
var array, operatorFunction;
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
array = [1, 2, 3];
|
|
104
|
+
operatorFunction = jest.fn();
|
|
105
|
+
return [4 /*yield*/, (0, mapAsync_1.default)(array, operatorFunction)];
|
|
106
|
+
case 1:
|
|
107
|
+
_a.sent();
|
|
108
|
+
expect(operatorFunction).toHaveBeenCalledWith(expect.anything(), 0, expect.any(Object));
|
|
109
|
+
expect(operatorFunction).toHaveBeenCalledWith(expect.anything(), 1, expect.any(Object));
|
|
110
|
+
expect(operatorFunction).toHaveBeenCalledWith(expect.anything(), 2, expect.any(Object));
|
|
111
|
+
return [2 /*return*/];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}); });
|
|
115
|
+
it('should pass the correct options object to the operator function', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
116
|
+
var array, operatorFunction;
|
|
117
|
+
return __generator(this, function (_a) {
|
|
118
|
+
switch (_a.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
array = [1, 2, 3];
|
|
121
|
+
operatorFunction = jest.fn();
|
|
122
|
+
return [4 /*yield*/, (0, mapAsync_1.default)(array, operatorFunction)];
|
|
123
|
+
case 1:
|
|
124
|
+
_a.sent();
|
|
125
|
+
expect(operatorFunction).toHaveBeenCalledWith(expect.anything(), expect.anything(), {
|
|
126
|
+
breakNow: expect.any(Function),
|
|
127
|
+
array: expect.any(Array),
|
|
128
|
+
});
|
|
129
|
+
return [2 /*return*/];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}); });
|
|
133
|
+
it('should allow the operator function to break the loop', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
134
|
+
var array, result;
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
switch (_a.label) {
|
|
137
|
+
case 0:
|
|
138
|
+
array = [1, 2, 3];
|
|
139
|
+
return [4 /*yield*/, (0, mapAsync_1.default)(array, function (item_1, index_1, _a) { return __awaiter(void 0, [item_1, index_1, _a], void 0, function (item, index, _b) {
|
|
140
|
+
var breakNow = _b.breakNow;
|
|
141
|
+
return __generator(this, function (_c) {
|
|
142
|
+
if (item === 2) {
|
|
143
|
+
breakNow();
|
|
144
|
+
}
|
|
145
|
+
return [2 /*return*/, item];
|
|
146
|
+
});
|
|
147
|
+
}); })];
|
|
148
|
+
case 1:
|
|
149
|
+
result = _a.sent();
|
|
150
|
+
expect(result).toEqual([1]);
|
|
151
|
+
return [2 /*return*/];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}); });
|
|
155
|
+
it('should handle asynchronous operator function', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
156
|
+
var array, result;
|
|
157
|
+
return __generator(this, function (_a) {
|
|
158
|
+
switch (_a.label) {
|
|
159
|
+
case 0:
|
|
160
|
+
array = [1, 2, 3];
|
|
161
|
+
return [4 /*yield*/, (0, mapAsync_1.default)(array, function (item) { return __awaiter(void 0, void 0, void 0, function () {
|
|
162
|
+
return __generator(this, function (_a) {
|
|
163
|
+
switch (_a.label) {
|
|
164
|
+
case 0: return [4 /*yield*/, (0, waitMs_1.default)(1000)];
|
|
165
|
+
case 1:
|
|
166
|
+
_a.sent();
|
|
167
|
+
return [2 /*return*/, item * 2];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}); })];
|
|
171
|
+
case 1:
|
|
172
|
+
result = _a.sent();
|
|
173
|
+
expect(result).toEqual([2, 4, 6]);
|
|
174
|
+
return [2 /*return*/];
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}); });
|
|
178
|
+
it('should handle errors thrown by the operator function', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
179
|
+
var array;
|
|
180
|
+
return __generator(this, function (_a) {
|
|
181
|
+
switch (_a.label) {
|
|
182
|
+
case 0:
|
|
183
|
+
array = [1, 2, 3];
|
|
184
|
+
return [4 /*yield*/, expect((0, mapAsync_1.default)(array, function (item) { return __awaiter(void 0, void 0, void 0, function () {
|
|
185
|
+
return __generator(this, function (_a) {
|
|
186
|
+
if (item === 2) {
|
|
187
|
+
throw new Error('Error processing item');
|
|
188
|
+
}
|
|
189
|
+
return [2 /*return*/, item * 2];
|
|
190
|
+
});
|
|
191
|
+
}); })).rejects.toThrow('Error processing item')];
|
|
192
|
+
case 1:
|
|
193
|
+
_a.sent();
|
|
194
|
+
return [2 /*return*/];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}); });
|
|
198
|
+
it('should handle empty array with breakNow called', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
199
|
+
var array, result;
|
|
200
|
+
return __generator(this, function (_a) {
|
|
201
|
+
switch (_a.label) {
|
|
202
|
+
case 0:
|
|
203
|
+
array = [];
|
|
204
|
+
return [4 /*yield*/, (0, mapAsync_1.default)(array, function (item_1, index_1, _a) { return __awaiter(void 0, [item_1, index_1, _a], void 0, function (item, index, _b) {
|
|
205
|
+
var breakNow = _b.breakNow;
|
|
206
|
+
return __generator(this, function (_c) {
|
|
207
|
+
breakNow();
|
|
208
|
+
return [2 /*return*/, item];
|
|
209
|
+
});
|
|
210
|
+
}); })];
|
|
211
|
+
case 1:
|
|
212
|
+
result = _a.sent();
|
|
213
|
+
expect(result).toEqual([]);
|
|
214
|
+
return [2 /*return*/];
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}); });
|
|
218
|
+
});
|
|
219
|
+
//# sourceMappingURL=mapAsync.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapAsync.test.js","sourceRoot":"","sources":["../../../src/helpers/asyncArrayFunctions/mapAsync.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA+B;AAC/B,wDAAkC;AAElC,QAAQ,CAAC,UAAU,EAAE;IACnB,EAAE,CAAC,wDAAwD,EAAE;;;;wBAC5C,qBAAM,IAAA,kBAAQ,EAAC,EAAE,EAAE;;;;yBAEjC,CAAC,EAAA;;oBAFI,MAAM,GAAG,SAEb;oBAEF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;;;;SAC5B,CAAC,CAAC;IAEH,EAAE,CAAC,8DAA8D,EAAE;;;;;oBAC3D,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;oBAClB,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;oBAEnC,qBAAM,IAAA,kBAAQ,EAAC,KAAK,EAAE,gBAAgB,CAAC,EAAA;;oBAAvC,SAAuC,CAAC;oBAExC,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;oBAClD,MAAM,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAA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