replace filterObject with shake

This commit is contained in:
vchikalkin 2023-04-12 17:54:12 +03:00
parent ac8860a023
commit 57058b473a
2 changed files with 2 additions and 18 deletions

View File

@ -5,8 +5,7 @@ import type { ProcessContext } from '@/process/types';
import ValidationHelper from '@/stores/validation/helper';
import { disposableReaction } from '@/utils/mobx';
import { reaction } from 'mobx';
import { uid } from 'radash';
import { filterObject } from 'tools';
import { shake, uid } from 'radash';
import type { BaseOption } from 'ui/elements/types';
function hasInvalidValueOrOptions(value: unknown, options: Array<BaseOption<unknown>>) {
@ -108,7 +107,7 @@ export default function reactions({ store }: ProcessContext) {
);
}
const optionsTypes = filterObject(types, (type) => type().typeName === 'Options');
const optionsTypes = shake(types, (type) => type().typeName !== 'Options');
(Object.keys(optionsTypes) as Values.Elements[]).forEach((elementName) =>
validateOptionsElement(elementName)

View File

@ -1,18 +1,3 @@
export function flatten(obj: object) {
return Object.values(obj).flat();
}
export function filterObject<T extends object, RemovedKeys extends keyof T>(
obj: T,
filter: (value: T[keyof T]) => boolean
): Omit<T, RemovedKeys> {
const keys = Object.keys(obj) as Array<keyof T>;
return keys.reduce((acc, objKey) => {
if (filter(obj[objKey])) {
acc[objKey] = obj[objKey];
}
return acc;
}, {} as T);
}