parent
1fec480af7
commit
28e12251d6
3 changed files with 26 additions and 1 deletions
@ -0,0 +1,14 @@ |
||||
type QueryField = string; |
||||
|
||||
export const buildQueryResultModifier = |
||||
<T>(mod: (output: QueryField[][]) => T): QueryResultModifierFunction => |
||||
(output) => |
||||
output instanceof Array ? mod(output) : output; |
||||
|
||||
export const buildQueryResultReducer = <T>( |
||||
reduce: (previous: T, row: QueryField[]) => T, |
||||
initialValue: T, |
||||
) => |
||||
buildQueryResultModifier<T>((output) => |
||||
output.reduce<T>(reduce, initialValue), |
||||
); |
@ -0,0 +1,9 @@ |
||||
type BuildQueryDetailOptions = { keys?: string[] | '*' }; |
||||
|
||||
type BuildQueryDetailReturn = { |
||||
query: string; |
||||
} & Pick<BuildQueryOptions, 'afterQueryReturn'>; |
||||
|
||||
type BuildQueryDetailFunction = ( |
||||
options?: BuildQueryDetailOptions, |
||||
) => BuildQueryDetailReturn; |
Loading…
Reference in new issue