mol_type_all
v0.0.1848
Published
Collection of TypeScript meta types for complex logic.
Downloads
8,805
Maintainers
Keywords
Readme
$mol_type
Collection of TypeScript meta types for complex logic.
Usage
MAM
type cutted_head = $mol_type_assert<
$mol_type_tail<[ 1, 2, 3 ]>,
[ 2, 3 ]
>NPM
npm install mol_type_allimport {
$mol_type_assert as Assert,
$mol_type_tail as Tail,
} from 'mol_type_all'
type cutted_head = Assert<
Tail<[ 1, 2, 3 ]>,
[ 2, 3 ]
>Utilites
Assertions
- $mol_type_error - special type for errors with details.
- $mol_type_assert - fails type check on type inequality.
- $mol_type_enforce - fails type check on type incompatibility.
// Actual result
type partial_record = $mol_type_assert<
Partial<{ foo: 123 }>, // Some expression
{ foo?: 123 } // Expected result
>
Tuples
- $mol_type_head - first item of tuple or never.
- $mol_type_head_write - replaces first element of tuple.
- $mol_type_tail - tuple without first item.
- $mol_type_foot - last item of tuple or never.
- $mol_type_reverse - makes reversed tuple.
Algebraics
- $mol_type_equals - check for types equality.
- $mol_type_access - takes type of property from wild union type.
- $mol_type_filter_keys - records from union with provided property.
- $mol_type_intersect - converts union to intersection.
- $mol_type_merge - merges intersection of records to one record.
- $mol_type_keys_all - all keys from all records from union.
Strings
- $mol_type_alphabet_* - character classes.
- $mol_type_string_split - splits string by separator.
- $mol_type_string_join - joins strings by separator.
Numbers
- $mol_type_int_* - integer arithmetic (
+,-,*,/,^,..,(),<)
Functions
- $mol_type_unary - function/class with single param.
- $mol_type_param - takes param type by index.
- $mol_type_result - takes result/instance type.
Records
$mol_type_immutable_deep - recursive immutability.
$mol_type_mutable_deep - recursive mutability.
$mol_type_partial_undefined - makes all properties partial.
$mol_type_partial_deep - makes all properties partial deeply.
$mol_type_required_deep - makes all properties required deeply.
$mol_type_nullable - makes all properties nullable.
$mol_type_writable - makes all properties writable.
$mol_type_keys_extract - extracts key names from record by value type.
$mol_type_keys_exclude - excludes key names from record by value type.
$mol_type_omit - omits properties by value type.
$mol_type_pick - pick properties by value type.
$mol_type_override - fully replaces properties.
$mol_type_case_* - converts keys/values to upper/lower/capital cases.
$mol_type_flat_camel - makes flat record from volume records tree.
$mol_type_flat_keys - takes keys paths from volume records tree.
$mol_type_volume - makes volume records tree from flat record.
$mol_type_volume_value - takes value from volume records tree by path.
Similar Projects
piotrwitek/utility-types- Collection of utility types, complementing TypeScript built-in mapped types and aliases (think "lodash" for static types).pirix-gh/ts-toolbelt- All the types you need for TypeScript.ksxnodemodules/typescript-tuple- Generics to work with tuples in TypeScript
