UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

34 lines (33 loc) 923 B
/** * This method is like `clone` except that it accepts `customizer` which * is invoked to produce the cloned value. If `customizer` returns `undefined`, * cloning is handled by the method instead. The `customizer` is invoked with * one argument (value). * * @since 5.3.0 * @category Lang * @param {*} value The value to clone. * @param {Function} [customizer] The function to customize cloning. * @returns {*} Returns the cloned value. * @see cloneDeepWith * @example * * ```js * function customizer(value) { * if (isElement(value)) { * return value.cloneNode(false) * } * } * * const el = cloneWith(document.body, customizer) * * console.log(el === document.body) * // => false * console.log(el.nodeName) * // => 'BODY' * console.log(el.childNodes.length) * // => 0 * ``` */ declare function cloneWith(value: any, customizer: (...any: any[]) => any): any; export default cloneWith;