@webdeveric/utils 0.83.1 → 0.83.2
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/dist/cjs/asArray.js +9 -0
- package/dist/cjs/asError.js +9 -0
- package/dist/cjs/assertion/assertExhaustive.js +19 -0
- package/dist/cjs/assertion/assertIsAsyncIterable.js +13 -0
- package/dist/cjs/assertion/assertIsBigInt.js +9 -0
- package/dist/cjs/assertion/assertIsBigIntArray.js +9 -0
- package/dist/cjs/assertion/assertIsBoolean.js +9 -0
- package/dist/cjs/assertion/assertIsBooleanArray.js +9 -0
- package/dist/cjs/assertion/assertIsDigitsString.js +9 -0
- package/dist/cjs/assertion/assertIsFiniteNumber.js +9 -0
- package/dist/cjs/assertion/assertIsFunction.js +9 -0
- package/dist/cjs/assertion/assertIsInt32.js +9 -0
- package/dist/cjs/assertion/assertIsIntString.js +9 -0
- package/dist/cjs/assertion/assertIsInteger.js +9 -0
- package/dist/cjs/assertion/assertIsIterable.js +9 -0
- package/dist/cjs/assertion/assertIsLengthAware.js +9 -0
- package/dist/cjs/assertion/assertIsNull.js +9 -0
- package/dist/cjs/assertion/assertIsNullArray.js +9 -0
- package/dist/cjs/assertion/assertIsNumber.js +9 -0
- package/dist/cjs/assertion/assertIsNumberArray.js +9 -0
- package/dist/cjs/assertion/assertIsNumberGTEOne.js +9 -0
- package/dist/cjs/assertion/assertIsNumericString.js +9 -0
- package/dist/cjs/assertion/assertIsNumericValue.js +11 -0
- package/dist/cjs/assertion/assertIsNumericValueArray.js +9 -0
- package/dist/cjs/assertion/assertIsObject.js +10 -0
- package/dist/cjs/assertion/assertIsOptionalBigInt.js +10 -0
- package/dist/cjs/assertion/assertIsOptionalBoolean.js +10 -0
- package/dist/cjs/assertion/assertIsOptionalNull.js +10 -0
- package/dist/cjs/assertion/assertIsOptionalNumber.js +10 -0
- package/dist/cjs/assertion/assertIsOptionalString.js +10 -0
- package/dist/cjs/assertion/assertIsOptionalSymbol.js +10 -0
- package/dist/cjs/assertion/assertIsPositiveFiniteNumber.js +9 -0
- package/dist/cjs/assertion/assertIsPositiveInteger.js +9 -0
- package/dist/cjs/assertion/assertIsPrimitive.js +9 -0
- package/dist/cjs/assertion/assertIsPromiseFulfilledResult.js +11 -0
- package/dist/cjs/assertion/assertIsPromiseRejectedResult.js +11 -0
- package/dist/cjs/assertion/assertIsPropertyKey.js +11 -0
- package/dist/cjs/assertion/assertIsSafeInteger.js +9 -0
- package/dist/cjs/assertion/assertIsSizeAware.js +9 -0
- package/dist/cjs/assertion/assertIsString.js +9 -0
- package/dist/cjs/assertion/assertIsStringArray.js +9 -0
- package/dist/cjs/assertion/assertIsStringMatching.js +9 -0
- package/dist/cjs/assertion/assertIsStringRecord.js +9 -0
- package/dist/cjs/assertion/assertIsStringWithLength.js +9 -0
- package/dist/cjs/assertion/assertIsSymbol.js +9 -0
- package/dist/cjs/assertion/assertIsSymbolArray.js +9 -0
- package/dist/cjs/assertion/assertIsUndefined.js +9 -0
- package/dist/cjs/assertion/assertIsUndefinedArray.js +9 -0
- package/dist/cjs/assertion/assertPathExists.js +12 -0
- package/dist/cjs/assertion/assertPredicate.js +11 -0
- package/dist/cjs/assertion/getError.js +9 -0
- package/dist/cjs/capitalize.js +8 -0
- package/dist/cjs/cartesian.js +10 -0
- package/dist/cjs/chunk.js +8 -0
- package/dist/cjs/clamp.js +9 -0
- package/dist/cjs/combinations.js +8 -0
- package/dist/cjs/comment.js +11 -0
- package/dist/cjs/compose.js +11 -0
- package/dist/cjs/constants.js +2 -0
- package/dist/cjs/convert.js +8 -0
- package/dist/cjs/countCharCode.js +8 -0
- package/dist/cjs/countCharacter.js +8 -0
- package/dist/cjs/counter.js +8 -0
- package/dist/cjs/dedent.js +14 -0
- package/dist/cjs/deepDecodeURI.js +8 -0
- package/dist/cjs/deepFreeze.js +13 -0
- package/dist/cjs/delay.js +14 -0
- package/dist/cjs/delayAnimationFrame.js +9 -0
- package/dist/cjs/delayAnimationFrames.js +9 -0
- package/dist/cjs/describeInput.js +12 -0
- package/dist/cjs/escapeRegExp.js +8 -0
- package/dist/cjs/findIndentation.js +8 -0
- package/dist/cjs/get.js +9 -0
- package/dist/cjs/getDateString.js +8 -0
- package/dist/cjs/getISODateString.js +8 -0
- package/dist/cjs/getMaxValue.js +8 -0
- package/dist/cjs/getMilliseconds.js +9 -0
- package/dist/cjs/getMinValue.js +8 -0
- package/dist/cjs/getOwnKeys.js +8 -0
- package/dist/cjs/getOwnPaths.js +8 -0
- package/dist/cjs/getOwnProperties.js +8 -0
- package/dist/cjs/getPackageName.js +9 -0
- package/dist/cjs/getPaths.js +8 -0
- package/dist/cjs/getRandomItem.js +8 -0
- package/dist/cjs/getSortedObject.js +8 -0
- package/dist/cjs/getType.js +9 -0
- package/dist/cjs/has.js +9 -0
- package/dist/cjs/hasAdditionalProperties.js +9 -0
- package/dist/cjs/inRange.js +9 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/isEmpty.js +9 -0
- package/dist/cjs/iterateForever.js +13 -0
- package/dist/cjs/joinStrings.js +8 -0
- package/dist/cjs/jsonParse.js +8 -0
- package/dist/cjs/looksLikeURL.js +10 -0
- package/dist/cjs/normalize.js +17 -0
- package/dist/cjs/numbers.js +3 -3
- package/dist/cjs/parseNumber.js +9 -0
- package/dist/cjs/pathParts.js +8 -0
- package/dist/cjs/predicate/assume.js +14 -0
- package/dist/cjs/predicate/factory/allOf.js +11 -0
- package/dist/cjs/predicate/factory/anyOf.js +11 -0
- package/dist/cjs/predicate/factory/everyItem.js +11 -0
- package/dist/cjs/predicate/factory/fromEnum.js +20 -0
- package/dist/cjs/predicate/factory/instanceOf.js +10 -0
- package/dist/cjs/predicate/factory/is.js +10 -0
- package/dist/cjs/predicate/factory/literal.js +10 -0
- package/dist/cjs/predicate/factory/matching.js +10 -0
- package/dist/cjs/predicate/factory/maybeArray.js +11 -0
- package/dist/cjs/predicate/factory/nonNullable.js +13 -0
- package/dist/cjs/predicate/factory/nullable.js +11 -0
- package/dist/cjs/predicate/factory/nullish.js +12 -0
- package/dist/cjs/predicate/factory/optional.js +11 -0
- package/dist/cjs/predicate/factory/range.js +10 -0
- package/dist/cjs/predicate/factory/shape.js +13 -0
- package/dist/cjs/predicate/factory/simple.js +10 -0
- package/dist/cjs/predicate/factory/stringLength.js +11 -0
- package/dist/cjs/predicate/factory/tuple.js +11 -0
- package/dist/cjs/predicate/factory/typeOf.js +11 -0
- package/dist/cjs/predicate/factory/withLength.js +15 -0
- package/dist/cjs/predicate/factory/withSize.js +14 -0
- package/dist/cjs/predicate/index.js +0 -1
- package/dist/cjs/predicate/isAny.js +10 -0
- package/dist/cjs/predicate/isAnyObject.js +9 -0
- package/dist/cjs/predicate/isAnyObjectWith.js +9 -0
- package/dist/cjs/predicate/isAnyObjectWithOwn.js +9 -0
- package/dist/cjs/predicate/isArray.js +9 -0
- package/dist/cjs/predicate/isAsyncIterable.js +12 -0
- package/dist/cjs/predicate/isBigInt.js +9 -0
- package/dist/cjs/predicate/isBigIntArray.js +9 -0
- package/dist/cjs/predicate/isBinaryNumberString.js +11 -0
- package/dist/cjs/predicate/isBoolean.js +9 -0
- package/dist/cjs/predicate/isBooleanArray.js +9 -0
- package/dist/cjs/predicate/isDateInputString.js +9 -0
- package/dist/cjs/predicate/isDigitsString.js +9 -0
- package/dist/cjs/predicate/isFiniteNumber.js +9 -0
- package/dist/cjs/predicate/isFunction.js +9 -0
- package/dist/cjs/predicate/isHexNumberString.js +11 -0
- package/dist/cjs/predicate/isISODateString.js +12 -0
- package/dist/cjs/predicate/isInt32.js +9 -0
- package/dist/cjs/predicate/isIntString.js +9 -0
- package/dist/cjs/predicate/isInteger.js +9 -0
- package/dist/cjs/predicate/isIterable.js +9 -0
- package/dist/cjs/predicate/isJSONable.js +11 -1
- package/dist/cjs/predicate/isLengthAware.js +9 -0
- package/dist/cjs/predicate/isNonNullable.js +9 -0
- package/dist/cjs/predicate/isNull.js +9 -0
- package/dist/cjs/predicate/isNullArray.js +9 -0
- package/dist/cjs/predicate/isNullish.js +9 -0
- package/dist/cjs/predicate/isNumber.js +9 -0
- package/dist/cjs/predicate/isNumberArray.js +9 -0
- package/dist/cjs/predicate/isNumericString.js +9 -0
- package/dist/cjs/predicate/isNumericValue.js +9 -0
- package/dist/cjs/predicate/isNumericValueArray.js +9 -0
- package/dist/cjs/predicate/isObject.js +9 -0
- package/dist/cjs/predicate/isObjectLiteral.js +9 -0
- package/dist/cjs/predicate/isObjectWith.js +9 -0
- package/dist/cjs/predicate/isOctalNumberString.js +11 -0
- package/dist/cjs/predicate/isOptionalArray.js +9 -0
- package/dist/cjs/predicate/isOptionalBigInt.js +9 -0
- package/dist/cjs/predicate/isOptionalBoolean.js +9 -0
- package/dist/cjs/predicate/isOptionalISODateString.js +9 -0
- package/dist/cjs/predicate/isOptionalNull.js +9 -0
- package/dist/cjs/predicate/isOptionalNumber.js +9 -0
- package/dist/cjs/predicate/isOptionalObject.js +9 -0
- package/dist/cjs/predicate/isOptionalString.js +9 -0
- package/dist/cjs/predicate/isOptionalSymbol.js +9 -0
- package/dist/cjs/predicate/isPositiveFiniteNumber.js +9 -0
- package/dist/cjs/predicate/isPositiveInteger.js +9 -0
- package/dist/cjs/predicate/isPrimitive.js +9 -0
- package/dist/cjs/predicate/isPromiseFulfilledResult.js +9 -0
- package/dist/cjs/predicate/isPromiseLike.js +9 -0
- package/dist/cjs/predicate/isPromiseRejectedResult.js +9 -0
- package/dist/cjs/predicate/isPropertyKey.js +9 -0
- package/dist/cjs/predicate/isSafeInteger.js +9 -0
- package/dist/cjs/predicate/isSizeAware.js +9 -0
- package/dist/cjs/predicate/isString.js +9 -0
- package/dist/cjs/predicate/isStringArray.js +9 -0
- package/dist/cjs/predicate/isStringRecord.js +9 -0
- package/dist/cjs/predicate/isStringWithLength.js +9 -0
- package/dist/cjs/predicate/isSymbol.js +9 -0
- package/dist/cjs/predicate/isSymbolArray.js +9 -0
- package/dist/cjs/predicate/isTimeoutError.js +13 -0
- package/dist/cjs/predicate/isUInt32.js +9 -0
- package/dist/cjs/predicate/isUndefined.js +9 -0
- package/dist/cjs/predicate/isUndefinedArray.js +9 -0
- package/dist/cjs/predicate/isUnknown.js +9 -0
- package/dist/cjs/predicate/isUrlString.js +9 -0
- package/dist/cjs/prefix.js +9 -0
- package/dist/cjs/randomInt.js +9 -0
- package/dist/cjs/redactCredentialsInURL.js +8 -0
- package/dist/cjs/resultify.js +25 -0
- package/dist/cjs/secToString.js +9 -0
- package/dist/cjs/set.js +13 -0
- package/dist/cjs/sort/byLocaleCompare.js +8 -0
- package/dist/cjs/sort/byRandom.js +9 -1
- package/dist/cjs/sort/bySimpleComparison.js +8 -0
- package/dist/cjs/sort/bySubtraction.js +8 -0
- package/dist/cjs/sort/byTimestamp.js +8 -0
- package/dist/cjs/sort/factory/byProperty.js +8 -0
- package/dist/cjs/sort/factory/byReverseOf.js +8 -0
- package/dist/cjs/stripIndent.js +8 -0
- package/dist/cjs/stripWhitespace.js +8 -0
- package/dist/cjs/suffix.js +9 -0
- package/dist/cjs/toPascalCase.js +10 -0
- package/dist/cjs/trimEnd.js +9 -0
- package/dist/cjs/trimIndentation.js +8 -0
- package/dist/cjs/trimStart.js +9 -0
- package/dist/cjs/tryFn.js +11 -0
- package/dist/cjs/tryIt.js +9 -0
- package/dist/cjs/types/common.js +1 -0
- package/dist/cjs/types/utils.js +1 -0
- package/dist/cjs/unique.js +8 -0
- package/dist/cjs/uniqueItems.js +8 -0
- package/dist/cjs/until.js +35 -0
- package/dist/mjs/asArray.js +9 -0
- package/dist/mjs/asError.js +9 -0
- package/dist/mjs/assertion/assertExhaustive.js +19 -0
- package/dist/mjs/assertion/assertIsAsyncIterable.js +13 -0
- package/dist/mjs/assertion/assertIsBigInt.js +9 -0
- package/dist/mjs/assertion/assertIsBigIntArray.js +9 -0
- package/dist/mjs/assertion/assertIsBoolean.js +9 -0
- package/dist/mjs/assertion/assertIsBooleanArray.js +9 -0
- package/dist/mjs/assertion/assertIsDigitsString.js +9 -0
- package/dist/mjs/assertion/assertIsFiniteNumber.js +9 -0
- package/dist/mjs/assertion/assertIsFunction.js +9 -0
- package/dist/mjs/assertion/assertIsInt32.js +9 -0
- package/dist/mjs/assertion/assertIsIntString.js +9 -0
- package/dist/mjs/assertion/assertIsInteger.js +9 -0
- package/dist/mjs/assertion/assertIsIterable.js +9 -0
- package/dist/mjs/assertion/assertIsLengthAware.js +9 -0
- package/dist/mjs/assertion/assertIsNull.js +9 -0
- package/dist/mjs/assertion/assertIsNullArray.js +9 -0
- package/dist/mjs/assertion/assertIsNumber.js +9 -0
- package/dist/mjs/assertion/assertIsNumberArray.js +9 -0
- package/dist/mjs/assertion/assertIsNumberGTEOne.js +9 -0
- package/dist/mjs/assertion/assertIsNumericString.js +9 -0
- package/dist/mjs/assertion/assertIsNumericValue.js +11 -0
- package/dist/mjs/assertion/assertIsNumericValueArray.js +9 -0
- package/dist/mjs/assertion/assertIsObject.js +10 -0
- package/dist/mjs/assertion/assertIsOptionalBigInt.js +10 -0
- package/dist/mjs/assertion/assertIsOptionalBoolean.js +10 -0
- package/dist/mjs/assertion/assertIsOptionalNull.js +10 -0
- package/dist/mjs/assertion/assertIsOptionalNumber.js +10 -0
- package/dist/mjs/assertion/assertIsOptionalString.js +10 -0
- package/dist/mjs/assertion/assertIsOptionalSymbol.js +10 -0
- package/dist/mjs/assertion/assertIsPositiveFiniteNumber.js +9 -0
- package/dist/mjs/assertion/assertIsPositiveInteger.js +9 -0
- package/dist/mjs/assertion/assertIsPrimitive.js +9 -0
- package/dist/mjs/assertion/assertIsPromiseFulfilledResult.js +11 -0
- package/dist/mjs/assertion/assertIsPromiseRejectedResult.js +11 -0
- package/dist/mjs/assertion/assertIsPropertyKey.js +11 -0
- package/dist/mjs/assertion/assertIsSafeInteger.js +9 -0
- package/dist/mjs/assertion/assertIsSizeAware.js +9 -0
- package/dist/mjs/assertion/assertIsString.js +9 -0
- package/dist/mjs/assertion/assertIsStringArray.js +9 -0
- package/dist/mjs/assertion/assertIsStringMatching.js +9 -0
- package/dist/mjs/assertion/assertIsStringRecord.js +9 -0
- package/dist/mjs/assertion/assertIsStringWithLength.js +9 -0
- package/dist/mjs/assertion/assertIsSymbol.js +9 -0
- package/dist/mjs/assertion/assertIsSymbolArray.js +9 -0
- package/dist/mjs/assertion/assertIsUndefined.js +9 -0
- package/dist/mjs/assertion/assertIsUndefinedArray.js +9 -0
- package/dist/mjs/assertion/assertPathExists.js +12 -0
- package/dist/mjs/assertion/assertPredicate.js +11 -0
- package/dist/mjs/assertion/getError.js +9 -0
- package/dist/mjs/capitalize.js +8 -0
- package/dist/mjs/cartesian.js +10 -0
- package/dist/mjs/chunk.js +8 -0
- package/dist/mjs/clamp.js +9 -0
- package/dist/mjs/combinations.js +8 -0
- package/dist/mjs/comment.js +11 -0
- package/dist/mjs/compose.js +11 -0
- package/dist/mjs/constants.js +2 -0
- package/dist/mjs/convert.js +8 -0
- package/dist/mjs/countCharCode.js +8 -0
- package/dist/mjs/countCharacter.js +8 -0
- package/dist/mjs/counter.js +8 -0
- package/dist/mjs/dedent.js +14 -0
- package/dist/mjs/deepDecodeURI.js +8 -0
- package/dist/mjs/deepFreeze.js +13 -0
- package/dist/mjs/delay.js +14 -0
- package/dist/mjs/delayAnimationFrame.js +9 -0
- package/dist/mjs/delayAnimationFrames.js +9 -0
- package/dist/mjs/describeInput.js +12 -0
- package/dist/mjs/escapeRegExp.js +8 -0
- package/dist/mjs/findIndentation.js +8 -0
- package/dist/mjs/get.js +9 -0
- package/dist/mjs/getDateString.js +8 -0
- package/dist/mjs/getISODateString.js +8 -0
- package/dist/mjs/getMaxValue.js +8 -0
- package/dist/mjs/getMilliseconds.js +9 -0
- package/dist/mjs/getMinValue.js +8 -0
- package/dist/mjs/getOwnKeys.js +8 -0
- package/dist/mjs/getOwnPaths.js +8 -0
- package/dist/mjs/getOwnProperties.js +8 -0
- package/dist/mjs/getPackageName.js +9 -0
- package/dist/mjs/getPaths.js +8 -0
- package/dist/mjs/getRandomItem.js +8 -0
- package/dist/mjs/getSortedObject.js +8 -0
- package/dist/mjs/getType.js +9 -0
- package/dist/mjs/has.js +9 -0
- package/dist/mjs/hasAdditionalProperties.js +9 -0
- package/dist/mjs/inRange.js +9 -0
- package/dist/mjs/index.js +2 -0
- package/dist/mjs/isEmpty.js +9 -0
- package/dist/mjs/iterateForever.js +13 -0
- package/dist/mjs/joinStrings.js +8 -0
- package/dist/mjs/jsonParse.js +8 -0
- package/dist/mjs/looksLikeURL.js +10 -0
- package/dist/mjs/normalize.js +17 -0
- package/dist/mjs/numbers.js +3 -3
- package/dist/mjs/parseNumber.js +9 -0
- package/dist/mjs/pathParts.js +8 -0
- package/dist/mjs/predicate/assume.js +14 -0
- package/dist/mjs/predicate/factory/allOf.js +11 -0
- package/dist/mjs/predicate/factory/anyOf.js +11 -0
- package/dist/mjs/predicate/factory/everyItem.js +11 -0
- package/dist/mjs/predicate/factory/fromEnum.js +20 -0
- package/dist/mjs/predicate/factory/instanceOf.js +10 -0
- package/dist/mjs/predicate/factory/is.js +10 -0
- package/dist/mjs/predicate/factory/literal.js +10 -0
- package/dist/mjs/predicate/factory/matching.js +10 -0
- package/dist/mjs/predicate/factory/maybeArray.js +11 -0
- package/dist/mjs/predicate/factory/nonNullable.js +13 -0
- package/dist/mjs/predicate/factory/nullable.js +11 -0
- package/dist/mjs/predicate/factory/nullish.js +12 -0
- package/dist/mjs/predicate/factory/optional.js +11 -0
- package/dist/mjs/predicate/factory/range.js +10 -0
- package/dist/mjs/predicate/factory/shape.js +13 -0
- package/dist/mjs/predicate/factory/simple.js +10 -0
- package/dist/mjs/predicate/factory/stringLength.js +11 -0
- package/dist/mjs/predicate/factory/tuple.js +11 -0
- package/dist/mjs/predicate/factory/typeOf.js +11 -0
- package/dist/mjs/predicate/factory/withLength.js +15 -0
- package/dist/mjs/predicate/factory/withSize.js +14 -0
- package/dist/mjs/predicate/index.js +0 -1
- package/dist/mjs/predicate/isAny.js +10 -0
- package/dist/mjs/predicate/isAnyObject.js +9 -0
- package/dist/mjs/predicate/isAnyObjectWith.js +9 -0
- package/dist/mjs/predicate/isAnyObjectWithOwn.js +9 -0
- package/dist/mjs/predicate/isArray.js +9 -0
- package/dist/mjs/predicate/isAsyncIterable.js +12 -0
- package/dist/mjs/predicate/isBigInt.js +9 -0
- package/dist/mjs/predicate/isBigIntArray.js +9 -0
- package/dist/mjs/predicate/isBinaryNumberString.js +11 -0
- package/dist/mjs/predicate/isBoolean.js +9 -0
- package/dist/mjs/predicate/isBooleanArray.js +9 -0
- package/dist/mjs/predicate/isDateInputString.js +9 -0
- package/dist/mjs/predicate/isDigitsString.js +9 -0
- package/dist/mjs/predicate/isFiniteNumber.js +9 -0
- package/dist/mjs/predicate/isFunction.js +9 -0
- package/dist/mjs/predicate/isHexNumberString.js +11 -0
- package/dist/mjs/predicate/isISODateString.js +12 -0
- package/dist/mjs/predicate/isInt32.js +9 -0
- package/dist/mjs/predicate/isIntString.js +9 -0
- package/dist/mjs/predicate/isInteger.js +9 -0
- package/dist/mjs/predicate/isIterable.js +9 -0
- package/dist/mjs/predicate/isJSONable.js +11 -1
- package/dist/mjs/predicate/isLengthAware.js +9 -0
- package/dist/mjs/predicate/isNonNullable.js +9 -0
- package/dist/mjs/predicate/isNull.js +9 -0
- package/dist/mjs/predicate/isNullArray.js +9 -0
- package/dist/mjs/predicate/isNullish.js +9 -0
- package/dist/mjs/predicate/isNumber.js +9 -0
- package/dist/mjs/predicate/isNumberArray.js +9 -0
- package/dist/mjs/predicate/isNumericString.js +9 -0
- package/dist/mjs/predicate/isNumericValue.js +9 -0
- package/dist/mjs/predicate/isNumericValueArray.js +9 -0
- package/dist/mjs/predicate/isObject.js +9 -0
- package/dist/mjs/predicate/isObjectLiteral.js +9 -0
- package/dist/mjs/predicate/isObjectWith.js +9 -0
- package/dist/mjs/predicate/isOctalNumberString.js +11 -0
- package/dist/mjs/predicate/isOptionalArray.js +9 -0
- package/dist/mjs/predicate/isOptionalBigInt.js +9 -0
- package/dist/mjs/predicate/isOptionalBoolean.js +9 -0
- package/dist/mjs/predicate/isOptionalISODateString.js +9 -0
- package/dist/mjs/predicate/isOptionalNull.js +9 -0
- package/dist/mjs/predicate/isOptionalNumber.js +9 -0
- package/dist/mjs/predicate/isOptionalObject.js +9 -0
- package/dist/mjs/predicate/isOptionalString.js +9 -0
- package/dist/mjs/predicate/isOptionalSymbol.js +9 -0
- package/dist/mjs/predicate/isPositiveFiniteNumber.js +9 -0
- package/dist/mjs/predicate/isPositiveInteger.js +9 -0
- package/dist/mjs/predicate/isPrimitive.js +9 -0
- package/dist/mjs/predicate/isPromiseFulfilledResult.js +9 -0
- package/dist/mjs/predicate/isPromiseLike.js +9 -0
- package/dist/mjs/predicate/isPromiseRejectedResult.js +9 -0
- package/dist/mjs/predicate/isPropertyKey.js +9 -0
- package/dist/mjs/predicate/isSafeInteger.js +9 -0
- package/dist/mjs/predicate/isSizeAware.js +9 -0
- package/dist/mjs/predicate/isString.js +9 -0
- package/dist/mjs/predicate/isStringArray.js +9 -0
- package/dist/mjs/predicate/isStringRecord.js +9 -0
- package/dist/mjs/predicate/isStringWithLength.js +9 -0
- package/dist/mjs/predicate/isSymbol.js +9 -0
- package/dist/mjs/predicate/isSymbolArray.js +9 -0
- package/dist/mjs/predicate/isTimeoutError.js +13 -0
- package/dist/mjs/predicate/isUInt32.js +9 -0
- package/dist/mjs/predicate/isUndefined.js +9 -0
- package/dist/mjs/predicate/isUndefinedArray.js +9 -0
- package/dist/mjs/predicate/isUnknown.js +9 -0
- package/dist/mjs/predicate/isUrlString.js +9 -0
- package/dist/mjs/prefix.js +9 -0
- package/dist/mjs/randomInt.js +9 -0
- package/dist/mjs/redactCredentialsInURL.js +8 -0
- package/dist/mjs/resultify.js +25 -0
- package/dist/mjs/secToString.js +9 -0
- package/dist/mjs/set.js +13 -0
- package/dist/mjs/sort/byLocaleCompare.js +8 -0
- package/dist/mjs/sort/byRandom.js +9 -1
- package/dist/mjs/sort/bySimpleComparison.js +8 -0
- package/dist/mjs/sort/bySubtraction.js +8 -0
- package/dist/mjs/sort/byTimestamp.js +8 -0
- package/dist/mjs/sort/factory/byProperty.js +8 -0
- package/dist/mjs/sort/factory/byReverseOf.js +8 -0
- package/dist/mjs/stripIndent.js +8 -0
- package/dist/mjs/stripWhitespace.js +8 -0
- package/dist/mjs/suffix.js +9 -0
- package/dist/mjs/toPascalCase.js +10 -0
- package/dist/mjs/trimEnd.js +9 -0
- package/dist/mjs/trimIndentation.js +8 -0
- package/dist/mjs/trimStart.js +9 -0
- package/dist/mjs/tryFn.js +11 -0
- package/dist/mjs/tryIt.js +9 -0
- package/dist/mjs/types/common.js +1 -0
- package/dist/mjs/types/utils.js +1 -0
- package/dist/mjs/unique.js +8 -0
- package/dist/mjs/uniqueItems.js +8 -0
- package/dist/mjs/until.js +35 -0
- package/dist/types/asArray.d.ts +9 -0
- package/dist/types/asError.d.ts +9 -0
- package/dist/types/assertion/assertExhaustive.d.ts +19 -0
- package/dist/types/assertion/assertIsAsyncIterable.d.ts +13 -0
- package/dist/types/assertion/assertIsBigInt.d.ts +9 -0
- package/dist/types/assertion/assertIsBigIntArray.d.ts +9 -0
- package/dist/types/assertion/assertIsBoolean.d.ts +9 -0
- package/dist/types/assertion/assertIsBooleanArray.d.ts +9 -0
- package/dist/types/assertion/assertIsDigitsString.d.ts +9 -0
- package/dist/types/assertion/assertIsFiniteNumber.d.ts +9 -0
- package/dist/types/assertion/assertIsFunction.d.ts +9 -0
- package/dist/types/assertion/assertIsInt32.d.ts +9 -0
- package/dist/types/assertion/assertIsIntString.d.ts +9 -0
- package/dist/types/assertion/assertIsInteger.d.ts +9 -0
- package/dist/types/assertion/assertIsIterable.d.ts +9 -0
- package/dist/types/assertion/assertIsLengthAware.d.ts +9 -0
- package/dist/types/assertion/assertIsNull.d.ts +9 -0
- package/dist/types/assertion/assertIsNullArray.d.ts +9 -0
- package/dist/types/assertion/assertIsNumber.d.ts +9 -0
- package/dist/types/assertion/assertIsNumberArray.d.ts +9 -0
- package/dist/types/assertion/assertIsNumberGTEOne.d.ts +9 -0
- package/dist/types/assertion/assertIsNumericString.d.ts +9 -0
- package/dist/types/assertion/assertIsNumericValue.d.ts +11 -0
- package/dist/types/assertion/assertIsNumericValueArray.d.ts +9 -0
- package/dist/types/assertion/assertIsObject.d.ts +10 -0
- package/dist/types/assertion/assertIsOptionalBigInt.d.ts +10 -0
- package/dist/types/assertion/assertIsOptionalBoolean.d.ts +10 -0
- package/dist/types/assertion/assertIsOptionalNull.d.ts +10 -0
- package/dist/types/assertion/assertIsOptionalNumber.d.ts +10 -0
- package/dist/types/assertion/assertIsOptionalString.d.ts +10 -0
- package/dist/types/assertion/assertIsOptionalSymbol.d.ts +10 -0
- package/dist/types/assertion/assertIsPositiveFiniteNumber.d.ts +9 -0
- package/dist/types/assertion/assertIsPositiveInteger.d.ts +9 -0
- package/dist/types/assertion/assertIsPrimitive.d.ts +9 -0
- package/dist/types/assertion/assertIsPromiseFulfilledResult.d.ts +11 -0
- package/dist/types/assertion/assertIsPromiseRejectedResult.d.ts +11 -0
- package/dist/types/assertion/assertIsPropertyKey.d.ts +11 -0
- package/dist/types/assertion/assertIsSafeInteger.d.ts +9 -0
- package/dist/types/assertion/assertIsSizeAware.d.ts +9 -0
- package/dist/types/assertion/assertIsString.d.ts +9 -0
- package/dist/types/assertion/assertIsStringArray.d.ts +9 -0
- package/dist/types/assertion/assertIsStringMatching.d.ts +9 -0
- package/dist/types/assertion/assertIsStringRecord.d.ts +9 -0
- package/dist/types/assertion/assertIsStringWithLength.d.ts +9 -0
- package/dist/types/assertion/assertIsSymbol.d.ts +9 -0
- package/dist/types/assertion/assertIsSymbolArray.d.ts +9 -0
- package/dist/types/assertion/assertIsUndefined.d.ts +9 -0
- package/dist/types/assertion/assertIsUndefinedArray.d.ts +9 -0
- package/dist/types/assertion/assertPredicate.d.ts +11 -0
- package/dist/types/assertion/getError.d.ts +9 -0
- package/dist/types/capitalize.d.ts +9 -1
- package/dist/types/cartesian.d.ts +10 -0
- package/dist/types/chunk.d.ts +8 -0
- package/dist/types/clamp.d.ts +9 -0
- package/dist/types/combinations.d.ts +8 -0
- package/dist/types/comment.d.ts +8 -0
- package/dist/types/compose.d.ts +11 -0
- package/dist/types/convert.d.ts +8 -0
- package/dist/types/countCharCode.d.ts +8 -0
- package/dist/types/countCharacter.d.ts +8 -0
- package/dist/types/counter.d.ts +8 -0
- package/dist/types/dedent.d.ts +14 -0
- package/dist/types/deepDecodeURI.d.ts +8 -0
- package/dist/types/deepFreeze.d.ts +13 -0
- package/dist/types/describeInput.d.ts +10 -0
- package/dist/types/escapeRegExp.d.ts +8 -0
- package/dist/types/findIndentation.d.ts +8 -0
- package/dist/types/getDateString.d.ts +8 -0
- package/dist/types/getISODateString.d.ts +8 -0
- package/dist/types/getMaxValue.d.ts +8 -0
- package/dist/types/getMilliseconds.d.ts +9 -0
- package/dist/types/getMinValue.d.ts +8 -0
- package/dist/types/getOwnKeys.d.ts +8 -0
- package/dist/types/getOwnPaths.d.ts +8 -0
- package/dist/types/getOwnProperties.d.ts +8 -0
- package/dist/types/getPackageName.d.ts +9 -0
- package/dist/types/getPaths.d.ts +8 -0
- package/dist/types/getType.d.ts +9 -0
- package/dist/types/hasAdditionalProperties.d.ts +9 -0
- package/dist/types/inRange.d.ts +9 -0
- package/dist/types/isEmpty.d.ts +9 -0
- package/dist/types/iterateForever.d.ts +13 -0
- package/dist/types/joinStrings.d.ts +8 -0
- package/dist/types/looksLikeURL.d.ts +9 -0
- package/dist/types/memo.d.ts +14 -0
- package/dist/types/parseNumber.d.ts +9 -0
- package/dist/types/pathParts.d.ts +8 -0
- package/dist/types/predicate/assume.d.ts +13 -0
- package/dist/types/predicate/factory/allOf.d.ts +11 -0
- package/dist/types/predicate/factory/anyOf.d.ts +11 -0
- package/dist/types/predicate/factory/everyItem.d.ts +11 -0
- package/dist/types/predicate/factory/fromEnum.d.ts +17 -0
- package/dist/types/predicate/factory/instanceOf.d.ts +10 -0
- package/dist/types/predicate/factory/is.d.ts +10 -0
- package/dist/types/predicate/factory/literal.d.ts +10 -0
- package/dist/types/predicate/factory/matching.d.ts +10 -0
- package/dist/types/predicate/factory/maybeArray.d.ts +11 -0
- package/dist/types/predicate/factory/nonNullable.d.ts +13 -0
- package/dist/types/predicate/factory/nullable.d.ts +11 -0
- package/dist/types/predicate/factory/nullish.d.ts +12 -0
- package/dist/types/predicate/factory/optional.d.ts +11 -0
- package/dist/types/predicate/factory/shape.d.ts +13 -0
- package/dist/types/predicate/factory/simple.d.ts +10 -0
- package/dist/types/predicate/factory/stringLength.d.ts +11 -0
- package/dist/types/predicate/factory/tuple.d.ts +11 -0
- package/dist/types/predicate/factory/typeOf.d.ts +11 -0
- package/dist/types/predicate/index.d.ts +0 -1
- package/dist/types/predicate/isAny.d.ts +9 -0
- package/dist/types/predicate/isAnyObject.d.ts +9 -0
- package/dist/types/predicate/isAnyObjectWith.d.ts +9 -0
- package/dist/types/predicate/isAnyObjectWithOwn.d.ts +9 -0
- package/dist/types/predicate/isArray.d.ts +9 -0
- package/dist/types/predicate/isAsyncIterable.d.ts +12 -0
- package/dist/types/predicate/isBigInt.d.ts +9 -0
- package/dist/types/predicate/isBigIntArray.d.ts +9 -0
- package/dist/types/predicate/isBinaryNumberString.d.ts +11 -0
- package/dist/types/predicate/isBoolean.d.ts +9 -0
- package/dist/types/predicate/isBooleanArray.d.ts +9 -0
- package/dist/types/predicate/isDateInputString.d.ts +9 -0
- package/dist/types/predicate/isDigitsString.d.ts +9 -0
- package/dist/types/predicate/isFiniteNumber.d.ts +9 -0
- package/dist/types/predicate/isFunction.d.ts +9 -0
- package/dist/types/predicate/isHexNumberString.d.ts +11 -0
- package/dist/types/predicate/isISODateString.d.ts +12 -0
- package/dist/types/predicate/isInt32.d.ts +9 -0
- package/dist/types/predicate/isIntString.d.ts +9 -0
- package/dist/types/predicate/isInteger.d.ts +9 -0
- package/dist/types/predicate/isIterable.d.ts +9 -0
- package/dist/types/predicate/isJSONable.d.ts +9 -0
- package/dist/types/predicate/isLengthAware.d.ts +9 -0
- package/dist/types/predicate/isNonNullable.d.ts +9 -0
- package/dist/types/predicate/isNull.d.ts +9 -0
- package/dist/types/predicate/isNullArray.d.ts +9 -0
- package/dist/types/predicate/isNullish.d.ts +9 -0
- package/dist/types/predicate/isNumber.d.ts +9 -0
- package/dist/types/predicate/isNumberArray.d.ts +9 -0
- package/dist/types/predicate/isNumericString.d.ts +9 -0
- package/dist/types/predicate/isNumericValue.d.ts +9 -0
- package/dist/types/predicate/isNumericValueArray.d.ts +9 -0
- package/dist/types/predicate/isObject.d.ts +9 -0
- package/dist/types/predicate/isObjectLiteral.d.ts +9 -0
- package/dist/types/predicate/isObjectWith.d.ts +9 -0
- package/dist/types/predicate/isOctalNumberString.d.ts +11 -0
- package/dist/types/predicate/isOptionalArray.d.ts +9 -0
- package/dist/types/predicate/isOptionalBigInt.d.ts +9 -0
- package/dist/types/predicate/isOptionalBoolean.d.ts +9 -0
- package/dist/types/predicate/isOptionalISODateString.d.ts +9 -0
- package/dist/types/predicate/isOptionalNull.d.ts +9 -0
- package/dist/types/predicate/isOptionalNumber.d.ts +9 -0
- package/dist/types/predicate/isOptionalObject.d.ts +9 -0
- package/dist/types/predicate/isOptionalString.d.ts +9 -0
- package/dist/types/predicate/isOptionalSymbol.d.ts +9 -0
- package/dist/types/predicate/isPositiveFiniteNumber.d.ts +9 -0
- package/dist/types/predicate/isPositiveInteger.d.ts +9 -0
- package/dist/types/predicate/isPrimitive.d.ts +9 -0
- package/dist/types/predicate/isPromiseFulfilledResult.d.ts +9 -0
- package/dist/types/predicate/isPromiseLike.d.ts +9 -0
- package/dist/types/predicate/isPromiseRejectedResult.d.ts +9 -0
- package/dist/types/predicate/isPropertyKey.d.ts +9 -0
- package/dist/types/predicate/isSafeInteger.d.ts +9 -0
- package/dist/types/predicate/isSizeAware.d.ts +9 -0
- package/dist/types/predicate/isString.d.ts +9 -0
- package/dist/types/predicate/isStringArray.d.ts +9 -0
- package/dist/types/predicate/isStringRecord.d.ts +9 -0
- package/dist/types/predicate/isStringWithLength.d.ts +9 -0
- package/dist/types/predicate/isSymbol.d.ts +9 -0
- package/dist/types/predicate/isSymbolArray.d.ts +9 -0
- package/dist/types/predicate/isTimeoutError.d.ts +13 -0
- package/dist/types/predicate/isUInt32.d.ts +9 -0
- package/dist/types/predicate/isUndefined.d.ts +9 -0
- package/dist/types/predicate/isUndefinedArray.d.ts +9 -0
- package/dist/types/predicate/isUnknown.d.ts +9 -0
- package/dist/types/predicate/isUrlString.d.ts +9 -0
- package/dist/types/prefix.d.ts +9 -0
- package/dist/types/redactCredentialsInURL.d.ts +8 -0
- package/dist/types/resultify.d.ts +25 -0
- package/dist/types/secToString.d.ts +8 -0
- package/dist/types/sort/byLocaleCompare.d.ts +8 -0
- package/dist/types/sort/byRandom.d.ts +8 -0
- package/dist/types/sort/bySimpleComparison.d.ts +8 -0
- package/dist/types/sort/bySubtraction.d.ts +8 -0
- package/dist/types/sort/byTimestamp.d.ts +8 -0
- package/dist/types/sort/factory/byProperty.d.ts +8 -0
- package/dist/types/sort/factory/byReverseOf.d.ts +8 -0
- package/dist/types/stripIndent.d.ts +8 -0
- package/dist/types/stripWhitespace.d.ts +8 -0
- package/dist/types/suffix.d.ts +9 -0
- package/dist/types/toPascalCase.d.ts +9 -0
- package/dist/types/trimEnd.d.ts +9 -0
- package/dist/types/trimIndentation.d.ts +8 -0
- package/dist/types/trimStart.d.ts +9 -0
- package/dist/types/types/arrays.d.ts +3 -0
- package/dist/types/types/common.d.ts +3 -0
- package/dist/types/types/date-time.d.ts +9 -0
- package/dist/types/types/functions.d.ts +7 -0
- package/dist/types/types/numbers.d.ts +21 -0
- package/dist/types/types/objects.d.ts +74 -0
- package/dist/types/types/records.d.ts +5 -0
- package/dist/types/types/utils.d.ts +24 -0
- package/dist/types/unique.d.ts +18 -0
- package/dist/types/uniqueItems.d.ts +8 -0
- package/dist/types/until.d.ts +33 -0
- package/package.json +4 -2
- package/readme.md +11 -1
- package/dist/cjs/predicate/isDateString.js +0 -5
- package/dist/mjs/predicate/isDateString.js +0 -2
- package/dist/types/predicate/isDateString.d.ts +0 -2
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.redactCredentialsInURL = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Replace the username and password in `input`, a URL, with `mask`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* redactCredentialsInURL('https://user:pass@example.com'); // 'https://REDACTED:REDACTED@example.com/'
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
4
12
|
const redactCredentialsInURL = (input, mask = 'REDACTED') => {
|
|
5
13
|
try {
|
|
6
14
|
const url = new URL(String(input));
|
package/dist/cjs/resultify.js
CHANGED
|
@@ -17,6 +17,17 @@ function errorResult(error) {
|
|
|
17
17
|
isError: true,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Wrap a synchronous function `fn` so it returns a `Result` instead of throwing.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const parse = resultify(JSON.parse);
|
|
26
|
+
*
|
|
27
|
+
* parse('{"a":1}'); // { ok: { a: 1 }, isOk: true, isError: false }
|
|
28
|
+
* parse('invalid'); // { error: SyntaxError, isOk: false, isError: true }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
20
31
|
function resultify(fn) {
|
|
21
32
|
return (...args) => {
|
|
22
33
|
try {
|
|
@@ -27,5 +38,19 @@ function resultify(fn) {
|
|
|
27
38
|
}
|
|
28
39
|
};
|
|
29
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Wrap an async function `fn` so its returned `Promise` resolves with a `Result` instead of rejecting.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const fetchJson = resultifyAsync(async (url: string) => {
|
|
47
|
+
* const response = await fetch(url);
|
|
48
|
+
*
|
|
49
|
+
* return response.json();
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* await fetchJson('https://example.com'); // { ok: ..., isOk: true, isError: false }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
30
55
|
const resultifyAsync = (fn) => (...args) => fn(...args).then(okResult, (error) => errorResult((0, asError_js_1.asError)(error)));
|
|
31
56
|
exports.resultifyAsync = resultifyAsync;
|
package/dist/cjs/secToString.js
CHANGED
|
@@ -15,6 +15,14 @@ var Seconds;
|
|
|
15
15
|
Seconds[Seconds["Century"] = 3155760000] = "Century";
|
|
16
16
|
Seconds[Seconds["Millennium"] = 31557600000] = "Millennium";
|
|
17
17
|
})(Seconds || (exports.Seconds = Seconds = {}));
|
|
18
|
+
/**
|
|
19
|
+
* Convert `time`, in seconds, to a human-readable string.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* secToString(90061); // '1 day 1 hour 1 minute 1 second'
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
18
26
|
function secToString(time, joinString = ' ') {
|
|
19
27
|
const secTime = [
|
|
20
28
|
['millennium', Seconds.Millennium],
|
|
@@ -37,5 +45,6 @@ function secToString(time, joinString = ' ') {
|
|
|
37
45
|
}
|
|
38
46
|
return output;
|
|
39
47
|
}, []);
|
|
48
|
+
// cSpell:ignore centurys
|
|
40
49
|
return parts.join(joinString).replace('centurys', 'centuries');
|
|
41
50
|
}
|
package/dist/cjs/set.js
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.set = set;
|
|
4
4
|
const pathParts_js_1 = require("./pathParts.js");
|
|
5
|
+
/**
|
|
6
|
+
* Set the value of a property
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const data = { a: { b: 1 } };
|
|
11
|
+
*
|
|
12
|
+
* set(data, 'a.b', 2); // 2
|
|
13
|
+
* data; // { a: { b: 2 } }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
5
16
|
function set(input, path, value) {
|
|
6
17
|
if (path === '') {
|
|
7
18
|
throw new Error('Path cannot be an empty string');
|
|
@@ -14,8 +25,10 @@ function set(input, path, value) {
|
|
|
14
25
|
if (typeof lastPart === 'undefined') {
|
|
15
26
|
throw new Error('Path must have at least one part');
|
|
16
27
|
}
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
29
|
let current = input;
|
|
18
30
|
const useParts = [];
|
|
31
|
+
// get a reference to the last node that will be updated
|
|
19
32
|
for (const part of parts) {
|
|
20
33
|
useParts.push(part);
|
|
21
34
|
if (typeof current === 'object' && current !== null && part in current) {
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.byLocaleCompare = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Compare two strings using `localeCompare`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* ['banana', 'apple', 'cherry'].sort(byLocaleCompare); // ['apple', 'banana', 'cherry']
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
4
12
|
const byLocaleCompare = (left, right) => left.localeCompare(right);
|
|
5
13
|
exports.byLocaleCompare = byLocaleCompare;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.byRandom = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Randomly return -1, 0, or 1. This is an easy way to shuffle an array.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* [1, 2, 3, 4, 5].sort(byRandom); // shuffled order, e.g. [3, 1, 5, 2, 4]
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
4
12
|
const byRandom = () => {
|
|
5
13
|
let value;
|
|
6
14
|
const data = new Uint8Array(1);
|
|
7
15
|
do {
|
|
8
16
|
value = crypto.getRandomValues(data)[0];
|
|
9
|
-
} while (value >= 252);
|
|
17
|
+
} while (value >= 252); // Avoid modulo bias
|
|
10
18
|
return (value % 3) - 1;
|
|
11
19
|
};
|
|
12
20
|
exports.byRandom = byRandom;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bySimpleComparison = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Compare two values using `<`, `>`, and `===`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* [3, 1, 2].sort(bySimpleComparison); // [1, 2, 3]
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
4
12
|
const bySimpleComparison = (left, right) => {
|
|
5
13
|
return left === right ? 0 : left > right ? 1 : -1;
|
|
6
14
|
};
|
|
@@ -2,5 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bySubtraction = void 0;
|
|
4
4
|
const parseNumber_js_1 = require("../parseNumber.js");
|
|
5
|
+
/**
|
|
6
|
+
* Compare two numeric-like values by parsing them and subtracting `right` from `left`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* [10, 2, 1].sort(bySubtraction); // [1, 2, 10]
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
5
13
|
const bySubtraction = (left, right) => (0, parseNumber_js_1.parseNumber)(left) - (0, parseNumber_js_1.parseNumber)(right);
|
|
6
14
|
exports.bySubtraction = bySubtraction;
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.byTimestamp = void 0;
|
|
4
4
|
const getMilliseconds_js_1 = require("../getMilliseconds.js");
|
|
5
|
+
/**
|
|
6
|
+
* Compare two dates, strings, or numbers by their timestamp in milliseconds.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* ['2024-01-02', '2024-01-01'].sort(byTimestamp); // ['2024-01-01', '2024-01-02']
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
5
13
|
const byTimestamp = (left, right) => {
|
|
6
14
|
const timeDiff = (0, getMilliseconds_js_1.getMilliseconds)(left) - (0, getMilliseconds_js_1.getMilliseconds)(right);
|
|
7
15
|
return Number.isNaN(timeDiff) ? -1 : timeDiff;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.byProperty = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Create a comparator that sorts by the value at the given object `property`, using `compareFn` to compare those values.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* [{ age: 30 }, { age: 20 }].sort(byProperty(bySubtraction, 'age')); // [{ age: 20 }, { age: 30 }]
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
4
12
|
const byProperty = (compareFn, property) => (left, right) => compareFn(left[property], right[property]);
|
|
5
13
|
exports.byProperty = byProperty;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.byReverseOf = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Create a comparator that reverses the ordering produced by the given `compareFn`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* [1, 2, 3].sort(byReverseOf(bySubtraction)); // [3, 2, 1]
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
4
12
|
const byReverseOf = (compareFn) => (left, right) => 0 - compareFn(left, right);
|
|
5
13
|
exports.byReverseOf = byReverseOf;
|
package/dist/cjs/stripIndent.js
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stripIndent = stripIndent;
|
|
4
4
|
const constants_js_1 = require("./constants.js");
|
|
5
|
+
/**
|
|
6
|
+
* Remove `indent` immediately following every line break in `input`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* stripIndent('\n foo\n bar', ' '); // '\nfoo\nbar'
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
5
13
|
function stripIndent(input, indent) {
|
|
6
14
|
return input.replaceAll(new RegExp(String.raw `(?<newLine>${constants_js_1.NEWLINE_RAW_PATTERN})${indent}`, 'g'), '$<newLine>');
|
|
7
15
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stripWhitespace = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Remove all whitespace from `input`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* stripWhitespace('a b\tc\nd'); // 'abcd'
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
4
12
|
const stripWhitespace = (input) => input.replace(/\s+/g, '');
|
|
5
13
|
exports.stripWhitespace = stripWhitespace;
|
package/dist/cjs/suffix.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.suffix = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Append `suffixString` to `value`, or return `defaultValue` if `value` is `null`, `undefined`, or an empty string.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* suffix('!', 'Hi'); // 'Hi!'
|
|
10
|
+
* suffix('!', null, 'N/A'); // 'N/A'
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
4
13
|
const suffix = (suffixString, value, defaultValue = '') => {
|
|
5
14
|
if (value == null || (typeof value == 'string' && value.length === 0)) {
|
|
6
15
|
return defaultValue;
|
package/dist/cjs/toPascalCase.js
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toPascalCase = toPascalCase;
|
|
4
4
|
const capitalize_js_1 = require("./capitalize.js");
|
|
5
|
+
/**
|
|
6
|
+
* Convert `text` to PascalCase, optionally replacing individual words using `customWords`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* toPascalCase('hello world'); // 'HelloWorld'
|
|
11
|
+
* toPascalCase('foo-bar', { bar: 'BAR' }); // 'FooBAR'
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
5
14
|
function toPascalCase(text, customWords) {
|
|
6
15
|
let words = String(text)
|
|
7
16
|
.replaceAll(/['.]/g, '')
|
|
@@ -12,6 +21,7 @@ function toPascalCase(text, customWords) {
|
|
|
12
21
|
if (words && customWords && typeof customWords === 'object') {
|
|
13
22
|
const replacements = new Map(Object.entries(customWords).map(([key, value]) => [key.toLowerCase(), value]));
|
|
14
23
|
if (replacements.size) {
|
|
24
|
+
// This takes a single word and returns the first matching replacement, if any.
|
|
15
25
|
const replaceCustomWords = (word) => replacements.get(word.toLowerCase()) ?? word;
|
|
16
26
|
words = words.map(replaceCustomWords);
|
|
17
27
|
}
|
package/dist/cjs/trimEnd.js
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.trimEnd = trimEnd;
|
|
4
4
|
const escapeRegExp_js_1 = require("./escapeRegExp.js");
|
|
5
|
+
/**
|
|
6
|
+
* Remove `char` from the end of `str`, or whitespace if `char` isn't provided.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* trimEnd('hello '); // 'hello'
|
|
11
|
+
* trimEnd('hello///', '/'); // 'hello'
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
5
14
|
function trimEnd(str, char) {
|
|
6
15
|
return char ? str.replace(new RegExp(`${(0, escapeRegExp_js_1.escapeRegExp)(char)}+$`), '') : str.trimEnd();
|
|
7
16
|
}
|
|
@@ -4,6 +4,14 @@ exports.trimIndentation = trimIndentation;
|
|
|
4
4
|
const constants_js_1 = require("./constants.js");
|
|
5
5
|
const findIndentation_js_1 = require("./findIndentation.js");
|
|
6
6
|
const stripIndent_js_1 = require("./stripIndent.js");
|
|
7
|
+
/**
|
|
8
|
+
* Remove common leading indentation from every line in `input` and trim the result.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* trimIndentation(' foo\n bar\n'); // 'foo\nbar'
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
7
15
|
function trimIndentation(input) {
|
|
8
16
|
const whiteSpace = (0, findIndentation_js_1.findIndentation)(input.split(new RegExp(constants_js_1.NEWLINE_RAW_PATTERN)));
|
|
9
17
|
return (whiteSpace ? (0, stripIndent_js_1.stripIndent)(input, whiteSpace) : input).trim();
|
package/dist/cjs/trimStart.js
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.trimStart = trimStart;
|
|
4
4
|
const escapeRegExp_js_1 = require("./escapeRegExp.js");
|
|
5
|
+
/**
|
|
6
|
+
* Remove `char` from the start of `str`, or whitespace if `char` isn't provided.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* trimStart(' hello'); // 'hello'
|
|
11
|
+
* trimStart('///hello', '/'); // 'hello'
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
5
14
|
function trimStart(str, char) {
|
|
6
15
|
return char ? str.replace(new RegExp(`^${(0, escapeRegExp_js_1.escapeRegExp)(char)}+`), '') : str.trimStart();
|
|
7
16
|
}
|
package/dist/cjs/tryFn.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tryFn = tryFn;
|
|
4
|
+
/**
|
|
5
|
+
* Wrap `fn` so calling it returns `defaultValue` instead of throwing.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const parse = tryFn(JSON.parse, {});
|
|
10
|
+
*
|
|
11
|
+
* parse('invalid'); // {}
|
|
12
|
+
* parse('{"a":1}'); // { a: 1 }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
4
15
|
function tryFn(fn, defaultValue) {
|
|
5
16
|
return (...args) => {
|
|
6
17
|
try {
|
package/dist/cjs/tryIt.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tryIt = tryIt;
|
|
4
|
+
/**
|
|
5
|
+
* Call `fn` and return `defaultValue` instead of throwing if it fails.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* tryIt(() => JSON.parse('invalid'), {}); // {}
|
|
10
|
+
* tryIt(() => JSON.parse('{"a":1}')); // { a: 1 }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
4
13
|
function tryIt(fn, defaultValue) {
|
|
5
14
|
try {
|
|
6
15
|
return fn();
|
package/dist/cjs/types/common.js
CHANGED
package/dist/cjs/types/utils.js
CHANGED
package/dist/cjs/unique.js
CHANGED
|
@@ -3,6 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.unique = unique;
|
|
4
4
|
const isAsyncIterable_js_1 = require("./predicate/isAsyncIterable.js");
|
|
5
5
|
const isIterable_js_1 = require("./predicate/isIterable.js");
|
|
6
|
+
/**
|
|
7
|
+
* Lazily yield only the unique items from an `Iterable` or `AsyncIterable`, preserving order.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* [...unique([1, 2, 2, 3, 1])]; // [1, 2, 3]
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
6
14
|
function unique(items, options = {}) {
|
|
7
15
|
const { filter, identity, store = new Set() } = options;
|
|
8
16
|
if (typeof items === 'string' || (0, isIterable_js_1.isIterable)(items)) {
|
package/dist/cjs/uniqueItems.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.uniqueItems = uniqueItems;
|
|
4
|
+
/**
|
|
5
|
+
* Get the unique items in `data`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* uniqueItems([1, 2, 2, 3]); // [1, 2, 3]
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
4
12
|
function uniqueItems(data) {
|
|
5
13
|
return [...new Set(data)];
|
|
6
14
|
}
|
package/dist/cjs/until.js
CHANGED
|
@@ -7,10 +7,43 @@ const getType_js_1 = require("./getType.js");
|
|
|
7
7
|
const defaultOptions = {
|
|
8
8
|
delay: 10,
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Determine if `input` is a valid `Delay`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* isDelay(10); // true
|
|
16
|
+
* isDelay(() => 10); // true
|
|
17
|
+
* isDelay('10'); // false
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
10
20
|
const isDelay = (input) => Number.isInteger(input) || typeof input === 'function';
|
|
11
21
|
exports.isDelay = isDelay;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve `delay` to a number of milliseconds, calling it with `context` if it's a function.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const context = { callCount: 2, lastCall: Date.now(), data: {}, options: { delay: 100 } };
|
|
28
|
+
*
|
|
29
|
+
* getDelay(100, context); // 100
|
|
30
|
+
* getDelay((ctx) => ctx.callCount * 50, context); // 100
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
12
33
|
const getDelay = (delay, context) => typeof delay === 'function' ? delay(context) : delay;
|
|
13
34
|
exports.getDelay = getDelay;
|
|
35
|
+
/**
|
|
36
|
+
* Return a Promise that delegates resolving/rejecting to the passed in function.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* await until((resolve, reject, context) => {
|
|
41
|
+
* if (context.callCount >= 3) {
|
|
42
|
+
* resolve('done');
|
|
43
|
+
* }
|
|
44
|
+
* }, { delay: 100, callLimit: 5 }); // resolves with 'done' after being called 3 times
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
14
47
|
function until(fn, options = defaultOptions) {
|
|
15
48
|
if (typeof fn !== 'function') {
|
|
16
49
|
return Promise.reject(new Error('fn must be a function'));
|
|
@@ -32,7 +65,9 @@ function until(fn, options = defaultOptions) {
|
|
|
32
65
|
let callCount = 0;
|
|
33
66
|
let lastCall;
|
|
34
67
|
let done = false;
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
69
|
let timer;
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
71
|
let timeoutTimer;
|
|
37
72
|
const finish = () => {
|
|
38
73
|
done = true;
|
package/dist/mjs/asArray.js
CHANGED
package/dist/mjs/asError.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensure `input` is an `Error` instance, converting it to one if it isn't already.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* asError('Oops'); // Error('Oops')
|
|
7
|
+
* asError(new Error('Oops')); // the same Error instance
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
1
10
|
export function asError(input) {
|
|
2
11
|
return input instanceof Error ? input : new Error(String(input));
|
|
3
12
|
}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import { getError } from './getError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Assert that this line is unreachable, useful for exhaustive checks such as a `switch` covering every case of a union.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* type Direction = 'up' | 'down';
|
|
8
|
+
*
|
|
9
|
+
* function describe(direction: Direction): string {
|
|
10
|
+
* switch (direction) {
|
|
11
|
+
* case 'up':
|
|
12
|
+
* return 'Going up';
|
|
13
|
+
* case 'down':
|
|
14
|
+
* return 'Going down';
|
|
15
|
+
* default:
|
|
16
|
+
* assertExhaustive(direction); // throws if a new Direction case isn't handled above
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
2
21
|
export function assertExhaustive(_, error = 'Failed exhaustive check') {
|
|
3
22
|
throw getError(error);
|
|
4
23
|
}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { isAsyncIterable } from '../predicate/isAsyncIterable.js';
|
|
2
2
|
import { getError } from './getError.js';
|
|
3
|
+
/**
|
|
4
|
+
* Assert that `input` is an `AsyncIterable`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* async function* gen() {
|
|
9
|
+
* yield 1;
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* assertIsAsyncIterable(gen()); // does not throw
|
|
13
|
+
* assertIsAsyncIterable([1, 2, 3]); // throws TypeError: input is not an AsyncIterable
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
3
16
|
export function assertIsAsyncIterable(input, error = 'input is not an AsyncIterable') {
|
|
4
17
|
if (!isAsyncIterable(input)) {
|
|
5
18
|
throw getError(error);
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { isBigInt } from '../predicate/isBigInt.js';
|
|
2
2
|
import { getError } from './getError.js';
|
|
3
|
+
/**
|
|
4
|
+
* Assert that `input` is a `bigint`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* assertIsBigInt(10n); // does not throw
|
|
9
|
+
* assertIsBigInt(10); // throws TypeError: input is not a bigint
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export function assertIsBigInt(input, error = 'input is not a bigint') {
|
|
4
13
|
if (!isBigInt(input)) {
|
|
5
14
|
throw getError(error);
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { isBigIntArray } from '../predicate/isBigIntArray.js';
|
|
2
2
|
import { getError } from './getError.js';
|
|
3
|
+
/**
|
|
4
|
+
* Assert that `input` is an array of `bigint`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* assertIsBigIntArray([1n, 2n, 3n]); // does not throw
|
|
9
|
+
* assertIsBigIntArray([1, 2, 3]); // throws TypeError: input is not an array of bigint
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export function assertIsBigIntArray(input, error = 'input is not an array of bigint') {
|
|
4
13
|
if (!isBigIntArray(input)) {
|
|
5
14
|
throw getError(error);
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { isBoolean } from '../predicate/isBoolean.js';
|
|
2
2
|
import { getError } from './getError.js';
|
|
3
|
+
/**
|
|
4
|
+
* Assert that `input` is a boolean.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* assertIsBoolean(true); // does not throw
|
|
9
|
+
* assertIsBoolean('true'); // throws TypeError: input is not a boolean
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export function assertIsBoolean(input, error = 'input is not a boolean') {
|
|
4
13
|
if (!isBoolean(input)) {
|
|
5
14
|
throw getError(error);
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { isBooleanArray } from '../predicate/isBooleanArray.js';
|
|
2
2
|
import { getError } from './getError.js';
|
|
3
|
+
/**
|
|
4
|
+
* Assert that `input` is an array of booleans.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* assertIsBooleanArray([true, false]); // does not throw
|
|
9
|
+
* assertIsBooleanArray([true, 'false']); // throws TypeError: input is not an array of boolean
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export function assertIsBooleanArray(input, error = 'input is not an array of boolean') {
|
|
4
13
|
if (!isBooleanArray(input)) {
|
|
5
14
|
throw getError(error);
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { isDigitsString } from '../predicate/isDigitsString.js';
|
|
2
2
|
import { getError } from './getError.js';
|
|
3
|
+
/**
|
|
4
|
+
* Assert that `input` is a string that contains digits only.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* assertIsDigitsString('12345'); // does not throw
|
|
9
|
+
* assertIsDigitsString('123.45'); // throws TypeError: input is not a string of integers only
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export function assertIsDigitsString(input, error = 'input is not a string of integers only') {
|
|
4
13
|
if (!isDigitsString(input)) {
|
|
5
14
|
throw getError(error);
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { isFiniteNumber } from '../predicate/isFiniteNumber.js';
|
|
2
2
|
import { getError } from './getError.js';
|
|
3
|
+
/**
|
|
4
|
+
* Assert that `input` is a finite number.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* assertIsFiniteNumber(42); // does not throw
|
|
9
|
+
* assertIsFiniteNumber(Infinity); // throws TypeError: input is not a finite number
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export function assertIsFiniteNumber(input, error = 'input is not a finite number') {
|
|
4
13
|
if (!isFiniteNumber(input)) {
|
|
5
14
|
throw getError(error);
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { isFunction } from '../predicate/isFunction.js';
|
|
2
2
|
import { getError } from './getError.js';
|
|
3
|
+
/**
|
|
4
|
+
* Assert that `input` is a function.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* assertIsFunction(() => {}); // does not throw
|
|
9
|
+
* assertIsFunction(42); // throws TypeError: input is not a function
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export function assertIsFunction(input, error = 'input is not a function') {
|
|
4
13
|
if (!isFunction(input)) {
|
|
5
14
|
throw getError(error);
|