Open JacobWeisenburger opened 1 year ago
the problem seems to be with set
.
console.log( set( {}, 'name.first', null ) )
// {}, but expected { name: { first: null } }
I've fixed this for my use case using lodash. But I would really like to be able to use this with only radash. So it would be nice if this was fixed in the future.
export const construct = <TObject extends object> ( obj: TObject ): object => {
if ( !obj ) return {}
return Object.keys( obj ).reduce( ( acc, path ) => {
/* uses lodash.set instead of radash.set */
return lodash.set( acc, path, ( obj as any )[ path ] )
}, {} )
}
Hi @JacobWeisenburger, this is fixed in the Radashi fork, along with many other things. Check us out!
https://radash-docs.vercel.app/docs/object/construct this is not documented and I don't understand why this is needed. I would like to be able to construct objects without removing falsy values.