UNPKG

@augment-vir/common

Version:

A collection of augments, helpers types, functions, and classes for any JavaScript environment.

49 lines (48 loc) 1.46 kB
import { type AnyObject } from '@augment-vir/core'; import { type SelectFrom, type SelectionSet } from './selection-set.js'; /** * Determine if the given input should be preserved in the selection output, meaning it won't be * recursed into. * * @ignore */ export declare function shouldPreserveInSelectionSet(input: unknown): boolean; /** * Performs a SQL-like nested selection on an object, extracting the selected values. * * @category Selection * @category Package : @augment-vir/common * @example * * ```ts * import {selectFrom} from '@augment-vir/common'; * * selectFrom( * [ * { * child: { * grandChild: 'hi', * grandChild2: 3, * grandChild3: /something/, * }, * }, * { * child: { * grandChild: 'hi', * grandChild2: 4, * grandChild3: /something/, * }, * }, * ], * { * child: { * grandChild2: true, * }, * }, * ); * // output is `[{child: {grandChild2: 3}}, {child: {grandChild2: 4}}]` * ``` * * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export declare function selectFrom<Full extends AnyObject, const Selection extends SelectionSet<NoInfer<Full>>>(originalObject: Readonly<Full>, selectionSet: Readonly<Selection>): SelectFrom<Full, Selection>;