mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-10-05 09:12:04 +00:00
feat: upgrade prettier to v3
This commit is contained in:
@@ -17,12 +17,15 @@
|
||||
* Pick a set of properties from an object
|
||||
*/
|
||||
export function pick<T extends object, U extends keyof T>(object: T, keys: U[]): Pick<T, U> {
|
||||
return keys.reduce((accumulator, key) => {
|
||||
if (object.hasOwnProperty(key)) {
|
||||
accumulator[key] = object[key];
|
||||
}
|
||||
return accumulator;
|
||||
}, {} as Pick<T, U>);
|
||||
return keys.reduce(
|
||||
(accumulator, key) => {
|
||||
if (object.hasOwnProperty(key)) {
|
||||
accumulator[key] = object[key];
|
||||
}
|
||||
return accumulator;
|
||||
},
|
||||
{} as Pick<T, U>,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,10 +35,13 @@ export function pickBy<T extends object, U extends keyof T>(
|
||||
object: T,
|
||||
predicate: (value: T[U], key: U) => boolean,
|
||||
): Pick<T, U> {
|
||||
return (Object.keys(object) as U[]).reduce((accumulator, key) => {
|
||||
if (predicate(object[key], key)) {
|
||||
accumulator[key] = object[key];
|
||||
}
|
||||
return accumulator;
|
||||
}, {} as Pick<T, U>);
|
||||
return (Object.keys(object) as U[]).reduce(
|
||||
(accumulator, key) => {
|
||||
if (predicate(object[key], key)) {
|
||||
accumulator[key] = object[key];
|
||||
}
|
||||
return accumulator;
|
||||
},
|
||||
{} as Pick<T, U>,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user