Skip to content

Instantly share code, notes, and snippets.

@lancetw
Created March 1, 2018 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lancetw/099c1cb42d02146509ac97c01e9a6974 to your computer and use it in GitHub Desktop.
Save lancetw/099c1cb42d02146509ac97c01e9a6974 to your computer and use it in GitHub Desktop.
filterByProps
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