|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import DOMPurify from 'isomorphic-dompurify'; |
|
|
|
|
|
|
|
|
|
export function extractProps<T>(body: T, props: string[]): Partial<T> { |
|
|
|
|
export function extractProps<T extends object>(body: T, props: string[]): Partial<T> { |
|
|
|
|
// todo: throw error if no props found
|
|
|
|
|
return props.reduce((o, key) => { |
|
|
|
|
if (key in body) o[key] = body[key]; |
|
|
|
@ -8,7 +8,7 @@ export function extractProps<T>(body: T, props: string[]): Partial<T> {
|
|
|
|
|
}, {}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function extractPropsAndSanitize<T>( |
|
|
|
|
export function extractPropsAndSanitize<T extends object>( |
|
|
|
|
body: T, |
|
|
|
|
props: string[] |
|
|
|
|
): Partial<T> { |
|
|
|
|