TObject Class
The TObject
class provides utility methods for handling objects, including merging, key operations, freezing, unfreezing, and filtering.
Usage
Using the object
from the t
Object
Creating an Instance
Methods
Merge
merge<T extends object, U extends object>(a: T, b: U): Prettify<T & U>
Merges two objects.
Note: This method does not mutate the original objects. And will overwrite the values of the first object with the values of the second object if they have the same keys.
Example:
Keys
keys<T extends object>(a: T): (keyof T)[]
Gets the keys of an object.
Example:
Freeze
freeze<T extends object>(a: T): Readonly<T>
Freezes an object.
Example:
Unfreeze
unfreeze<T extends object>(a: Readonly<T>): T
Unfreezes a frozen object.
Example:
Filter
filter<T extends object>(a: T, fn: (key: keyof T, value: T[keyof T]) => boolean): Prettify<Partial<T>>
Filters an object by key and value.
Example:
Select
select<T extends object, U extends keyof T>(a: T, b: U[]): Prettify<Pick<T, U>>
Selects keys from an object.
Example:
Exclude
exclude<T extends object, U extends keyof T>(a: T, b: U[]): Prettify<Omit<T, U>>
Excludes keys from an object.
Example: