UNPKG

@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

37 lines (36 loc) 923 B
/** * @description * Accepts an object of type T and single key or array of keys (K extends keyof T). * Constructs new object based on provided keys. * * @example * * const cat = {id: 1, type: 'cat', name: 'Fluffy'}; * * const catWithoutType = slice(cat, ['name', 'id']); * * // catWithoutType will be: * // {id: 1, name: 'Fluffy'}; * * @example * // Usage with RxState * * export class AnimalsListComponent { * * constructor(private state: RxState<ComponentState>, private api: ApiService) { * state.connect( * 'animals' * this.api.getAnimals(), * (state, animals) => { * return animals.map(animal => slice(animal, ['id', 'name'])); * } * ); * } * } * * @returns T * * @docsPage slice * @docsCategory transformation-helpers */ export declare function slice<T extends object, K extends keyof T>(object: T, keys: K | K[]): Pick<T, K>;