@adyen/kyc-components
Version:
This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.
53 lines (51 loc) • 1.85 kB
TypeScript
import type { MappingRecord } from '../mapping/mappingRecord';
/**
* returns the indicated property of an object, if it exists.
*
* @param object - The object to query
* @param path - The property name or path to the property
* @returns The value at `obj[p]`.
* @example
* ```
* getProp({x: 100}, 'x'); //=> 100
* getProp({}, 'x'); //=> undefined
* ```
*/
export declare function getProp(object: Record<string, any>, path: string): any;
/**
* assigns the value provided to the key in targetObject.
* @param path - keys separated by a delimiter.
* @param obj - object to which value will be assigned
* @param val - value to be assigned
*
* @example
* ```
* targetObject = {};
* assignToProp('x.y.z', targetObject, 'foo');
* console.log(targetObject); => {x:{y:{z:'foo'}}}
* ```
*/
export declare function assignToProp(path: string, obj: Record<string, any>, val: any): void;
export declare function deleteProp(path: string, obj: Record<string, any>): void;
/**
* @param obj - source object
* @param mapping - key mappings from source to target object structure
* @example
* ```
* let mapping={ 'a.b': 'x.y.z'}
* let obj = {x: {y: {z: 'foo'}}}
* formatObject(obj, mapping) => {a:{b:'foo'}}
* ```
*/
export declare const formatObject: <Source extends Record<string, any>, Target extends Record<string, any>>(obj: Source, mapping: Partial<MappingRecord<Target, Source>>) => Target;
/**
* @param obj - source object
* @param mapping - key mappings from target to source object structure
* @example
* ```
* let mapping={ 'a.b': 'x.y.z'}
* let obj = {x: {y: {z: 'foo'}}}
* formatObject(obj, mapping) => {a:{b:'foo'}}
* ```
*/
export declare const mapWith: <Source extends Record<string, any>, Target extends Record<string, any>>(obj: Source, mapping: MappingRecord<Source, Target>) => Target;