@rx-angular/cdk
Version:
@rx-angular/cdk is a Component Development Kit for ergonomic and highly performant angular applications. It helps to to build Large scale applications, UI libs, state management, rendering systems and much more. Furthermore the unique way of mixing reacti
46 lines (45 loc) • 1.18 kB
TypeScript
/**
* @description
* Accepts an object of type T and key of type K extends keyof T.
* Removes property from an object and returns a shallow copy of the updated object without specified property.
* If property not found returns copy of the original object.
* Not mutating original object.
*
* @example
*
* const cat = {id: 1, type: 'cat', name: 'Fluffy'};
*
* const anonymusCat = deleteProp(cat, 'name');
*
* // anonymusCat will be:
* // {id: 1, type: 'cat'};
*
* @example
* // Usage with RxState
*
* export class ProfileComponent {
*
* readonly removeName$ = new Subject();
*
* constructor(private state: RxState<ComponentState>) {
* // Reactive implementation
* state.connect(
* this.removeName$,
* (state) => {
* return deleteProp(state, 'name');
* }
* );
* }
*
* // Imperative implementation
* removeName(): void {
* this.state.set(remove(this.get(), 'name'));
* }
* }
*
* @returns Omit<T, K>
*
* @docsPage deleteProp
* @docsCategory transformation-helpers
*/
export declare function deleteProp<T extends object, K extends keyof T>(object: T, key: K): Omit<T, K>;