object-set-all-values-to
Version:
Recursively walk the input and set all found values in plain objects to something
11 lines (9 loc) • 660 B
JavaScript
/**
* @name object-set-all-values-to
* @fileoverview Recursively walk the input and set all found values in plain objects to something
* @version 6.1.0
* @author Roy Revelt
* @license MIT
* {@link https://codsen.com/os/object-set-all-values-to/}
*/
import u from"rfdc";import{isPlainObject as o}from"codsen-utils";var i="6.1.0";var l=u(),j=i;function p(c,r){let t,e=l(c);return arguments.length<2?t=!1:o(r)||Array.isArray(r)?t=l(r):t=r,Array.isArray(e)?e.forEach((s,n)=>{(o(e[n])||Array.isArray(e[n]))&&(e[n]=p(e[n],t))}):o(e)&&Object.keys(e).forEach(s=>{Array.isArray(e[s])||o(e[s])?e[s]=p(e[s],t):e[s]=t}),e}export{p as setAllValuesTo,j as version};