mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-24 09:27:49 +08:00
21 lines
504 B
TypeScript
21 lines
504 B
TypeScript
|
/**
|
||
|
* Remove a property or an array of properties from an object
|
||
|
* @param obj Object
|
||
|
* @param key Key to remove
|
||
|
*/
|
||
|
export default function deleteProps(obj: { [key: string ]: any }, propOrProps: string | string[]) {
|
||
|
const props = typeof propOrProps === 'string'
|
||
|
? [propOrProps]
|
||
|
: propOrProps
|
||
|
|
||
|
return Object
|
||
|
.keys(obj)
|
||
|
.reduce((newObj: { [key: string ]: any }, prop) => {
|
||
|
if (!props.includes(prop)) {
|
||
|
newObj[prop] = obj[prop]
|
||
|
}
|
||
|
|
||
|
return newObj
|
||
|
}, {})
|
||
|
}
|