CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
assignWithDepth.d.ts31 linesDownload Raw Back to dist
1/**2 * assignWithDepth Extends the functionality of {@link Object.assign} with the3 *   ability to merge arbitrary-depth objects For each key in src with path `k` (recursively)4 *   performs an Object.assign(dst[`k`], src[`k`]) with a slight change from the typical handling of5 *   undefined for dst[`k`]: instead of raising an error, dst[`k`] is auto-initialized to `{}` and6 *   effectively merged with src[`k`]<p> Additionally, dissimilar types will not clobber unless the7 *   config.clobber parameter === true. Example:8 *9 * ```10 * const config_0 = { foo: { bar: 'bar' }, bar: 'foo' };11 * const config_1 = { foo: 'foo', bar: 'bar' };12 * const result = assignWithDepth(config_0, config_1);13 * console.log(result);14 * //-> result: { foo: { bar: 'bar' }, bar: 'bar' }15 * ```16 *17 *   Traditional Object.assign would have clobbered foo in config_0 with foo in config_1. If src is a18 *   destructured array of objects and dst is not an array, assignWithDepth will apply each element19 *   of src to dst in order.20 * @param dst - The destination of the merge21 * @param src - The source object(s) to merge into destination22 * @param config -23 * * depth: depth to traverse within src and dst for merging24 * * clobber: should dissimilar types clobber25 */26declare const assignWithDepth: (dst: any, src: any, { depth, clobber }?: {27    depth?: number;28    clobber?: boolean;29}) => any;30export default assignWithDepth;31 
basant307/AI_Governance_Project · CoolFace