( obj: Record<string, any>, toRemove: Array<string | RegExp> )
| 536 | * @public |
| 537 | */ |
| 538 | export function except( |
| 539 | obj: Record<string, any>, |
| 540 | toRemove: Array<string | RegExp> |
| 541 | ): Record<string, any> { |
| 542 | const clean: Record<string, any> = {} |
| 543 | const exps = toRemove.filter((n) => n instanceof RegExp) as RegExp[] |
| 544 | const keysToRemove = new Set(toRemove) |
| 545 | for (const key in obj) { |
| 546 | if (!keysToRemove.has(key) && !exps.some((exp) => exp.test(key))) { |
| 547 | clean[key] = obj[key] |
| 548 | } |
| 549 | } |
| 550 | return clean |
| 551 | } |
| 552 | |
| 553 | /** |
| 554 | * Extracts a set of keys from a given object. Importantly, this will extract |
no outgoing calls
no test coverage detected