2.1.1 âĸ Published 2 years ago
@cuppachino/type-space v2.1.1
đĻ Installation
Use your favorite package manager to install @cuppachino/type-space as a developer dependency.
pnpm add -D @cuppachino/type-spacenpm install --save-dev @cuppachino/type-spaceđ Quick Reference
The source code is fully tsdoc'd, so you can use your IDE's intellisense to reference examples and descriptions at any time. Click any type for more documentation.
đ Base Types
NumberLiteral: A stringified number literal.Stringifiable: An alias forstring | number | bigint | boolean | null | undefined.UnknownArray: An alias forunknown[] | readonly unknown[], safer thanany.UnknownRecord: An alias forRecord<PropertyKey, unknown>, safer thananyor{}.
đ§Ž Arithmetic Types
Absolute: Coerces a number literal to a positivenumberof the same magnitude.Add: Return the sum of two number literals.Subtract: Return the difference between two number literals.
đĸ Numeric Types
IntoNumber: Coerce aNumberLiketype to anumberIntoNumberLiteral: Coerce aNumberLiketype to aNumberLiteralIsInteger: A boolean type that is true if a number literal is an integer.IsPositive: A boolean type that is true if a number literal is positive.IsNegative: A boolean type that is true if a number literal is negative.IsWhole: A boolean type that is true if a number literal is a whole number.NumberLike: Coerce either anumberor aNumberLiteralinto a union between the two.ParseNumberLiteral: Coerce aNumberLiteraltype to anumber
đ String Types
Chars: Splits a string literal into a tuple of characters. Reads more clearly thanSplitin some cases.ReverseString: Reverse a string literal.Split: Splits a string literal into a tuple of characters, separated by the given delimiter.SplitAt: Split a string literal into a tuple of two strings, separated by the given index, non-inclusive.Stringify: Converts a type to a string literal type, if possible.StringIncludes: A boolean type that is true if a string literal includes a given substring (â).StringIncludesProper: A boolean type that is true if a string literal includes a given substring, and the substring is not the entire string (â).
đ Tuple Types
CreateTuple: Generate a fixed-length tuple.Flat: Recursively flatten a tuple up to a given depth.IndexOf: Return a union of a tuple's indices.Indices: Generate a tuple of a tuple's indices.Join: Joins a tuple of strings into a single string, separated by a delimiter.Length: Extract the length property from an array or tuple.MergeAll: Merge all type members of a tuple into a single type.PartitionKeys: Extract a union of keys for each member in a tuple into a new tuple; order is preserved.PartitionValues: Create a tuple of value(s) for the given key(s) in each member of a tuple; order is preserved.PartitionPick: Maps picked properties from each member of a tuple into a new tuple; order is preserved.Reverse: Reverse the order of elements in a tuple type.
A la Array.prototype
sig
Action :: <Tuple> -> NewTuple
Pop: Remove the last element from a tuple. Does not return the removed element.PopBy: Remove the lastNelements from a tuple.Push: Adds one element type to the end of a tuple. Does not return the new length of the tuple.Shift: Remove the first element from a tuple type. Does not return the removed element.ShiftBy: Remove the firstNelements from a tuple.Unshift: Adds one element type to the beginning of a tuple. Does not return the new length of the tuple.
đ§° Utility Types
Assert: Assert that a type is assignable to another type; shorthand forT extends U ? T : never.Combine: Simplify a type by mapping over its properties.KeyOf: Extract all keys from every member of a union type, unlikekeyofwhich only preserves shared members' keys.Mutable: Recursively removes thereadonlymodifier from all properties of a type.PartialSome: Return a new type that allows the specified keys to be undefined.PickAll: Extract properties from all members in a union, missing properties default to| undefined.RequireSome: Return a new type requiring the selected keys.Simplify: Simplify a type by mapping over its inferred properties - use whenCombinecannot infer a deep type.Subset: TypeScript equivalent ofâ.UnionLiteral: Create a union from a literal and primitive type without losing the literal type.UnionToIntersection: Create an intersection from all members of a union type.UnionToTuple: Convert a union to a tuple type. The order is not guaranteed.Zip: From a tuple of keys and a tuple of values, create a new record.
Extract
ExtractRequired: Extract all non-optional properties from a type; âšī¸exactOptionalPropertyTypes.ExtractOptional: Extract all optional properties from a type; âšī¸exactOptionalPropertyTypesExtractFunctions: Create a new type of all property functions and methods in a type.ExtractSetMembers: Create a union type of members in aSet.
Extends
| sig
Extends :: <T, R = T> -> boolean
Tis the type to check.Ris the type returned whenTextends the name of the generic.
ExtendsFunction: Return a type if the given type extends a function or method.
I hope you have fun with these utilities. Thank you for using type-space!
2.1.1
2 years ago
2.1.0
2 years ago
2.0.1
2 years ago
1.15.0
3 years ago
1.14.1
3 years ago
1.13.2
3 years ago
1.14.0
3 years ago
1.13.1
3 years ago
1.17.1
3 years ago
1.17.0
3 years ago
1.16.0
3 years ago
1.15.1
3 years ago
2.0.0
3 years ago
1.12.2
3 years ago
1.13.0
3 years ago
1.12.1
3 years ago
1.12.0
3 years ago
1.9.1
3 years ago
1.6.0
3 years ago
1.5.1
3 years ago
1.8.3
3 years ago
1.11.0
3 years ago
1.10.1
3 years ago
1.10.0
3 years ago
1.4.0
3 years ago
1.3.0
3 years ago
1.2.4
3 years ago
1.2.3
3 years ago
1.2.1
3 years ago
1.2.0
3 years ago
1.1.4
3 years ago
1.1.3
3 years ago
1.1.2
3 years ago
1.1.1
3 years ago
1.1.0
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago