From 558851c9e32f292b80ffc716d9dcc08cf7317df5 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sun, 27 Dec 2020 14:48:34 +0100 Subject: [PATCH] refactor: move omit to devtools --- src/devtools.ts | 16 +++++++++++++++- src/utils/index.ts | 17 ----------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/devtools.ts b/src/devtools.ts index 5fae1944..d5939724 100644 --- a/src/devtools.ts +++ b/src/devtools.ts @@ -15,7 +15,7 @@ import { RouteRecordMatcher } from './matcher/pathMatcher' import { PathParser } from './matcher/pathParserRanker' import { Router } from './router' import { RouteLocationNormalized } from './types' -import { assign, omit } from './utils' +import { assign } from './utils' function formatRouteLocation( routeLocation: RouteLocationNormalized, @@ -472,3 +472,17 @@ function isRouteMatching(route: RouteRecordMatcher, filter: string): boolean { return route.children.some(child => isRouteMatching(child, filter)) } + +function omit(obj: T, keys: K) { + const ret = {} as { + [K2 in Exclude]: T[K2] + } + + for (let key in obj) { + if (!keys.includes(key as any)) { + // @ts-ignore + ret[key] = obj[key] + } + } + return ret +} diff --git a/src/utils/index.ts b/src/utils/index.ts index 957c8b05..35a2b8d0 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -24,20 +24,3 @@ export function applyToParams( } export let noop = () => {} - -export const omit = >( - object: T, - paths: Array -) => { - const result: Record = {} - for (let key in object) { - if ( - paths.indexOf(key) >= 0 || - !Object.prototype.hasOwnProperty.call(object, key) - ) { - continue - } - result[key] = object[key] - } - return result -} -- 2.39.5