/** * A mapping rule used to extract a single value from a source object. * * - a string with the name of a source property, or the dot-notation path of a * nested source property * - a {@link PropertyMapRule} object with a property name or path, and optional * transformation rules * - a function that accepts the object and returns a property value or `undefined` */ export type PropertyMap = string | PropertyMapRule | ((input: T) => unknown); /** * Describes the location of a piece of data on a source object. */ export interface PropertyMapRule extends Record { /** * The name of the property to be checked; this can be a simple property name, * or the dot-delimited path to a nested property. */ source: string; /** * If the source property is found, and its value is a string, parse it as an HTML * fragment and return the inner text. */ selector?: string; /** * If a selector is used, return the number of matches rather than the content. */ count?: boolean; /** * If a selector is used, return the value of an attribute rather than the element text. */ attribute?: string; /** * If the property value is found and is an array, limit the number of results * to this number. * * @defaultValue: undefined */ limit?: number; /** * If the property value is found and is an array, collapse it to a string * using the specified delimiter. If `join` is undefined or false, array * will remain arrays. * * @defaultValue: undefined */ join?: string; /** * If the property value is found and is a string, split it into an array using this * character or regular expression. * * @defaultValue: undefined */ split?: string | RegExp; /** * If the property is not found, or the selector returns empty results, return this value * as a fallback. * * Note: If a PropertyMap with a default value is placed in the middle of an array of * PropertyMaps, its default value will be returned and all subsequent PropertyMap * will be ignored. */ fallback?: unknown; /** * If set, this value will be returned in place of the found value. * * This can be useful when you're *looking for* a messy value in one property * and want to set a clean flag or value in another property depending on the * ugly one. * * If the `value` property contains a function, that function will be called to * generate the return value. */ value?: string | number | boolean | ((value: unknown, conditions: PropertyMapRule) => unknown | undefined); /** * Only return the value if it's equal to this. */ eq?: unknown; /** * Only return the value if it's less than this. */ lt?: string | number; /** * Only return the value if it's greater than this. */ gt?: string | number; /** * Only return the value if it is contained in this. If the value is an array, * only return array values that are contained in this. */ in?: unknown[] | string; /** * Only return the value if it is a string that matches this. If it is an array, * only return values of the array that match this. */ matching?: string; /** * Only return the value if it contains this. */ contains?: unknown; /** * Treat null values as values, rather than undefined. */ acceptNull?: true; /** * Treat empty strings and arrays as values, rather than undefined. */ acceptEmpty?: true; /** * Negate any conditions. */ negate?: true; } export declare function mapProperties(obj: T, map: Record): T; /** * Find a single value on an object using one or more {@link PropertyMap} * descriptions. * * If an array is given, the individual {@link PropertyMap} records will be * checked in order; the first one to produce a value will be used. If none * produce a value, the `fallback` parameter will be returned. */ export declare function findPropertyValue(object: T, locations: PropertyMap | PropertyMap[], domDictionary?: Record): unknown | undefined; //# sourceMappingURL=map-properties.d.ts.map