UNPKG

@devexperts/dxcharts-lite

Version:
50 lines (49 loc) 1.61 kB
/* * Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. */ export const cloneUnsafe = (value) => JSON.parse(JSON.stringify(value)); export function typedEntries_UNSAFE(obj) { // eslint-disable-next-line no-restricted-syntax return Object.entries(obj); } export const findKeyFromValue = (map, mapValue) => { for (const [key, value] of Array.from(map.entries())) { if (value === mapValue) { return key; } } }; export function keys(r) { // eslint-disable-next-line no-restricted-syntax return Object.keys(r); } /** * Deeply compares two objects * @param {*} objA * @param {*} objB * @returns {Boolean} */ export function deepEqual(objA, objB) { if (Object.is(objA, objB)) { return true; } if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { return false; } const keysA = Object.keys(objA); const keysB = Object.keys(objB); if (keysA.length !== keysB.length) { return false; } // Test for A's keys different from B. for (let i = 0, len = keysA.length; i < len; i++) { // @ts-ignore if (!hasOwnProperty.call(objB, keysA[i]) || !deepEqual(objA[keysA[i]], objB[keysA[i]])) { return false; } } return true; } export const isEmpty = (obj) => Object.keys(obj).length === 0 && obj.constructor === Object;