This library is still in development, some features may not work as expected and be subject to change.
View the code examples on playground
(These will also be listed directly on this README as text in the future)
This function is a wrapper for Object.entries(), providing additional type information and no extra implementation
Parameters:
- object (
O
) - The object to get the entries of
returns: [key: string, value: unknown][]
Assigns all keys of source objects that do not have their value set to undefined to the target object
It does not return the target object, but instead asserts its type. To create a new object, use optel.mergeDefined()
.
Parameters:
- target (
T
) - The object to assign to - sources (
AssertDefinedAssignableTo<T, S>
) - The objects to get assigned values from
returns: void
Creates a new object with all of its keys assigned to their respective values from the source objects, only being
assigned if that value is not undefined.
This function creates a new object and returns it, not modifying any of the source objects.
To modify an existing target object instead, use optel.assignDefined()
.
Parameters:
- sources (
AssertDefinedAssignableTo<{}, S>
) - The objects to get assigned values from
returns: ReduceImpl<S, {}, HOTDefinedAssign>
This function is a wrapper for Object.assign(), providing additional type information and no extra implementation.
It does not return the target object, but instead asserts its type. To create a new object, use optel.merge()
.
Parameters:
- target (
T
) - The object to assign to - sources (
AssertAssignableTo<T, S>
) - The objects to get assigned values from
returns: void
This function is a wrapper for Object.assign(), providing additional type information and no extra implementation.
This function creates a new object and returns it, not modifying any of the source objects.
To modify an existing target object instead, use optel.assign()
.
Parameters:
- sources (
AssertAssignableTo<{}, S>
) - The objects to get assigned values from
returns: ReduceImpl<S, {}, HOTAssign>
Creates a copy of the given object with only the specified keys included
Parameters:
- object (
O
) - The object to pick keys from - keys (
K
) - The keys to be picked and included on the new object
returns: OptelPick<O, K>
Creates a copy of the given object with the specified keys removed
Parameters:
- object (
O
) - The object to pick keys from - keys (
K
) - The keys to be picked and included on the new object
returns: OptelOmit<O, K>
This function returns the first key (as given by Object.entries()) that contains the given value
Parameters:
- object (
O
) - The object to search for the value within - value (
V
) - The value to search for
returns: OptelKeyOf<O, V>
This function returns an array of keys that contain the given value
Parameters:
- object (
O
) - The object to search for the value within - value (
V
) - The value to search for
returns: OptelKeyOf<O, V>[]
Returns this object, but with its type changed to allow for any key to be used to index it, with its value set to unknown. This function does nothing else except return the same object passed to it with additional type information.
Parameters:
- object (
O
) - The object to unlock
returns: OptelUnlocked
This function is a wrapper for Object.fromEntries(), providing additional type information and no extra implementation.
Parameters:
- sources - The entries to create an object from
- entries (
T
)
returns: OptelFromEntries