Created
March 1, 2018 18:05
-
-
Save lancetw/099c1cb42d02146509ac97c01e9a6974 to your computer and use it in GitHub Desktop.
filterByProps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function filterByProps(obj: any, props: string[]): any { | |
if (!props) return obj | |
let ret = {} | |
Object.keys(obj).forEach(key => { | |
if (props.some(prop => prop === key)) { | |
ret[key] = clone(obj[key]) | |
} | |
}) | |
return ret | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment