Lodash-es
This commit is contained in:
parent
3e1b124bd9
commit
376b76648d
@ -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<T extends IListable> {
|
||||
@ -29,7 +29,7 @@ export class SortingService<T extends IListable> {
|
||||
return order === SortingOrders.asc ? result : result.reverse();
|
||||
}
|
||||
|
||||
return orderBy<T>(values, [column], [order]) ;
|
||||
return orderBy<T>(values, [column], [order]);
|
||||
}
|
||||
|
||||
setSortingOption(value: SortingOption<T>): void {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import debounce from 'lodash/debounce';
|
||||
import { debounce } from 'lodash-es';
|
||||
|
||||
interface DebounceSettings {
|
||||
readonly leading?: boolean;
|
||||
|
||||
@ -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<string, unknown>, object: Record<string
|
||||
return object;
|
||||
}
|
||||
|
||||
const res = _.transform(object, (result: Record<string, unknown>, value, key) => {
|
||||
if (!_.has(base, key)) {
|
||||
const res = transform(object, (result: Record<string, unknown>, 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<string, unknown>, value as Record<string, unknown>)
|
||||
: 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;
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user