From 376b76648d7f3d10db13c00cadbb2b08270ca395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 21 Mar 2022 20:40:26 +0200 Subject: [PATCH] Lodash-es --- src/lib/sorting/sorting.service.ts | 4 ++-- src/lib/utils/decorators/debounce.decorator.ts | 2 +- src/lib/utils/functions.ts | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/sorting/sorting.service.ts b/src/lib/sorting/sorting.service.ts index 2d94067..5a00272 100644 --- a/src/lib/sorting/sorting.service.ts +++ b/src/lib/sorting/sorting.service.ts @@ -4,7 +4,7 @@ import { SortingOption } from './models/sorting-option.model'; import { SortingOrder, SortingOrders } from './models/sorting-order.type'; import { KeysOf, shareDistinctLast } from '../utils'; import { IListable } from '../listing'; -import orderBy from 'lodash/orderBy'; +import { orderBy } from 'lodash-es'; @Injectable() export class SortingService { @@ -29,7 +29,7 @@ export class SortingService { return order === SortingOrders.asc ? result : result.reverse(); } - return orderBy(values, [column], [order]) ; + return orderBy(values, [column], [order]); } setSortingOption(value: SortingOption): void { diff --git a/src/lib/utils/decorators/debounce.decorator.ts b/src/lib/utils/decorators/debounce.decorator.ts index 2cd954f..2eef472 100644 --- a/src/lib/utils/decorators/debounce.decorator.ts +++ b/src/lib/utils/decorators/debounce.decorator.ts @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; interface DebounceSettings { readonly leading?: boolean; diff --git a/src/lib/utils/functions.ts b/src/lib/utils/functions.ts index 9adc948..e26dd75 100644 --- a/src/lib/utils/functions.ts +++ b/src/lib/utils/functions.ts @@ -1,7 +1,7 @@ import { ITrackable } from '../listing/models/trackable'; import moment from 'moment'; import { FormGroup } from '@angular/forms'; -import _ from 'lodash'; +import { forOwn, has, isEqual, isPlainObject, transform } from 'lodash-es'; export function capitalize(value: string): string { if (!value) { @@ -93,20 +93,20 @@ export function deepDiffObj(base: Record, object: Record, value, key) => { - if (!_.has(base, key)) { + const res = transform(object, (result: Record, value, key) => { + if (!has(base, key)) { result[key] = value; } // fix edge case: not defined to explicitly defined as undefined - if (!_.isEqual(value, base[key])) { + if (!isEqual(value, base[key])) { result[key] = - _.isPlainObject(value) && _.isPlainObject(base[key]) + isPlainObject(value) && isPlainObject(base[key]) ? deepDiffObj(base[key] as Record, value as Record) : value; } }); // map removed fields to undefined - _.forOwn(base, (value, key) => { - if (!_.has(object, key)) { + forOwn(base, (value, key) => { + if (!has(object, key)) { res[key] = undefined; } });