omitBy() function
返回对象的部分副本,仅包含满足提供的谓词的键。
Signature:
typescript
declare function omitBy<T extends object, F extends AsyncEntryPredicate<T>>(
f: F,
obj: T,
): Promise<Partial<T>>;Example
ts
const obj = { a: 1, b: "2", c: true };
omitBy(([key, value]) => key === "a" || value === true, obj); // { b: "2" }
// asynchronous predicate
await omitBy(async ([key, value]) => key === "a" || value === true, obj); // { b: "2" }
// Using with the `pipe` function
pipe(
obj,
omitBy(([key, value]) => key === "a" || value === true),
);
await pipe(
obj,
omitBy(async ([key, value]) => key === "a" || value === true),
);