UNPKG

nhb-toolbox

Version:

A versatile collection of smart, efficient, and reusable utility functions and classes for everyday development needs.

21 lines (20 loc) 441 B
/** * * Deep clone an object. * * @param obj Object to clone. * @returns Deep cloned object. */ export const cloneObject = (obj) => { return JSON.parse(JSON.stringify(obj)); }; /** * * Count the number of fields in an object. * * @param obj Object to check. * @returns Number of fields in the object. */ export const countObjectFields = (obj) => { if (obj != null) return Object.keys(obj)?.length; return 0; };