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 { SortingOrder, SortingOrders } from './models/sorting-order.type';
|
||||||
import { KeysOf, shareDistinctLast } from '../utils';
|
import { KeysOf, shareDistinctLast } from '../utils';
|
||||||
import { IListable } from '../listing';
|
import { IListable } from '../listing';
|
||||||
import orderBy from 'lodash/orderBy';
|
import { orderBy } from 'lodash-es';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SortingService<T extends IListable> {
|
export class SortingService<T extends IListable> {
|
||||||
@ -29,7 +29,7 @@ export class SortingService<T extends IListable> {
|
|||||||
return order === SortingOrders.asc ? result : result.reverse();
|
return order === SortingOrders.asc ? result : result.reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
return orderBy<T>(values, [column], [order]) ;
|
return orderBy<T>(values, [column], [order]);
|
||||||
}
|
}
|
||||||
|
|
||||||
setSortingOption(value: SortingOption<T>): void {
|
setSortingOption(value: SortingOption<T>): void {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import debounce from 'lodash/debounce';
|
import { debounce } from 'lodash-es';
|
||||||
|
|
||||||
interface DebounceSettings {
|
interface DebounceSettings {
|
||||||
readonly leading?: boolean;
|
readonly leading?: boolean;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { ITrackable } from '../listing/models/trackable';
|
import { ITrackable } from '../listing/models/trackable';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
import _ from 'lodash';
|
import { forOwn, has, isEqual, isPlainObject, transform } from 'lodash-es';
|
||||||
|
|
||||||
export function capitalize(value: string): string {
|
export function capitalize(value: string): string {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
@ -93,20 +93,20 @@ export function deepDiffObj(base: Record<string, unknown>, object: Record<string
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = _.transform(object, (result: Record<string, unknown>, value, key) => {
|
const res = transform(object, (result: Record<string, unknown>, value, key) => {
|
||||||
if (!_.has(base, key)) {
|
if (!has(base, key)) {
|
||||||
result[key] = value;
|
result[key] = value;
|
||||||
} // fix edge case: not defined to explicitly defined as undefined
|
} // fix edge case: not defined to explicitly defined as undefined
|
||||||
if (!_.isEqual(value, base[key])) {
|
if (!isEqual(value, base[key])) {
|
||||||
result[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>)
|
? deepDiffObj(base[key] as Record<string, unknown>, value as Record<string, unknown>)
|
||||||
: value;
|
: value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// map removed fields to undefined
|
// map removed fields to undefined
|
||||||
_.forOwn(base, (value, key) => {
|
forOwn(base, (value, key) => {
|
||||||
if (!_.has(object, key)) {
|
if (!has(object, key)) {
|
||||||
res[key] = undefined;
|
res[key] = undefined;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user