@webdeveric/utils 0.83.0 → 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 +16 -1
- 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 +16 -1
- 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 +13 -1
- 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 +24 -1
- 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 +15 -12
- 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,2 +1,11 @@
|
|
|
1
1
|
import type { StringRecord } from '../types/records.js';
|
|
2
|
+
/**
|
|
3
|
+
* Determine if `input` is an object whose values are all arrays of strings.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* isStringRecord({ a: 'x', b: 'y' }); // true
|
|
8
|
+
* isStringRecord({ a: 1 }); // false
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
2
11
|
export declare const isStringRecord: (input: unknown) => input is StringRecord;
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determine if `input` is a string with a length greater than 0.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* isStringWithLength('hello'); // true
|
|
7
|
+
* isStringWithLength(''); // false
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
1
10
|
export declare const isStringWithLength: (input: unknown) => input is string;
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determine if `input` is an array of symbols.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* isSymbolArray([Symbol('a'), Symbol('b')]); // true
|
|
7
|
+
* isSymbolArray([Symbol('a'), 'b']); // false
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
1
10
|
export declare const isSymbolArray: import("../index.js").TypePredicateFn<symbol[]>;
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a input is a TimeoutError.
|
|
3
|
+
*
|
|
4
|
+
* @privateRemarks
|
|
5
|
+
* Using `instanceof` is not reliable for cross-realm errors.
|
|
6
|
+
* We must check the shape of the input instead. 🦆
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* isTimeoutError(new DOMException('Timed out', 'TimeoutError')); // true
|
|
11
|
+
* isTimeoutError(new Error('Timed out')); // false
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
1
14
|
export declare const isTimeoutError: import("../index.js").TypePredicateFn<{
|
|
2
15
|
stack?: string;
|
|
3
16
|
readonly code: number;
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import type { UInt32 } from '../types/numbers.js';
|
|
2
|
+
/**
|
|
3
|
+
* Determine if `input` is an integer within the unsigned 32-bit integer range.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* isUInt32(42); // true
|
|
8
|
+
* isUInt32(-1); // false
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
2
11
|
export declare function isUInt32(input: unknown): input is UInt32;
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determine if `input` is an array of `undefined` values.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* isUndefinedArray([undefined, undefined]); // true
|
|
7
|
+
* isUndefinedArray([undefined, null]); // false
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
1
10
|
export declare const isUndefinedArray: import("../index.js").TypePredicateFn<undefined[]>;
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Always returns `true`, allowing `input` to be treated as `unknown` without any runtime checks.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* isUnknown(42); // true
|
|
7
|
+
* isUnknown('hello'); // true
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
1
10
|
export declare const isUnknown: (_input: unknown, ..._args: any[]) => _input is unknown;
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determine if `input` is a string that `URL.canParse()` accepts as a valid URL.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* isUrlString('https://example.com'); // true
|
|
7
|
+
* isUrlString('not a url'); // false
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
1
10
|
export declare const isUrlString: (input: unknown) => input is string;
|
package/dist/types/prefix.d.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import type { Primitive } from './types/common.js';
|
|
2
|
+
/**
|
|
3
|
+
* Prepend `prefixString` to `value`, or return `defaultValue` if `value` is `null`, `undefined`, or an empty string.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* prefix('$', 5); // '$5'
|
|
8
|
+
* prefix('$', null, 'N/A'); // 'N/A'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
2
11
|
export declare const prefix: (prefixString: string, value: Exclude<Primitive, symbol>, defaultValue?: string) => string;
|
|
@@ -2,4 +2,12 @@ export type URLMaskOptions = string | {
|
|
|
2
2
|
username: string;
|
|
3
3
|
password: string;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Replace the username and password in `input`, a URL, with `mask`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* redactCredentialsInURL('https://user:pass@example.com'); // 'https://REDACTED:REDACTED@example.com/'
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
5
13
|
export declare const redactCredentialsInURL: (input: ConstructorParameters<typeof URL>[0], mask?: URLMaskOptions) => string;
|
|
@@ -11,6 +11,31 @@ export type ErrorResult<E> = Readonly<{
|
|
|
11
11
|
}>;
|
|
12
12
|
export type Result<T, E> = OkResult<T> | ErrorResult<E>;
|
|
13
13
|
export type ResultifiedSyncFn<Fn extends AnySyncFunction> = (...args: Parameters<Fn>) => Result<ReturnType<Fn>, Error>;
|
|
14
|
+
/**
|
|
15
|
+
* Wrap a synchronous function `fn` so it returns a `Result` instead of throwing.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const parse = resultify(JSON.parse);
|
|
20
|
+
*
|
|
21
|
+
* parse('{"a":1}'); // { ok: { a: 1 }, isOk: true, isError: false }
|
|
22
|
+
* parse('invalid'); // { error: SyntaxError, isOk: false, isError: true }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
14
25
|
export declare function resultify<Fn extends AnySyncFunction>(fn: Fn): ResultifiedSyncFn<Fn>;
|
|
15
26
|
export type ResultifiedAsyncFn<Fn extends AnyAsyncFunction> = (...args: Parameters<Fn>) => Promise<Result<Awaited<ReturnType<Fn>>, Error>>;
|
|
27
|
+
/**
|
|
28
|
+
* Wrap an async function `fn` so its returned `Promise` resolves with a `Result` instead of rejecting.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const fetchJson = resultifyAsync(async (url: string) => {
|
|
33
|
+
* const response = await fetch(url);
|
|
34
|
+
*
|
|
35
|
+
* return response.json();
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* await fetchJson('https://example.com'); // { ok: ..., isOk: true, isError: false }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
16
41
|
export declare const resultifyAsync: <Fn extends AnyAsyncFunction>(fn: Fn) => ResultifiedAsyncFn<Fn>;
|
|
@@ -10,4 +10,12 @@ export declare enum Seconds {
|
|
|
10
10
|
Century = 3155760000,
|
|
11
11
|
Millennium = 31557600000
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Convert `time`, in seconds, to a human-readable string.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* secToString(90061); // '1 day 1 hour 1 minute 1 second'
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
13
21
|
export declare function secToString(time: number, joinString?: string): string;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two numeric-like values by parsing them and subtracting `right` from `left`.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* [10, 2, 1].sort(bySubtraction); // [1, 2, 10]
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
1
9
|
export declare const bySubtraction: <T extends number | bigint | string>(left: T, right: T) => number;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two dates, strings, or numbers by their timestamp in milliseconds.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* ['2024-01-02', '2024-01-01'].sort(byTimestamp); // ['2024-01-01', '2024-01-02']
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
1
9
|
export declare const byTimestamp: <T extends string | number | Date>(left: T, right: T) => number;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import type { CompareFn } from '../../types/functions.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a comparator that sorts by the value at the given object `property`, using `compareFn` to compare those values.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* [{ age: 30 }, { age: 20 }].sort(byProperty(bySubtraction, 'age')); // [{ age: 20 }, { age: 30 }]
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
2
10
|
export declare const byProperty: <T extends object, K extends keyof T = keyof T>(compareFn: CompareFn<T[K]>, property: K) => CompareFn<T>;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import type { CompareFn } from '../../types/functions.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a comparator that reverses the ordering produced by the given `compareFn`.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* [1, 2, 3].sort(byReverseOf(bySubtraction)); // [3, 2, 1]
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
2
10
|
export declare const byReverseOf: <T>(compareFn: CompareFn<T>) => CompareFn<T>;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import type { StripWhitespace } from './types/strings.js';
|
|
2
|
+
/**
|
|
3
|
+
* Remove all whitespace from `input`.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* stripWhitespace('a b\tc\nd'); // 'abcd'
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
2
10
|
export declare const stripWhitespace: <T extends string>(input: T) => StripWhitespace<T>;
|
package/dist/types/suffix.d.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import type { Primitive } from './types/common.js';
|
|
2
|
+
/**
|
|
3
|
+
* Append `suffixString` to `value`, or return `defaultValue` if `value` is `null`, `undefined`, or an empty string.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* suffix('!', 'Hi'); // 'Hi!'
|
|
8
|
+
* suffix('!', null, 'N/A'); // 'N/A'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
2
11
|
export declare const suffix: (suffixString: string, value: Exclude<Primitive, symbol>, defaultValue?: string) => string;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import type { StringRecord } from './types/records.js';
|
|
2
2
|
import type { PascalCase } from './types/strings.js';
|
|
3
|
+
/**
|
|
4
|
+
* Convert `text` to PascalCase, optionally replacing individual words using `customWords`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* toPascalCase('hello world'); // 'HelloWorld'
|
|
9
|
+
* toPascalCase('foo-bar', { bar: 'BAR' }); // 'FooBAR'
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export declare function toPascalCase<Type extends string>(text: Type, customWords?: StringRecord): PascalCase<Type>;
|
package/dist/types/trimEnd.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove `char` from the end of `str`, or whitespace if `char` isn't provided.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* trimEnd('hello '); // 'hello'
|
|
7
|
+
* trimEnd('hello///', '/'); // 'hello'
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
1
10
|
export declare function trimEnd(str: string, char?: string): string;
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove `char` from the start of `str`, or whitespace if `char` isn't provided.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* trimStart(' hello'); // 'hello'
|
|
7
|
+
* trimStart('///hello', '/'); // 'hello'
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
1
10
|
export declare function trimStart(str: string, char?: string): string;
|
|
@@ -7,6 +7,9 @@ export type GetLength<A extends any[]> = A extends {
|
|
|
7
7
|
} ? L : never;
|
|
8
8
|
export type IfLength<A extends any[], L extends number, T, F> = GetLength<A> extends L ? T : F;
|
|
9
9
|
export type IfEmpty<A extends any[], T, F> = GetLength<A> extends 0 ? T : F;
|
|
10
|
+
/**
|
|
11
|
+
* Check if `Type` is an array (excluding tuples).
|
|
12
|
+
*/
|
|
10
13
|
export type IfArray<Type, T, F> = Type extends readonly unknown[] ? (number extends Type['length'] ? T : F) : F;
|
|
11
14
|
export type IsArray<Type> = IfArray<Type, true, false>;
|
|
12
15
|
export type NonEmptyArray<Type> = [Type, ...Type[]];
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { NotPromise } from './utils.js';
|
|
2
2
|
export type Primitive = string | number | boolean | bigint | symbol | undefined | null;
|
|
3
|
+
/**
|
|
4
|
+
* This is any number or bigint that has been stringified.
|
|
5
|
+
*/
|
|
3
6
|
export type NumericString<T extends string | number | bigint = number | bigint> = `${T}` extends `${number | bigint}` ? `${T}` : never;
|
|
4
7
|
export type NumericValue = number | bigint | NumericString;
|
|
5
8
|
export type JsonObject = {
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import type { Branded } from './branded.js';
|
|
2
2
|
import type { NumericString } from './common.js';
|
|
3
3
|
export type DateInput = ConstructorParameters<typeof Date>[0];
|
|
4
|
+
/**
|
|
5
|
+
* This is used to represent a string can be used as input for a `Date` constructor.
|
|
6
|
+
*/
|
|
4
7
|
export type DateInputString = Branded<string, 'DateInputString'>;
|
|
5
8
|
export type YearString = Branded<NumericString<number>, 'YearString'>;
|
|
6
9
|
export type MonthString = Branded<NumericString<number>, 'MonthString'>;
|
|
7
10
|
export type DayString = Branded<NumericString<number>, 'DayString'>;
|
|
8
11
|
export type DateString = Branded<`${YearString}-${MonthString}-${DayString}`, 'DateString'>;
|
|
9
12
|
export type TimeString = Branded<`${number}:${number}:${number}`, 'TimeString'>;
|
|
13
|
+
/**
|
|
14
|
+
* This type describes what is returned by the `toISOString()` method of the `Date` object.
|
|
15
|
+
* It is a simplified format based on ISO 8601 and not a complete representation of the standard.
|
|
16
|
+
*
|
|
17
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
|
|
18
|
+
*/
|
|
10
19
|
export type ISODateString = Branded<`${DateString}T${TimeString}.${number}Z`, 'ISODateString'>;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Predicate function for use with Array methods,
|
|
3
|
+
* such as `filter()`, `find()`, or `some()`.
|
|
4
|
+
*/
|
|
1
5
|
export type ArrayPredicateFn<A, T extends A = A> = ((value: T, index: number, array: readonly A[]) => value is T) | ((value: T, index: number, array: readonly A[]) => unknown);
|
|
6
|
+
/**
|
|
7
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#comparefn
|
|
8
|
+
*/
|
|
2
9
|
export type CompareFn<T> = (a: T, b: T) => number;
|
|
3
10
|
export type TypePredicateFn<T> = (input: unknown, ...args: any[]) => input is T;
|
|
4
11
|
export type InferPredicateReturnType<Fn> = Fn extends TypePredicateFn<infer T> ? T : never;
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
import type { Branded } from './branded.js';
|
|
2
2
|
export type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
3
|
+
/**
|
|
4
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_strings#decimal_numbers
|
|
5
|
+
*/
|
|
3
6
|
export type DecimalNumberString = `${'-' | '+' | ''}${Digit}${number}`;
|
|
7
|
+
/**
|
|
8
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_strings#hexadecimal_numbers
|
|
9
|
+
*/
|
|
4
10
|
export type HexNumberString = `0${'x' | 'X'}${string}`;
|
|
11
|
+
/**
|
|
12
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_strings#octal_numbers
|
|
13
|
+
*/
|
|
5
14
|
export type OctalNumberString = `0${'o' | 'O'}${number}`;
|
|
15
|
+
/**
|
|
16
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_strings#binary_numbers
|
|
17
|
+
*/
|
|
6
18
|
export type BinaryNumberString = `0${'b' | 'B'}${number}`;
|
|
19
|
+
/**
|
|
20
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_strings#exponentiation
|
|
21
|
+
*/
|
|
7
22
|
export type ExponentiationString = `${number}${'e' | 'E'}${number}`;
|
|
23
|
+
/**
|
|
24
|
+
* Signed int 32
|
|
25
|
+
*/
|
|
8
26
|
export type Int32 = Branded<number, 'Int32'>;
|
|
27
|
+
/**
|
|
28
|
+
* Unsigned int 32
|
|
29
|
+
*/
|
|
9
30
|
export type UInt32 = Branded<number, 'UInt32'>;
|
|
10
|
-
export type NumberRange = [
|
|
31
|
+
export type NumberRange = [
|
|
32
|
+
min: number
|
|
33
|
+
] | [min: number, max: undefined] | [min: number, max: number] | [min: undefined, max: number];
|
|
@@ -14,12 +14,77 @@ export type NonNullableEntries<T extends object> = {
|
|
|
14
14
|
export type NonNullableProperties<Type> = {
|
|
15
15
|
[Key in keyof Type]: NonNullable<Type[Key]>;
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Return a type containing all method names
|
|
19
|
+
*/
|
|
17
20
|
export type MethodNames<Type, Key extends keyof Type = keyof Type> = Key extends PropertyKey ? Type[Key] extends Function ? Key : never : never;
|
|
21
|
+
/**
|
|
22
|
+
* Get keys of `Type` for use in `Path`.
|
|
23
|
+
* Keys should not be symbols.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
18
27
|
export type ValidKeys<Type extends object> = object extends Type ? never : Exclude<keyof Type, IfArrayLike<Type, symbol | MethodNames<Type>, symbol>>;
|
|
28
|
+
/**
|
|
29
|
+
* Get the possible dot notations for a given `Type`.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* type ExampleNotation = PathDotNotation<{
|
|
36
|
+
* job: {
|
|
37
|
+
* title: string;
|
|
38
|
+
* }
|
|
39
|
+
* }>;
|
|
40
|
+
* ```
|
|
41
|
+
* Equals:
|
|
42
|
+
* ```ts
|
|
43
|
+
* type ExampleNotation = "job" | "job.title";
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
19
46
|
export type PathDotNotation<Type extends object, Key extends keyof Type = keyof Type> = Key extends ValidKeys<Type> ? Type[Key] extends Primitive ? Key : Key | `${Key}.${PathDotNotation<NonNullable<Type[Key]>>}` : never;
|
|
47
|
+
/**
|
|
48
|
+
* Get the valid keys and dot notations for a given `Type`.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* type ExampleNotation = Path<{
|
|
53
|
+
* job: {
|
|
54
|
+
* title: string;
|
|
55
|
+
* }
|
|
56
|
+
* }>;
|
|
57
|
+
* ```
|
|
58
|
+
* Equals:
|
|
59
|
+
* ```ts
|
|
60
|
+
* type ExampleNotation = "job" | "job.title";
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
20
63
|
export type Path<Type extends object> = PathDotNotation<NonNullableProperties<Type>, keyof Type> | ValidKeys<Type>;
|
|
64
|
+
/**
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
21
67
|
export type MaybeOptional<Type, Optional extends boolean> = Optional extends true ? Type | undefined : Type;
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
22
71
|
export type GetValueForKey<Type extends object, Key extends PropertyKey, Optional extends boolean = CanBeUndefined<Type, true, false>> = Key extends keyof Type ? MaybeOptional<Type[Key], IfArray<Type, true, Optional>> : Key extends `${infer Index extends number}` ? Index extends keyof Type ? MaybeOptional<Type[Index], IfArray<Type, true, Optional>> : never : never;
|
|
72
|
+
/**
|
|
73
|
+
* Get the type for a given dot notation path.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* type ExampleValue = PathValue<{
|
|
78
|
+
* job: {
|
|
79
|
+
* title: string;
|
|
80
|
+
* }
|
|
81
|
+
* }, 'job.title'>;
|
|
82
|
+
* ```
|
|
83
|
+
* Equals:
|
|
84
|
+
* ```ts
|
|
85
|
+
* type ExampleValue = string;
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
23
88
|
export type PathValue<Type extends object, TargetPath extends Path<Type> | AutoCompletableString | number, Optional extends boolean = CanBeUndefined<Type, true, false>> = TargetPath extends `${infer Key}.${infer Rest}` ? GetValueForKey<Type, Key, Optional> extends infer Value ? Rest extends Path<NonNullable<Value>> ? PathValue<NonNullable<Value>, Rest, CanBeUndefined<Value, true, false>> : never : never : GetValueForKey<Type, TargetPath, Optional>;
|
|
24
89
|
export type PathValues<Type extends object, TargetPaths extends Path<Type>> = {
|
|
25
90
|
[TargetPath in TargetPaths as CamelCase<`${TargetPath}`, '.'>]: PathValue<Type, TargetPath>;
|
|
@@ -29,12 +94,21 @@ export type FromPath<TargetPath extends PropertyKey, Value> = TargetPath extends
|
|
|
29
94
|
} : {
|
|
30
95
|
[K in TargetPath]: Value;
|
|
31
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* Get a union of all intermediate paths, ending with `TargetPath`
|
|
99
|
+
*/
|
|
32
100
|
export type AllPaths<TargetPath extends PropertyKey> = TargetPath extends `${infer Head}.${infer Tail}` ? Head | `${Head}.${AllPaths<Tail>}` : TargetPath;
|
|
33
101
|
export type WithPath<Input extends object, InputPath extends PropertyKey, Value = unknown> = Pretty<Input & Merge<Input, FromPath<InputPath, Value>>>;
|
|
34
102
|
export type Merge<Left, Right> = Left extends unknown[] ? Right extends Record<number, unknown> ? MergeArrayWithObject<Left, Right> : Right : Left extends object ? Right extends object ? MergeObjects<Left, Right> : Right : Right;
|
|
103
|
+
/**
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
35
106
|
export type MergeObjects<Left, Right> = {
|
|
36
107
|
[Key in keyof Left | keyof Right]: Key extends keyof Right ? Key extends keyof Left ? Merge<Left[Key], Right[Key]> : Right[Key] : Key extends keyof Left ? Left[Key] : never;
|
|
37
108
|
};
|
|
109
|
+
/**
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
38
112
|
export type MergeArrayWithObject<Left extends unknown[], Right extends UnknownRecord> = Left & {
|
|
39
113
|
[Key in keyof Right]: Key extends keyof Left ? Merge<Left[Key & keyof Left], Right[Key]> : Key extends `${infer Index extends number}` ? Index extends keyof Left ? Merge<Left[Index], Right[Key]> : Right[Key] : Right[Key];
|
|
40
114
|
};
|
|
@@ -2,6 +2,11 @@ export type AnyRecord = Record<PropertyKey, any>;
|
|
|
2
2
|
export type UnknownRecord = Record<PropertyKey, unknown>;
|
|
3
3
|
export type NeverRecord = Record<PropertyKey, never>;
|
|
4
4
|
export type StringRecord = Record<string, string>;
|
|
5
|
+
/**
|
|
6
|
+
* This is an alternative to a TypeScript enum.
|
|
7
|
+
*
|
|
8
|
+
* It is useful for when you do not want reverse mapping of enum values to keys,
|
|
9
|
+
*/
|
|
5
10
|
export type EnumRecord<Key extends string = string, Value extends string | number = string | number> = Record<Key, Value>;
|
|
6
11
|
export type RemoveIndex<Type> = {
|
|
7
12
|
[Key in keyof Type as symbol extends Key ? never : string extends Key ? never : number extends Key ? never : Key]: Type[Key];
|
|
@@ -17,19 +17,40 @@ export type Unwritable<Type> = Type extends Writable<infer Inner> ? Readonly<Inn
|
|
|
17
17
|
export type GetIndex<Type> = {
|
|
18
18
|
[Key in keyof Type as symbol extends Key ? Key : string extends Key ? Key : number extends Key ? Key : never]: Type[Key];
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* All keys exist or none are allowed
|
|
22
|
+
*/
|
|
20
23
|
export type AllOrNone<Type> = Type | {
|
|
21
24
|
[Key in keyof Type]?: never;
|
|
22
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* The specified keys are required and all others are optional
|
|
28
|
+
*/
|
|
23
29
|
export type OptionalExcept<Type, Keys extends keyof Type> = Type extends any ? Partial<Omit<Type, Keys>> & Required<Pick<Type, Keys>> : never;
|
|
30
|
+
/**
|
|
31
|
+
* The specified keys are optional and all others are required
|
|
32
|
+
*/
|
|
24
33
|
export type RequiredExcept<Type, Keys extends keyof Type> = Type extends any ? Required<Omit<Type, Keys>> & Partial<Pick<Type, Keys>> : never;
|
|
34
|
+
/**
|
|
35
|
+
* Return a type with specific keys optional.
|
|
36
|
+
*/
|
|
25
37
|
export type OptionalKeys<Type, Keys extends keyof Type> = Type extends any ? Omit<Type, Keys> & Partial<Pick<Type, Keys>> : never;
|
|
38
|
+
/**
|
|
39
|
+
* Return a type with specific keys required.
|
|
40
|
+
*/
|
|
26
41
|
export type RequiredKeys<Type, Keys extends keyof Type> = Type extends any ? Omit<Type, Keys> & Required<Pick<Type, Keys>> : never;
|
|
27
42
|
export type NonVoid<Type> = Exclude<Type, void>;
|
|
28
43
|
export type Defined<Type> = Exclude<Type, undefined | void>;
|
|
29
44
|
export type RemoveNever<Type> = {
|
|
30
45
|
[Key in keyof Type as [Type[Key]] extends [never] ? never : Key]: Type[Key];
|
|
31
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Return a list of keys where the property value match the `DataType`.
|
|
49
|
+
*/
|
|
32
50
|
export type KeysWhere<Type, DataType, Key extends keyof Type = keyof Type> = Key extends PropertyKey ? Type[Key] extends DataType ? Key : never : never;
|
|
51
|
+
/**
|
|
52
|
+
* Construct a type where all the property values match the `DataType`.
|
|
53
|
+
*/
|
|
33
54
|
export type PickByType<Type, DataType> = {
|
|
34
55
|
[Property in KeysWhere<Type, DataType>]: Type[Property];
|
|
35
56
|
};
|
|
@@ -49,6 +70,9 @@ export type Pretty<Type> = {
|
|
|
49
70
|
export type Simplify<Type> = Type extends string ? string : Type extends number ? number : Type extends boolean ? boolean : Type extends bigint ? bigint : Type extends symbol ? symbol : Type extends undefined ? undefined : Type extends null ? null : Type extends Function ? Type : Type extends object ? {
|
|
50
71
|
[Key in keyof Type]: Simplify<Type[Key]>;
|
|
51
72
|
} : Type;
|
|
73
|
+
/**
|
|
74
|
+
* Check if the keys of a type are only numeric.
|
|
75
|
+
*/
|
|
52
76
|
export type IfHasOnlyNumericKeys<Type, T, F> = `${Exclude<keyof Type, symbol>}` extends `${number}` ? T : F;
|
|
53
77
|
export type HasOnlyNumericKeys<Type> = IfHasOnlyNumericKeys<Type, true, false>;
|
|
54
78
|
export type ParseNumber<T extends string> = T extends `${infer N extends number}` ? N : never;
|
package/dist/types/unique.d.ts
CHANGED
|
@@ -3,8 +3,26 @@ export type MembershipStore<T> = {
|
|
|
3
3
|
add(value: T): void;
|
|
4
4
|
};
|
|
5
5
|
export type UniqueOptions<Type> = {
|
|
6
|
+
/**
|
|
7
|
+
* Return a custom ID to uniquely identify an item.
|
|
8
|
+
*/
|
|
6
9
|
identity?: (item: Type) => unknown;
|
|
10
|
+
/**
|
|
11
|
+
* Return `true` to yield the item.
|
|
12
|
+
*
|
|
13
|
+
* @privateRemarks
|
|
14
|
+
* TODO: Refactor to use `filter` on the (async)iterator when available.
|
|
15
|
+
* @see https://github.com/tc39/proposal-async-iterator-helpers
|
|
16
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/filter
|
|
17
|
+
*/
|
|
7
18
|
filter?: (item: Type) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* A store to keep track of which items have been seen.
|
|
21
|
+
*
|
|
22
|
+
* If you have a large dataset, you may want to use a more memory-efficient store than a `Set`, such as a Bloom filter.
|
|
23
|
+
*
|
|
24
|
+
* @default `Set<unknown>`.
|
|
25
|
+
*/
|
|
8
26
|
store?: MembershipStore<unknown>;
|
|
9
27
|
};
|
|
10
28
|
export declare function unique<Type>(items: AsyncIterable<Type>, options?: UniqueOptions<Type>): AsyncIterable<Type>;
|