inferred-types 0.55.6 → 0.55.8

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.
@@ -7859,9 +7859,12 @@ type IterateOver<TContent extends readonly unknown[], TTrailing extends string>
7859
7859
  type EnsureTrailing<TContent extends string | number | readonly (string | number)[], TTrailing extends string | number> = IsWideType<TContent> extends true ? IsWideType<TTrailing> extends true ? TContent : `${string}${TTrailing}` : IsWideType<TTrailing> extends true ? IsString<TContent> extends true ? `${AsString<TContent>}${string}` : never : TContent extends number ? AsNumber<P<`${TContent}`, `${TTrailing}`>> : TContent extends string ? P<TContent, `${TTrailing}`> : TContent extends readonly unknown[] ? IterateOver<TContent, `${TTrailing}`> : never;
7860
7860
 
7861
7861
  /** the shae for an American Express long number */
7862
- type AmericanExpress = `${number} ${number} ${number}`;
7862
+ type AmericanExpress = `${"34" | "37"}${number} ${number} ${number}`;
7863
+ /** the shape of Visa long numbers */
7864
+ type Visa = `4${number} ${number} ${number} ${number}`;
7865
+ type Mastercard = `${"51" | "55"}${number} ${number} ${number} ${number}` | `2${"2" | "3" | "4" | "5" | "6" | "7"}${number} ${number} ${number} ${number}`;
7863
7866
  /** the shape for a VISA/Mastercard long number */
7864
- type VisaMastercard = `${number} ${number} ${number} ${number}`;
7867
+ type VisaMastercard = Visa | Mastercard;
7865
7868
  /**
7866
7869
  * Represents the string literal type for either a Mastercard/VISA
7867
7870
  * format or an American Express card.
@@ -10835,13 +10838,13 @@ type TypeToken__Number = `::${number}`;
10835
10838
  type TypeToken__NumberSet = "bigInt" | `bigInt::${bigint}` | "digit" | `digit::${2 | 3 | 4}` | "integer";
10836
10839
  type params = string;
10837
10840
  type rtn = string;
10838
- type D = TypeTokenDelimiter;
10839
- type TypeToken__Fn = `[${params}]` | `[${params}]${D}${rtn}` | `any::${rtn}`;
10840
- type TypeToken__Gen = `[${params}]` | `[${params}]${D}${rtn}` | `gen${D}any${D}${rtn}`;
10841
- type TypeToken__FnSet = `withoutParams` | `withoutParams${D}${rtn}` | `booleanLogic` | `booleanLogic${D}[${params}]`;
10841
+ type D$1 = TypeTokenDelimiter;
10842
+ type TypeToken__Fn = `[${params}]` | `[${params}]${D$1}${rtn}` | `any::${rtn}`;
10843
+ type TypeToken__Gen = `[${params}]` | `[${params}]${D$1}${rtn}` | `gen${D$1}any${D$1}${rtn}`;
10844
+ type TypeToken__FnSet = `withoutParams` | `withoutParams${D$1}${rtn}` | `booleanLogic` | `booleanLogic${D$1}[${params}]`;
10842
10845
  type RecVariant = typeof TYPE_TOKEN_REC_VARIANTS[number];
10843
10846
  type RecKeyVariant = typeof TYPE_TOKEN_REC_KEY_VARIANTS[number];
10844
- type TypeToken__Rec = `${RecVariant}${D}${RecKeyVariant}` | `${D}kv${D}${string}` | `${D}kv${D}${string}${D}${"withUnknownIndex" | "withAnyIndex"}`;
10847
+ type TypeToken__Rec = `${RecVariant}${D$1}${RecKeyVariant}` | `${D$1}kv${D$1}${string}` | `${D$1}kv${D$1}${string}${D$1}${"withUnknownIndex" | "withAnyIndex"}`;
10845
10848
  type TypeToken__Undefined = "";
10846
10849
  type TypeToken__Null = "";
10847
10850
  type TypeToken__Boolean = "";
@@ -13735,7 +13738,10 @@ type Mapper<TFrom extends AnyObject, TTo> = (<TInput extends TFrom>(from: TInput
13735
13738
  declare function createObjectMap<TFrom extends AnyObject, TTo extends AnyObject>(): <TMap extends ObjectMap<TFrom, TTo>>(map: TMap) => ObjectMapConversion<TFrom, TTo, TMap>;
13736
13739
  declare function createMapper<TFrom extends AnyObject, TTo extends AnyObject>(): <TFn extends <TInput extends TFrom>(cb: TInput) => { [K in keyof TInput]: TTo; }>(fn: TFn) => Mapper<TFrom, TTo>;
13737
13740
 
13738
- declare function mergeObjects<D extends Narrowable, O extends Narrowable, TDefault extends NarrowObject<D>, TOverride extends NarrowObject<O>>(defVal: TDefault, override: TOverride): MergeObjects<TDefault, TOverride>;
13741
+ /**
13742
+ * merge two objects while preserving narrow types
13743
+ */
13744
+ declare function mergeObjects<TDefault extends NarrowObject<D>, TOverride extends NarrowObject<O>, D extends Narrowable, O extends Narrowable>(defVal: TDefault, override: TOverride): MergeObjects<TDefault, TOverride>;
13739
13745
 
13740
13746
  /**
13741
13747
  * **mergeScalars**(a,b)
@@ -14041,9 +14047,24 @@ declare function isTomorrow(test: unknown): boolean;
14041
14047
  */
14042
14048
  declare function isYesterday(test: unknown): boolean;
14043
14049
 
14050
+ declare function isVisa(val: unknown): val is Visa;
14051
+ declare function isMastercard(val: unknown): val is Mastercard;
14044
14052
  declare function isVisaMastercard(val: unknown): val is VisaMastercard;
14045
14053
  declare function isAmericanExpress(val: unknown): val is AmericanExpress;
14046
14054
  declare function isCreditCard(val: unknown): val is CreditCard;
14055
+ /**
14056
+ * Given a card's long number, attempt to match this to a card type from:
14057
+ *
14058
+ * - Visa, Mastercard
14059
+ * - American Express
14060
+ * - Discover
14061
+ * - JCB
14062
+ * - Diners Club
14063
+ * - China UnionPay
14064
+ * - Maestro
14065
+ * - Solo
14066
+ */
14067
+ declare function cardType(cardNumber: string | number): string;
14047
14068
 
14048
14069
  /**
14049
14070
  * Type guard which checks whether `val` is a 2 character country
@@ -15475,4 +15496,4 @@ declare function isVueRef(val: unknown): val is VueRef;
15475
15496
  */
15476
15497
  declare function asVueRef<T extends Narrowable>(value: T): VueRef<T>;
15477
15498
 
15478
- export { type AsClassSelector, type AsList, type BoxValue, type BoxedFnParams, type ConfigRestApi, type CssKeyframeCallback, type CssSelectorOptions, type CsvFormat, type DictionaryWithValueFilter, type DictionaryWithoutValueFilter, type DoesExtendTypeguard, type EndingWithTypeGuard, type EndpointGenerator, type EqualTo, type Finder, type FnParam, type FnParams, type GenParam, type GenParams, type GetEachOptions, type GetInference, type GetInferenceProps, type GetOptions, type Joiner, type KeyframeApi, type Mapper, type Rtn, ShapeApiImplementation, type SingletonClosure, type StartingWithTypeGuard, type StripSurroundConfigured, type SurroundWith, type ToKeyValueSort, type TokenContainerClosure, type TokenFunctionClosure, type TokenSetClosure, type TypeOfTypeGuard, type Unbox, type UndefinedArrayIsUnknown, type UnionClosure, type UrlMeta, type YouTubeMeta, addFnToProps, addPropsToFn, and, asApi, asArray, asChars, asDate, asEscapeFunction, asIsoDate, asOptionalParamFunction, asPhoneFormat, asRecord, asString, asStringLiteral, asType, asTypeToken, asVueRef, box, boxDictionaryValues, capitalize, choices, createConverter, createCssKeyframe, createCssSelector, createErrorCondition, createFifoQueue, createFixedLengthArray, createFnWithProps, createFnWithPropsExplicit, createLifoQueue, createMapper, createObjectMap, createTypeToken, cssColor, csv, defineCss, defineObj, defineObject, defineObjectApi, defineTuple, doesExtend, endsWith, ensureLeading, ensureSurround, ensureTrailing, entries, errCondition, filter, find, fnMeta, fromDefineObject, fromKeyValue, get, getDaysBetween, getEach, getPhoneCountryCode, getTailwindModifiers, getToday, getTokenKind, getTomorrow, getTypeSubtype, getUrlBase, getUrlDefaultPort, getUrlDynamics, getUrlPath, getUrlPort, getUrlProtocol, getUrlQueryParams, getUrlSource, getWeekNumber, getYesterday, getYouTubePageType, handleDoneFn, hasCountryCode, hasDefaultValue, hasIndexOf, hasKeys, hasOverlappingKeys, hasProtocol, hasProtocolPrefix, hasUrlPort, hasUrlQueryParameter, hasWhiteSpace, idLiteral, idTypeGuard, identity, ifArray, ifArrayPartial, ifBoolean, ifChar, ifContainer, ifDefined, ifFalse, ifFunction, ifHasKey, ifLength, ifLowercaseChar, ifNotNull, ifNull, ifNumber, ifObject, ifSameType, ifScalar, ifString, ifTrue, ifUndefined, ifUppercaseChar, indexOf, infer, intersect, intersection, ip6GroupExpansion, ip6Prefix, isAccelerationMetric, isAccelerationUom, isAlpha, isAmazonUrl, isAmericanExpress, isApi, isApiSurface, isAppleUrl, isAreaMetric, isAreaUom, isArray, isArrayToken, isAtomicKind, isAtomicToken, isAustralianNewsUrl, isBelgiumNewsUrl, isBestBuyUrl, isBitbucketUrl, isBoolean, isBooleanLike, isBox, isCanadianNewsUrl, isChineseNewsUrl, isCodeCommitUrl, isConstant, isContainer, isContainerToken, isCostCoUrl, isCountryAbbrev, isCountryCode2, isCountryCode3, isCountryName, isCreditCard, isCssAspectRatio, isCsv, isCurrentMetric, isCurrentUom, isCvsUrl, isDanishNewsUrl, isDate, isDefineObject, isDefined, isDellUrl, isDistanceMetric, isDistanceUom, isDomainName, isDoneFn, isDutchNewsUrl, isEbayUrl, isEmail, isEmpty, isEnergyMetric, isEnergyUom, isEqual, isErrorCondition, isEscapeFunction, isEtsyUrl, isFalse, isFalsy, isFnBasedKind, isFnBasedToken, isFnWithParams, isFrenchNewsUrl, isFrequencyMetric, isFrequencyUom, isFunction, isGermanNewsUrl, isGithubIssueUrl, isGithubIssuesListUrl, isGithubOrgUrl, isGithubProjectUrl, isGithubProjectsListUrl, isGithubReleaseTagUrl, isGithubReleasesListUrl, isGithubRepoReleaseTagUrl, isGithubRepoReleasesUrl, isGithubRepoUrl, isGithubUrl, isHexadecimal, isHmUrl, isHomeDepotUrl, isHtmlElement, isIkeaUrl, isIndexable, isIndianNewsUrl, isInlineSvg, isIp4Address, isIp6Address, isIpAddress, isIso3166Alpha2, isIso3166Alpha3, isIso3166CountryCode, isIso3166CountryName, isIsoDate, isIsoDateTime, isIsoExplicitDate, isIsoExplicitTime, isIsoImplicitDate, isIsoImplicitTime, isIsoTime, isIsoYear, isItalianNewsUrl, isJapaneseNewsUrl, isKrogersUrl, isLeapYear, isLength, isLikeRegExp, isLowesUrl, isLuminosityMetric, isLuminosityUom, isLuxonDateTime, isMacysUrl, isMap, isMapToken, isMassMetric, isMassUom, isMetric, isMexicanNewsUrl, isMoment, isNarrowableObject, isNever, isNewsUrl, isNikeUrl, isNorwegianNewsUrl, isNotNull, isNothing, isNull, isNumber, isNumberLike, isNumericArray, isNumericString, isObject, isObjectToken, isOptionalParamFunction, isPhoneNumber, isPowerMetric, isPowerUom, isPressureMetric, isPressureUom, isProtocol, isProtocolPrefix, isReadonlyArray, isRecordToken, isRef, isRegExp, isRepoSource, isRepoUrl, isResistance, isResistanceUom, isRetailUrl, isSameTypeOf, isScalar, isSemanticVersion, isSet, isSetBasedKind, isSetBasedToken, isSetContainer, isSetToken, isShape, isShapeCallback, isSimpleContainerToken, isSimpleContainerTokenTuple, isSimpleScalarToken, isSimpleScalarTokenTuple, isSimpleToken, isSimpleTokenTuple, isSingletonKind, isSingletonToken, isSocialMediaProfileUrl, isSocialMediaUrl, isSouthKoreanNewsUrl, isSpanishNewsUrl, isSpecificConstant, isSpeedMetric, isSpeedUom, isString, isStringArray, isSwissNewsUrl, isSymbol, isTailwindColor, isTailwindColorClass, isTailwindColorName, isTailwindColorTarget, isTailwindColorWithLuminosity, isTailwindColorWithLuminosityAndOpacity, isTailwindModifier, isTargetUrl, isTemperatureMetric, isTemperatureUom, isThenable, isThisMonth, isThisWeek, isThisYear, isTimeMetric, isTimeUom, isToday, isTomorrow, isTrimable, isTrue, isTruthy, isTuple, isTupleToken, isTurkishNewsUrl, isTypeOf, isTypeSubtype, isTypeToken, isTypeTokenKind, isTypeTuple, isUkNewsUrl, isUndefined, isUnset, isUom, isUri, isUrl, isUrlPath, isUrlSource, isUsNewsUrl, isUsPhoneNumber, isUsStateAbbreviation, isUsStateName, isVariable, isVisaMastercard, isVoltageMetric, isVoltageUom, isVolumeMetric, isVolumeUom, isVueRef, isWalgreensUrl, isWalmartUrl, isWayfairUrl, isWholeFoodsUrl, isYesterday, isYouTubeCreatorUrl, isYouTubeFeedHistoryUrl, isYouTubeFeedUrl, isYouTubePlaylistUrl, isYouTubePlaylistsUrl, isYouTubeShareUrl, isYouTubeSubscriptionsUrl, isYouTubeTrendingUrl, isYouTubeUrl, isYouTubeVideoUrl, isYouTubeVideosInPlaylist, isZaraUrl, isZipCode, isZipCode5, isZipPlus4, joinWith, jsonValue, jsonValues, keysOf, kindLiteral, last, list, literal, logicalReturns, lookupCountryAlpha2, lookupCountryAlpha3, lookupCountryCode, lookupCountryName, lowercase, maybePhoneNumber, mergeObjects, mergeScalars, mergeTuples, nameLiteral, narrow, narrowObjectTo, narrowObjectToType, never, objectToApi, objectValues, omit, optional, optionalOrNull, or, orNull, pathJoin, pluralize, removePhoneCountryCode, removeTailwindModifiers, removeUrlProtocol, result, retain, retainAfter, retainAfterInclusive, retainChars, retainUntil, retainUntilInclusive, retainWhile, reverse, rightWhitespace, shape, sharedKeys, shift, simpleContainerToken, simpleContainerTokenToTypeToken, simpleContainerType, simpleScalarToken, simpleScalarTokenToTypeToken, simpleScalarType, simpleToken, simpleType, simpleUnionTokenToTypeToken, slice, split, startsWith, stripAfter, stripBefore, stripChars, stripLeading, stripParenthesis, stripSurround, stripTrailing, stripUntil, stripWhile, surround, takeNumericCharacters, takeProp, toCamelCase, toKebabCase, toKeyValue, toNumber, toNumericArray, toPascalCase, toSnakeCase, toString, toUppercase, trim, trimEnd, trimLeft, trimRight, trimStart, truncate, tuple, twColor, unbox, uncapitalize, union, unionize, unique, uniqueKeys, unset, uppercase, urlMeta, valuesOf, widen, withDefaults, withKeys, withValue, withoutKeys, withoutValue, wrapFn, youtubeEmbed, youtubeMeta };
15499
+ export { type AsClassSelector, type AsList, type BoxValue, type BoxedFnParams, type ConfigRestApi, type CssKeyframeCallback, type CssSelectorOptions, type CsvFormat, type DictionaryWithValueFilter, type DictionaryWithoutValueFilter, type DoesExtendTypeguard, type EndingWithTypeGuard, type EndpointGenerator, type EqualTo, type Finder, type FnParam, type FnParams, type GenParam, type GenParams, type GetEachOptions, type GetInference, type GetInferenceProps, type GetOptions, type Joiner, type KeyframeApi, type Mapper, type Rtn, ShapeApiImplementation, type SingletonClosure, type StartingWithTypeGuard, type StripSurroundConfigured, type SurroundWith, type ToKeyValueSort, type TokenContainerClosure, type TokenFunctionClosure, type TokenSetClosure, type TypeOfTypeGuard, type Unbox, type UndefinedArrayIsUnknown, type UnionClosure, type UrlMeta, type YouTubeMeta, addFnToProps, addPropsToFn, and, asApi, asArray, asChars, asDate, asEscapeFunction, asIsoDate, asOptionalParamFunction, asPhoneFormat, asRecord, asString, asStringLiteral, asType, asTypeToken, asVueRef, box, boxDictionaryValues, capitalize, cardType, choices, createConverter, createCssKeyframe, createCssSelector, createErrorCondition, createFifoQueue, createFixedLengthArray, createFnWithProps, createFnWithPropsExplicit, createLifoQueue, createMapper, createObjectMap, createTypeToken, cssColor, csv, defineCss, defineObj, defineObject, defineObjectApi, defineTuple, doesExtend, endsWith, ensureLeading, ensureSurround, ensureTrailing, entries, errCondition, filter, find, fnMeta, fromDefineObject, fromKeyValue, get, getDaysBetween, getEach, getPhoneCountryCode, getTailwindModifiers, getToday, getTokenKind, getTomorrow, getTypeSubtype, getUrlBase, getUrlDefaultPort, getUrlDynamics, getUrlPath, getUrlPort, getUrlProtocol, getUrlQueryParams, getUrlSource, getWeekNumber, getYesterday, getYouTubePageType, handleDoneFn, hasCountryCode, hasDefaultValue, hasIndexOf, hasKeys, hasOverlappingKeys, hasProtocol, hasProtocolPrefix, hasUrlPort, hasUrlQueryParameter, hasWhiteSpace, idLiteral, idTypeGuard, identity, ifArray, ifArrayPartial, ifBoolean, ifChar, ifContainer, ifDefined, ifFalse, ifFunction, ifHasKey, ifLength, ifLowercaseChar, ifNotNull, ifNull, ifNumber, ifObject, ifSameType, ifScalar, ifString, ifTrue, ifUndefined, ifUppercaseChar, indexOf, infer, intersect, intersection, ip6GroupExpansion, ip6Prefix, isAccelerationMetric, isAccelerationUom, isAlpha, isAmazonUrl, isAmericanExpress, isApi, isApiSurface, isAppleUrl, isAreaMetric, isAreaUom, isArray, isArrayToken, isAtomicKind, isAtomicToken, isAustralianNewsUrl, isBelgiumNewsUrl, isBestBuyUrl, isBitbucketUrl, isBoolean, isBooleanLike, isBox, isCanadianNewsUrl, isChineseNewsUrl, isCodeCommitUrl, isConstant, isContainer, isContainerToken, isCostCoUrl, isCountryAbbrev, isCountryCode2, isCountryCode3, isCountryName, isCreditCard, isCssAspectRatio, isCsv, isCurrentMetric, isCurrentUom, isCvsUrl, isDanishNewsUrl, isDate, isDefineObject, isDefined, isDellUrl, isDistanceMetric, isDistanceUom, isDomainName, isDoneFn, isDutchNewsUrl, isEbayUrl, isEmail, isEmpty, isEnergyMetric, isEnergyUom, isEqual, isErrorCondition, isEscapeFunction, isEtsyUrl, isFalse, isFalsy, isFnBasedKind, isFnBasedToken, isFnWithParams, isFrenchNewsUrl, isFrequencyMetric, isFrequencyUom, isFunction, isGermanNewsUrl, isGithubIssueUrl, isGithubIssuesListUrl, isGithubOrgUrl, isGithubProjectUrl, isGithubProjectsListUrl, isGithubReleaseTagUrl, isGithubReleasesListUrl, isGithubRepoReleaseTagUrl, isGithubRepoReleasesUrl, isGithubRepoUrl, isGithubUrl, isHexadecimal, isHmUrl, isHomeDepotUrl, isHtmlElement, isIkeaUrl, isIndexable, isIndianNewsUrl, isInlineSvg, isIp4Address, isIp6Address, isIpAddress, isIso3166Alpha2, isIso3166Alpha3, isIso3166CountryCode, isIso3166CountryName, isIsoDate, isIsoDateTime, isIsoExplicitDate, isIsoExplicitTime, isIsoImplicitDate, isIsoImplicitTime, isIsoTime, isIsoYear, isItalianNewsUrl, isJapaneseNewsUrl, isKrogersUrl, isLeapYear, isLength, isLikeRegExp, isLowesUrl, isLuminosityMetric, isLuminosityUom, isLuxonDateTime, isMacysUrl, isMap, isMapToken, isMassMetric, isMassUom, isMastercard, isMetric, isMexicanNewsUrl, isMoment, isNarrowableObject, isNever, isNewsUrl, isNikeUrl, isNorwegianNewsUrl, isNotNull, isNothing, isNull, isNumber, isNumberLike, isNumericArray, isNumericString, isObject, isObjectToken, isOptionalParamFunction, isPhoneNumber, isPowerMetric, isPowerUom, isPressureMetric, isPressureUom, isProtocol, isProtocolPrefix, isReadonlyArray, isRecordToken, isRef, isRegExp, isRepoSource, isRepoUrl, isResistance, isResistanceUom, isRetailUrl, isSameTypeOf, isScalar, isSemanticVersion, isSet, isSetBasedKind, isSetBasedToken, isSetContainer, isSetToken, isShape, isShapeCallback, isSimpleContainerToken, isSimpleContainerTokenTuple, isSimpleScalarToken, isSimpleScalarTokenTuple, isSimpleToken, isSimpleTokenTuple, isSingletonKind, isSingletonToken, isSocialMediaProfileUrl, isSocialMediaUrl, isSouthKoreanNewsUrl, isSpanishNewsUrl, isSpecificConstant, isSpeedMetric, isSpeedUom, isString, isStringArray, isSwissNewsUrl, isSymbol, isTailwindColor, isTailwindColorClass, isTailwindColorName, isTailwindColorTarget, isTailwindColorWithLuminosity, isTailwindColorWithLuminosityAndOpacity, isTailwindModifier, isTargetUrl, isTemperatureMetric, isTemperatureUom, isThenable, isThisMonth, isThisWeek, isThisYear, isTimeMetric, isTimeUom, isToday, isTomorrow, isTrimable, isTrue, isTruthy, isTuple, isTupleToken, isTurkishNewsUrl, isTypeOf, isTypeSubtype, isTypeToken, isTypeTokenKind, isTypeTuple, isUkNewsUrl, isUndefined, isUnset, isUom, isUri, isUrl, isUrlPath, isUrlSource, isUsNewsUrl, isUsPhoneNumber, isUsStateAbbreviation, isUsStateName, isVariable, isVisa, isVisaMastercard, isVoltageMetric, isVoltageUom, isVolumeMetric, isVolumeUom, isVueRef, isWalgreensUrl, isWalmartUrl, isWayfairUrl, isWholeFoodsUrl, isYesterday, isYouTubeCreatorUrl, isYouTubeFeedHistoryUrl, isYouTubeFeedUrl, isYouTubePlaylistUrl, isYouTubePlaylistsUrl, isYouTubeShareUrl, isYouTubeSubscriptionsUrl, isYouTubeTrendingUrl, isYouTubeUrl, isYouTubeVideoUrl, isYouTubeVideosInPlaylist, isZaraUrl, isZipCode, isZipCode5, isZipPlus4, joinWith, jsonValue, jsonValues, keysOf, kindLiteral, last, list, literal, logicalReturns, lookupCountryAlpha2, lookupCountryAlpha3, lookupCountryCode, lookupCountryName, lowercase, maybePhoneNumber, mergeObjects, mergeScalars, mergeTuples, nameLiteral, narrow, narrowObjectTo, narrowObjectToType, never, objectToApi, objectValues, omit, optional, optionalOrNull, or, orNull, pathJoin, pluralize, removePhoneCountryCode, removeTailwindModifiers, removeUrlProtocol, result, retain, retainAfter, retainAfterInclusive, retainChars, retainUntil, retainUntilInclusive, retainWhile, reverse, rightWhitespace, shape, sharedKeys, shift, simpleContainerToken, simpleContainerTokenToTypeToken, simpleContainerType, simpleScalarToken, simpleScalarTokenToTypeToken, simpleScalarType, simpleToken, simpleType, simpleUnionTokenToTypeToken, slice, split, startsWith, stripAfter, stripBefore, stripChars, stripLeading, stripParenthesis, stripSurround, stripTrailing, stripUntil, stripWhile, surround, takeNumericCharacters, takeProp, toCamelCase, toKebabCase, toKeyValue, toNumber, toNumericArray, toPascalCase, toSnakeCase, toString, toUppercase, trim, trimEnd, trimLeft, trimRight, trimStart, truncate, tuple, twColor, unbox, uncapitalize, union, unionize, unique, uniqueKeys, unset, uppercase, urlMeta, valuesOf, widen, withDefaults, withKeys, withValue, withoutKeys, withoutValue, wrapFn, youtubeEmbed, youtubeMeta };
@@ -4204,13 +4204,23 @@ function isYesterday(test) {
4204
4204
  }
4205
4205
 
4206
4206
  // src/type-guards/finance/CreditCards.ts
4207
- function isVisaMastercard(val) {
4208
- if (isString(val)) {
4207
+ function isVisa(val) {
4208
+ if (isString(val) && val.startsWith("4")) {
4209
4209
  const parts = val.split(" ");
4210
4210
  return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4);
4211
4211
  }
4212
4212
  return false;
4213
4213
  }
4214
+ function isMastercard(val) {
4215
+ if (isString(val) && val.startsWith("4")) {
4216
+ const parts = val.split(" ");
4217
+ return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4) && ["51", "55", "22", "23", "24", "25", "26", "27"].some((i) => val.startsWith(i));
4218
+ }
4219
+ return false;
4220
+ }
4221
+ function isVisaMastercard(val) {
4222
+ return isVisa(val) || isMastercard(val);
4223
+ }
4214
4224
  function isAmericanExpress(val) {
4215
4225
  if (isString(val)) {
4216
4226
  const parts = val.split(" ");
@@ -4223,6 +4233,57 @@ function isAmericanExpress(val) {
4223
4233
  function isCreditCard(val) {
4224
4234
  return isVisaMastercard(val) || isAmericanExpress(val);
4225
4235
  }
4236
+ function cardType(cardNumber) {
4237
+ const cleanedNumber = String(cardNumber).replace(/\D/g, "");
4238
+ const length = cleanedNumber.length;
4239
+ if (!isValidLength(length)) {
4240
+ return "invalid";
4241
+ }
4242
+ if (!luhnCheck(cleanedNumber)) {
4243
+ return "invalid";
4244
+ }
4245
+ const cardTypes = [
4246
+ { name: "Visa", lengths: [16], prefixes: [/^4/] },
4247
+ { name: "Mastercard", lengths: [16], prefixes: [/^(51|52|53|54|55|222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)/] },
4248
+ { name: "American Express", lengths: [15], prefixes: [/^3[47]/] },
4249
+ { name: "Discover", lengths: [16], prefixes: [/^(6011|622(12[6-9]|1[3-9]\d|2[0-4]\d|25\d|6[4-9]|7[0-4]|8[0-4]|9\d)|64[4-9]|65)/] },
4250
+ { name: "JCB", lengths: [16], prefixes: [/^(35|2131|1800)/] },
4251
+ { name: "Diners Club", lengths: [14, 16], prefixes: [/^(30[0-5]|36|38)/] },
4252
+ { name: "China UnionPay", lengths: [16, 17, 18, 19], prefixes: [/^(62|88)/] },
4253
+ { name: "Maestro", lengths: [12, 13, 14, 15, 16, 17, 18, 19], prefixes: [/^(5018|5020|5038|6304)/] },
4254
+ { name: "Solo", lengths: [16, 18, 19], prefixes: [/^(6334|6767)/] }
4255
+ ];
4256
+ for (const type of cardTypes) {
4257
+ if (type.lengths.includes(length)) {
4258
+ for (const prefix of type.prefixes) {
4259
+ if (prefix.test(cleanedNumber)) {
4260
+ return type.name;
4261
+ }
4262
+ }
4263
+ }
4264
+ }
4265
+ return "invalid";
4266
+ }
4267
+ function isValidLength(length) {
4268
+ const validLengths = [13, 14, 15, 16, 17, 18, 19];
4269
+ return validLengths.includes(length);
4270
+ }
4271
+ function luhnCheck(num) {
4272
+ let sum = 0;
4273
+ let double = false;
4274
+ for (let i = num.length - 1; i >= 0; i--) {
4275
+ let n = Number.parseInt(num.charAt(i), 10);
4276
+ if (double) {
4277
+ n *= 2;
4278
+ if (n > 9) {
4279
+ n -= 9;
4280
+ }
4281
+ }
4282
+ sum += n;
4283
+ double = !double;
4284
+ }
4285
+ return sum % 10 === 0;
4286
+ }
4226
4287
 
4227
4288
  // src/type-guards/isString.ts
4228
4289
  function isString(value) {
@@ -5460,18 +5521,10 @@ function createMapper() {
5460
5521
 
5461
5522
  // src/type-conversion/mergeObjects.ts
5462
5523
  function mergeObjects(defVal, override) {
5463
- const intersectingKeys = sharedKeys(defVal, override);
5464
- const defUnique = withoutKeys(defVal, ...intersectingKeys);
5465
- const overrideUnique = withoutKeys(defVal, ...intersectingKeys);
5466
- const merged = {
5467
- ...intersectingKeys.reduce(
5468
- (acc, key) => typeof override[key] === "undefined" ? { ...acc, [key]: defVal[key] } : { ...acc, [key]: override[key] },
5469
- {}
5470
- ),
5471
- ...defUnique,
5472
- ...overrideUnique
5524
+ return {
5525
+ ...defVal,
5526
+ ...override
5473
5527
  };
5474
- return merged;
5475
5528
  }
5476
5529
 
5477
5530
  // src/type-conversion/mergeScalars.ts
@@ -5602,6 +5655,7 @@ export {
5602
5655
  box,
5603
5656
  boxDictionaryValues,
5604
5657
  capitalize,
5658
+ cardType,
5605
5659
  choices,
5606
5660
  createConverter,
5607
5661
  createCssKeyframe,
@@ -5811,6 +5865,7 @@ export {
5811
5865
  isMapToken,
5812
5866
  isMassMetric,
5813
5867
  isMassUom,
5868
+ isMastercard,
5814
5869
  isMetric,
5815
5870
  isMexicanNewsUrl,
5816
5871
  isMoment,
@@ -5916,6 +5971,7 @@ export {
5916
5971
  isUsStateAbbreviation,
5917
5972
  isUsStateName,
5918
5973
  isVariable,
5974
+ isVisa,
5919
5975
  isVisaMastercard,
5920
5976
  isVoltageMetric,
5921
5977
  isVoltageUom,