@hitachivantara/uikit-react-core
Version:
UI Kit Core React components.
21 lines (20 loc) • 733 B
JavaScript
//#region src/utils/helpers.ts
var uniqueId = (prefix = "") => {
return `${prefix}${Math.random().toString(36).slice(2, 9)}`;
};
var range = (length, start = 0) => {
return Array.from({ length: length - start }, (_, i) => i + start);
};
var capitalize = (string) => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
function isEqual(obj1, obj2) {
if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") return obj1 === obj2;
const keys1 = Object.keys(obj1);
const keys2 = Object.keys(obj2);
if (keys1.length !== keys2.length) return false;
for (const key of keys1) if (!isEqual(obj1[key], obj2[key])) return false;
return true;
}
//#endregion
export { capitalize, isEqual, range, uniqueId };