inferred-types 0.54.8 → 0.54.9
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/README.md +81 -36
- package/modules/inferred-types/dist/index.cjs +135 -8
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +95 -20
- package/modules/inferred-types/dist/index.js +130 -8
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +147 -8
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +86 -20
- package/modules/runtime/dist/index.js +142 -8
- package/modules/runtime/dist/index.js.map +1 -1
- package/modules/types/dist/index.d.ts +10 -1
- package/package.json +1 -1
|
@@ -11089,6 +11089,25 @@ type WithoutKeys<TObj extends Dictionary, TKeys extends ObjectKey | readonly Obj
|
|
|
11089
11089
|
*/
|
|
11090
11090
|
type WithoutValue<TObj extends AnyObject, TValue extends Narrowable> = ExpandRecursively<Pick<TObj, KeysWithoutValue<TObj, TValue>>>;
|
|
11091
11091
|
|
|
11092
|
+
type Marked$1 = typeof MARKED;
|
|
11093
|
+
type Process$1<TObj extends Dictionary, TValue, TOp extends "equals" | "extends"> = RemoveMarked<{
|
|
11094
|
+
[K in keyof TObj]: If<Compare$1<TObj[K], TOp, TValue>, TObj[K], Marked$1>;
|
|
11095
|
+
}>;
|
|
11096
|
+
/**
|
|
11097
|
+
* **WithValue**`<TObj,TValue>`
|
|
11098
|
+
*
|
|
11099
|
+
* Reduces an object's type down to only those key/value pairs where the
|
|
11100
|
+
* value is of type `W`.
|
|
11101
|
+
* ```ts
|
|
11102
|
+
* const foo = { a: 1, b: "hi", c: () => "hello" }
|
|
11103
|
+
* // { c: () => "hello" }
|
|
11104
|
+
* type W = WithValue<typeof foo, Function>
|
|
11105
|
+
* ```
|
|
11106
|
+
*
|
|
11107
|
+
* **Related:** `WithoutValue`, `WithKeys`, `WithoutKeys`
|
|
11108
|
+
*/
|
|
11109
|
+
type WithValue<TObj extends Dictionary, TValue, TOp extends "equals" | "extends" = "extends"> = ExpandRecursively<Process$1<TObj, TValue, TOp>>;
|
|
11110
|
+
|
|
11092
11111
|
/**
|
|
11093
11112
|
* A dictionary which contains a `key` and `value` property.
|
|
11094
11113
|
*/
|
|
@@ -11741,6 +11760,13 @@ declare function narrowObjectTo<TDefn extends DefineObject>(_defn: TDefn): Const
|
|
|
11741
11760
|
*/
|
|
11742
11761
|
declare function narrowObjectToType<TDefn extends AnyObject>(): ConstrainedObjectIdentity<TDefn>;
|
|
11743
11762
|
|
|
11763
|
+
/**
|
|
11764
|
+
* **objectValues**`(obj) -> [val, val, val]`
|
|
11765
|
+
*
|
|
11766
|
+
* Converts an object into a strongly typed tuple of the _values_ of
|
|
11767
|
+
*/
|
|
11768
|
+
declare function objectValues<T extends Record<ObjectKey, N>, N extends Narrowable>(obj: T): Values<T>;
|
|
11769
|
+
|
|
11744
11770
|
/**
|
|
11745
11771
|
* **omit**(obj, excluding)
|
|
11746
11772
|
*
|
|
@@ -11836,21 +11862,41 @@ declare function withKeys<TObj extends Dictionary<string | symbol, N>, N extends
|
|
|
11836
11862
|
*/
|
|
11837
11863
|
declare function withoutKeys<TObj extends NarrowObject<N>, N extends Narrowable, TKeys extends readonly (string & keyof TObj)[]>(dict: TObj, ...exclude: TKeys): WithoutKeys<TObj, [...TKeys]>;
|
|
11838
11864
|
|
|
11865
|
+
type DictionaryWithoutValueFilter<Without extends Narrowable> = <T extends Record<ObjectKey, N>, N extends Narrowable>(obj: T) => WithoutValue<T, Without>;
|
|
11839
11866
|
/**
|
|
11840
11867
|
* **withoutValue**
|
|
11841
11868
|
*
|
|
11842
|
-
*
|
|
11843
|
-
*
|
|
11869
|
+
* A _higher-order_ runtime utility which allow you to first specify a **type**
|
|
11870
|
+
* which you will want to look for in future objects/dictionaries.
|
|
11844
11871
|
*
|
|
11845
11872
|
* ```ts
|
|
11846
|
-
* const
|
|
11847
|
-
*
|
|
11848
|
-
* const onlyStrings = withoutValue(t => kind.string())(obj);
|
|
11849
|
-
* // { foo: 1 }
|
|
11850
|
-
* const justOne = withoutValue(t => kind.literal(1))(obj);
|
|
11873
|
+
* const withoutStrings = withoutValue("string");
|
|
11874
|
+
* const withoutFooBar = withoutValue("string(foo,bar)");
|
|
11851
11875
|
* ```
|
|
11876
|
+
*
|
|
11877
|
+
* The returned utility will now receive dictonary objects and -- in a type strong
|
|
11878
|
+
* manner -- removed the key/values where the value extends `string` or `"foo" | "bar"`
|
|
11879
|
+
* repectively.
|
|
11852
11880
|
*/
|
|
11853
|
-
declare function withoutValue<
|
|
11881
|
+
declare function withoutValue<TWithout extends SimpleToken>(wo: TWithout): DictionaryWithoutValueFilter<FromSimpleToken<TWithout>>;
|
|
11882
|
+
|
|
11883
|
+
type DictionaryWithValueFilter<Without extends Narrowable> = <T extends Record<ObjectKey, N>, N extends Narrowable>(obj: T) => WithValue<T, Without>;
|
|
11884
|
+
/**
|
|
11885
|
+
* **WithValue**
|
|
11886
|
+
*
|
|
11887
|
+
* A _higher-order_ runtime utility which allow you to first specify a **type**
|
|
11888
|
+
* which you will want to look for in future objects/dictionaries.
|
|
11889
|
+
*
|
|
11890
|
+
* ```ts
|
|
11891
|
+
* const withoutStrings = WithValue("string");
|
|
11892
|
+
* const withoutFooBar = WithValue("string(foo,bar)");
|
|
11893
|
+
* ```
|
|
11894
|
+
*
|
|
11895
|
+
* The returned utility will now receive dictonary objects and -- in a type strong
|
|
11896
|
+
* manner -- removed the key/values where the value extends `string` or `"foo" | "bar"`
|
|
11897
|
+
* repectively.
|
|
11898
|
+
*/
|
|
11899
|
+
declare function withValue<TWithout extends SimpleToken>(wo: TWithout): DictionaryWithValueFilter<FromSimpleToken<TWithout>>;
|
|
11854
11900
|
|
|
11855
11901
|
/**
|
|
11856
11902
|
* **createErrorConditionTemplate**`(kind,[msg],[utility]) => ErrorCondition`
|
|
@@ -13863,6 +13909,11 @@ declare function isIndexable<T>(value: T): value is T & Indexable;
|
|
|
13863
13909
|
*/
|
|
13864
13910
|
declare function isInlineSvg<T>(v: T): v is T & InlineSvg;
|
|
13865
13911
|
|
|
13912
|
+
/**
|
|
13913
|
+
* type guard which tests `val` to see if it's a valid `Set<any>`
|
|
13914
|
+
*/
|
|
13915
|
+
declare function isMap(val: unknown): val is Map<any, any>;
|
|
13916
|
+
|
|
13866
13917
|
/**
|
|
13867
13918
|
* **isNever**(val)
|
|
13868
13919
|
*
|
|
@@ -13916,10 +13967,19 @@ declare function isNumberLike<T>(value: T): value is T & NumberLike;
|
|
|
13916
13967
|
*
|
|
13917
13968
|
* Note: an _array_ will **not** pass this test (although the _typeof_ operator
|
|
13918
13969
|
* would have said it was an object)
|
|
13970
|
+
*
|
|
13971
|
+
* **Related:** `isNarrowableObject()`
|
|
13919
13972
|
*/
|
|
13920
|
-
declare function isObject
|
|
13921
|
-
|
|
13922
|
-
|
|
13973
|
+
declare function isObject(value: unknown): value is Dictionary;
|
|
13974
|
+
/**
|
|
13975
|
+
* **isObject**(value)
|
|
13976
|
+
*
|
|
13977
|
+
* Type guard used to detect whether the passed in value is an Object and all of it's
|
|
13978
|
+
* values fit into the `Narrowable` type.
|
|
13979
|
+
*
|
|
13980
|
+
* **Related:** `isObject()`
|
|
13981
|
+
*/
|
|
13982
|
+
declare function isNarrowableObject(value: unknown): value is Dictionary<ObjectKey, Narrowable>;
|
|
13923
13983
|
|
|
13924
13984
|
/**
|
|
13925
13985
|
* **isPhoneNumber**`(val)`
|
|
@@ -13977,6 +14037,20 @@ declare function isLikeRegExp(val: unknown): val is LikeRegExp;
|
|
|
13977
14037
|
*/
|
|
13978
14038
|
declare function isScalar<T>(value: T): value is T & Scalar;
|
|
13979
14039
|
|
|
14040
|
+
/**
|
|
14041
|
+
* **isSet**`(val)`
|
|
14042
|
+
*
|
|
14043
|
+
* Type guard which validates that the value passed in is **not** `Unset`.
|
|
14044
|
+
*
|
|
14045
|
+
* **Related:** `isUnset()`
|
|
14046
|
+
*/
|
|
14047
|
+
declare function isSet<T>(val: T): val is Exclude<T, Unset>;
|
|
14048
|
+
|
|
14049
|
+
/**
|
|
14050
|
+
* type guard which tests `val` to see if it's a valid `Set<any>`
|
|
14051
|
+
*/
|
|
14052
|
+
declare function isSetContainer(val: unknown): val is Set<any>;
|
|
14053
|
+
|
|
13980
14054
|
/**
|
|
13981
14055
|
* **isSpecificConstant**(kind)
|
|
13982
14056
|
*
|
|
@@ -14064,14 +14138,6 @@ declare function isUndefined(value: unknown): value is undefined;
|
|
|
14064
14138
|
* **Related:** `isSet()`
|
|
14065
14139
|
*/
|
|
14066
14140
|
declare function isUnset(val: unknown): val is Unset;
|
|
14067
|
-
/**
|
|
14068
|
-
* **isSet**`(val)`
|
|
14069
|
-
*
|
|
14070
|
-
* Type guard which validates that the value passed in is **not** `Unset`.
|
|
14071
|
-
*
|
|
14072
|
-
* **Related:** `isUnset()`
|
|
14073
|
-
*/
|
|
14074
|
-
declare function isSet<T>(val: T): val is Exclude<T, Unset>;
|
|
14075
14141
|
|
|
14076
14142
|
/**
|
|
14077
14143
|
* **isUri**`(val, ...protocols)`
|
|
@@ -14856,4 +14922,4 @@ declare function isYouTubeVideosInPlaylist<T>(val: T): val is T & YouTubeVideosI
|
|
|
14856
14922
|
*/
|
|
14857
14923
|
declare function asVueRef<T extends Narrowable>(value: T): VueRef<T>;
|
|
14858
14924
|
|
|
14859
|
-
export { type AsClassSelector, type AsList, type BoxValue, type BoxedFnParams, type CssKeyframeCallback, type CssSelectorOptions, type CsvFormat, type EndingWithTypeGuard, 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 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, endsWith, ensureLeading, ensureSurround, ensureTrailing, entries, errCondition, filter, find, fnMeta, fromDefineObject, get, getDaysBetween, getEach, getPhoneCountryCode, getTailwindModifiers, getToday, getTokenKind, getTomorrow, getTypeSubtype, getUrlPath, getUrlPort, getUrlProtocol, getUrlQueryParams, getUrlSource, getWeekNumber, getYesterday, getYouTubePageType, handleDoneFn, hasDefaultValue, hasIndexOf, hasKeys, 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, 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, isCssAspectRatio, isCurrentMetric, isCurrentUom, isCvsUrl, isDanishNewsUrl, isDate, isDefineObject, isDefined, isDellUrl, isDistanceMetric, isDistanceUom, isDomainName, isDoneFn, isDutchNewsUrl, isEbayUrl, isEmail, 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, isMapToken, isMassMetric, isMassUom, isMetric, isMexicanNewsUrl, isMoment, isNever, isNewsUrl, isNikeUrl, isNorwegianNewsUrl, isNotNull, isNothing, isNull, isNumber, isNumberLike, isNumericArray, isNumericString, isObject, isObjectToken, isOptionalParamFunction, isPhoneNumber, isPowerMetric, isPowerUom, isPressureMetric, isPressureUom, isReadonlyArray, isRecordToken, isRef, isRegExp, isRepoSource, isRepoUrl, isResistance, isResistanceUom, isRetailUrl, isSameTypeOf, isScalar, isSemanticVersion, isSet, isSetBasedKind, isSetBasedToken, 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, isUsStateAbbreviation, isUsStateName, isVoltageMetric, isVoltageUom, isVolumeMetric, isVolumeUom, 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, mergeObjects, mergeScalars, mergeTuples, nameLiteral, narrow, narrowObjectTo, narrowObjectToType, never, objectToApi, 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, 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, withoutKeys, withoutValue, wrapFn, youtubeEmbed, youtubeMeta };
|
|
14925
|
+
export { type AsClassSelector, type AsList, type BoxValue, type BoxedFnParams, type CssKeyframeCallback, type CssSelectorOptions, type CsvFormat, type DictionaryWithValueFilter, type DictionaryWithoutValueFilter, type EndingWithTypeGuard, 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 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, endsWith, ensureLeading, ensureSurround, ensureTrailing, entries, errCondition, filter, find, fnMeta, fromDefineObject, get, getDaysBetween, getEach, getPhoneCountryCode, getTailwindModifiers, getToday, getTokenKind, getTomorrow, getTypeSubtype, getUrlPath, getUrlPort, getUrlProtocol, getUrlQueryParams, getUrlSource, getWeekNumber, getYesterday, getYouTubePageType, handleDoneFn, hasDefaultValue, hasIndexOf, hasKeys, 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, 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, isCssAspectRatio, isCurrentMetric, isCurrentUom, isCvsUrl, isDanishNewsUrl, isDate, isDefineObject, isDefined, isDellUrl, isDistanceMetric, isDistanceUom, isDomainName, isDoneFn, isDutchNewsUrl, isEbayUrl, isEmail, 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, 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, isUsStateAbbreviation, isUsStateName, isVoltageMetric, isVoltageUom, isVolumeMetric, isVolumeUom, 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, 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, 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 };
|
|
@@ -2197,6 +2197,18 @@ function narrowObjectToType() {
|
|
|
2197
2197
|
);
|
|
2198
2198
|
}
|
|
2199
2199
|
|
|
2200
|
+
// src/dictionary/objectValues.ts
|
|
2201
|
+
function objectValues(obj) {
|
|
2202
|
+
const tuple3 = Object.keys(obj).reduce(
|
|
2203
|
+
(acc, key) => [
|
|
2204
|
+
...acc,
|
|
2205
|
+
obj[key]
|
|
2206
|
+
],
|
|
2207
|
+
[]
|
|
2208
|
+
);
|
|
2209
|
+
return tuple3;
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2200
2212
|
// src/dictionary/omit.ts
|
|
2201
2213
|
function omit(obj, ...removeKeys) {
|
|
2202
2214
|
const keys = Object.keys(obj);
|
|
@@ -2263,13 +2275,115 @@ function withoutKeys(dict, ...exclude) {
|
|
|
2263
2275
|
return omit(dict, ...exclude);
|
|
2264
2276
|
}
|
|
2265
2277
|
|
|
2278
|
+
// src/runtime-types/doesExtend.ts
|
|
2279
|
+
function doesExtend(type) {
|
|
2280
|
+
return (val) => {
|
|
2281
|
+
let response = false;
|
|
2282
|
+
if (isString(val)) {
|
|
2283
|
+
if (type === "string") {
|
|
2284
|
+
response = true;
|
|
2285
|
+
}
|
|
2286
|
+
if (type.startsWith("string(")) {
|
|
2287
|
+
const literals = stripAfter(
|
|
2288
|
+
stripBefore(type, "string("),
|
|
2289
|
+
")"
|
|
2290
|
+
).split(/,\s*/);
|
|
2291
|
+
if (literals.includes(val)) {
|
|
2292
|
+
response = true;
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
if (isNumber(val)) {
|
|
2297
|
+
if (type === "number") {
|
|
2298
|
+
response = true;
|
|
2299
|
+
}
|
|
2300
|
+
if (type.startsWith("number(")) {
|
|
2301
|
+
const literals = stripAfter(
|
|
2302
|
+
stripBefore(type, "number("),
|
|
2303
|
+
")"
|
|
2304
|
+
).split(/,\s*/).map(Number);
|
|
2305
|
+
if (literals.includes(val)) {
|
|
2306
|
+
response = true;
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
if (isNull(val) && (type === "null" || type === "Opt<null>")) {
|
|
2311
|
+
response = true;
|
|
2312
|
+
}
|
|
2313
|
+
if (isUndefined(val) && (type === "undefined" || type.startsWith("Opt<"))) {
|
|
2314
|
+
response = true;
|
|
2315
|
+
}
|
|
2316
|
+
if (isBoolean(val)) {
|
|
2317
|
+
if (type === "boolean") {
|
|
2318
|
+
response = true;
|
|
2319
|
+
}
|
|
2320
|
+
if (type === "true" && val === true || type === "false" && val === false) {
|
|
2321
|
+
response = true;
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
if (isNarrowableObject(val)) {
|
|
2325
|
+
if (type === "Dict" || type === "Dict<string, unknown>") {
|
|
2326
|
+
response = true;
|
|
2327
|
+
}
|
|
2328
|
+
if (startsWith("Dict<")(type)) {
|
|
2329
|
+
const match = infer("Dict<{{infer key}}, {{infer value}}>")(type);
|
|
2330
|
+
if (match) {
|
|
2331
|
+
const { value } = match;
|
|
2332
|
+
const isOpt = value.includes(`Opt<`);
|
|
2333
|
+
const values = objectValues(val);
|
|
2334
|
+
if (values.every((i) => isOpt ? isString(i) || isUndefined(i) : isString(i)) && type === "Dict<string, string>" || values.every((i) => isOpt ? isUndefined(i) || isNumber(i) : isNumber(i)) && type === "Dict<string, number>" || values.every((i) => isOpt ? isUndefined(i) || isBoolean(i) : isBoolean(i)) && type === "Dict<string, boolean>") {
|
|
2335
|
+
response = true;
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
if (isArray(val)) {
|
|
2341
|
+
if (type === "Array" || type === "Array<unknown>") {
|
|
2342
|
+
return true;
|
|
2343
|
+
}
|
|
2344
|
+
if (type === "Array<Dict>" && val.every(isObject) || type === "Array<boolean>" && val.every(isBoolean) || type === "Array<string>" && val.every(isString) || type === "Array<number>" && val.every(isNumber) || type === "Array<Map>" && val.every(isMap) || type === "Array<Set>" && val.every(isSetContainer)) {
|
|
2345
|
+
response = true;
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
if (isMap(val)) {
|
|
2349
|
+
if (type === "Map" || type === "Map<Dict, Array>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isArray) || type === "Map<Dict, Dict>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isObject) || type === "Map<Dict, boolean>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isBoolean) || type === "Map<Dict, number>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isNumber) || type === "Map<Dict, string>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isString) || type === "Map<Dict, unknown>" && Array.from(val.keys()).every(isObject) || type === "Map<string, string>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isString) || type === "Map<string, number>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isNumber) || type === "Map<string, boolean>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isBoolean) || type === "Map<string, unknown>" && Array.from(val.keys()).every(isString) || type === "Map<number, string>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isString) || type === "Map<number, number>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isNumber) || type === "Map<number, boolean>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isBoolean) || type === "Map<number, unknown>" && Array.from(val.keys()).every(isNumber)) {
|
|
2350
|
+
response = true;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
if (isSetContainer(val)) {
|
|
2354
|
+
if (type === "Set" || type === "Set<unknown>" || type === "Set<boolean>" && Array.from(val).every(isBoolean) || type === "Set<string>" && Array.from(val).every(isString) || type === "Set<number>" && Array.from(val).every(isNumber) || type === "Set<Opt<boolean>>" && Array.from(val).every((i) => isBoolean(i) || isUndefined(i)) || type === "Set<Opt<string>>" && Array.from(val).every((i) => isString(i) || isUndefined(i)) || type === "Set<Opt<number>>" && Array.from(val).every((i) => isNumber(i) || isUndefined(i))) {
|
|
2355
|
+
response = true;
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
return response;
|
|
2359
|
+
};
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2266
2362
|
// src/dictionary/withoutValue.ts
|
|
2267
|
-
function withoutValue(
|
|
2363
|
+
function withoutValue(wo) {
|
|
2268
2364
|
return (obj) => {
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2365
|
+
const output = {};
|
|
2366
|
+
for (const key of keysOf(obj)) {
|
|
2367
|
+
const val = obj[key];
|
|
2368
|
+
if (!doesExtend(wo)(val)) {
|
|
2369
|
+
output[key] = val;
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
return output;
|
|
2373
|
+
};
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
// src/dictionary/withValue.ts
|
|
2377
|
+
function withValue(wo) {
|
|
2378
|
+
return (obj) => {
|
|
2379
|
+
const output = {};
|
|
2380
|
+
for (const key of keysOf(obj)) {
|
|
2381
|
+
const val = obj[key];
|
|
2382
|
+
if (doesExtend(wo)(val)) {
|
|
2383
|
+
output[key] = val;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
return output;
|
|
2273
2387
|
};
|
|
2274
2388
|
}
|
|
2275
2389
|
|
|
@@ -2544,6 +2658,9 @@ function isFunction(value) {
|
|
|
2544
2658
|
function isObject(value) {
|
|
2545
2659
|
return typeof value === "object" && value !== null && Array.isArray(value) === false;
|
|
2546
2660
|
}
|
|
2661
|
+
function isNarrowableObject(value) {
|
|
2662
|
+
return isObject(value) && Object.keys(value).every((key) => ["string", "number", "boolean", "symbol", "object", "undefined", "void", "null"].includes(typeof value[key]));
|
|
2663
|
+
}
|
|
2547
2664
|
|
|
2548
2665
|
// src/type-guards/api-tg.ts
|
|
2549
2666
|
function isEscapeFunction(val) {
|
|
@@ -3241,6 +3358,11 @@ function isInlineSvg(v) {
|
|
|
3241
3358
|
return isString(v) && v.trim().startsWith(`<svg`) && v.trim().endsWith(`</svg>`);
|
|
3242
3359
|
}
|
|
3243
3360
|
|
|
3361
|
+
// src/type-guards/isMap.ts
|
|
3362
|
+
function isMap(val) {
|
|
3363
|
+
return val instanceof Map;
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3244
3366
|
// src/type-guards/isNever.ts
|
|
3245
3367
|
function isNever(val) {
|
|
3246
3368
|
return isConstant(val) && val.kind === "never";
|
|
@@ -3303,6 +3425,16 @@ function isLikeRegExp(val) {
|
|
|
3303
3425
|
return false;
|
|
3304
3426
|
}
|
|
3305
3427
|
|
|
3428
|
+
// src/type-guards/isSet.ts
|
|
3429
|
+
function isSet(val) {
|
|
3430
|
+
return isObject(val) ? val.kind !== "Unset" : true;
|
|
3431
|
+
}
|
|
3432
|
+
|
|
3433
|
+
// src/type-guards/isSetContainer.ts
|
|
3434
|
+
function isSetContainer(val) {
|
|
3435
|
+
return val instanceof Set;
|
|
3436
|
+
}
|
|
3437
|
+
|
|
3306
3438
|
// src/type-guards/isStringArray.ts
|
|
3307
3439
|
function isStringArray(val) {
|
|
3308
3440
|
return Array.isArray(val) && val.every((i) => isString(i));
|
|
@@ -3342,9 +3474,6 @@ function isTypeTuple(value) {
|
|
|
3342
3474
|
function isUnset(val) {
|
|
3343
3475
|
return isObject(val) && val.kind === "Unset";
|
|
3344
3476
|
}
|
|
3345
|
-
function isSet(val) {
|
|
3346
|
-
return isObject(val) ? val.kind !== "Unset" : true;
|
|
3347
|
-
}
|
|
3348
3477
|
|
|
3349
3478
|
// src/type-guards/isUrl.ts
|
|
3350
3479
|
function isUri(val, ...protocols) {
|
|
@@ -5158,12 +5287,14 @@ export {
|
|
|
5158
5287
|
isLuminosityUom,
|
|
5159
5288
|
isLuxonDateTime,
|
|
5160
5289
|
isMacysUrl,
|
|
5290
|
+
isMap,
|
|
5161
5291
|
isMapToken,
|
|
5162
5292
|
isMassMetric,
|
|
5163
5293
|
isMassUom,
|
|
5164
5294
|
isMetric,
|
|
5165
5295
|
isMexicanNewsUrl,
|
|
5166
5296
|
isMoment,
|
|
5297
|
+
isNarrowableObject,
|
|
5167
5298
|
isNever,
|
|
5168
5299
|
isNewsUrl,
|
|
5169
5300
|
isNikeUrl,
|
|
@@ -5198,6 +5329,7 @@ export {
|
|
|
5198
5329
|
isSet,
|
|
5199
5330
|
isSetBasedKind,
|
|
5200
5331
|
isSetBasedToken,
|
|
5332
|
+
isSetContainer,
|
|
5201
5333
|
isSetToken,
|
|
5202
5334
|
isShape,
|
|
5203
5335
|
isShapeCallback,
|
|
@@ -5307,6 +5439,7 @@ export {
|
|
|
5307
5439
|
narrowObjectToType,
|
|
5308
5440
|
never,
|
|
5309
5441
|
objectToApi,
|
|
5442
|
+
objectValues,
|
|
5310
5443
|
omit,
|
|
5311
5444
|
optional,
|
|
5312
5445
|
optionalOrNull,
|
|
@@ -5383,6 +5516,7 @@ export {
|
|
|
5383
5516
|
widen,
|
|
5384
5517
|
withDefaults,
|
|
5385
5518
|
withKeys,
|
|
5519
|
+
withValue,
|
|
5386
5520
|
withoutKeys,
|
|
5387
5521
|
withoutValue,
|
|
5388
5522
|
wrapFn,
|