@terminus/ngx-tools
Version:
[![CircleCI][circle-badge]][circle-link] [![codecov][codecov-badge]][codecov-project] [![semantic-release][semantic-release-badge]][semantic-release] [![MIT License][license-image]][license-url] <br> [![NPM version][npm-version-image]][npm-url] [![Github
23 lines (22 loc) • 682 B
TypeScript
/**
* Helper function to return an array of values from an hash object
*
* @param keys - The array containing the key values (number|string) to retrieve from the hash
* @param hash - The object to pull values from
* @returns The array of values that match keys
*
* @example
* const tactic1: MyType = {
* id: 1,
* name: 'tactic1',
* goal: 'goal1',
* }
* const tactic2: MyType = {
* id: 2,
* name: 'tactic2',
* goal: 'goal2',
* }
* const tactics = { 1: tactic1, 2: tactic2 }
* returnValuesByKeys<MyType>([1], tactics) // Returns: `[tactic1]`
*/
export declare function returnValuesByKeys<T>(keys: Array<string | number>, hash: Record<string, T>): T[];