From: Eduardo San Martin Morote Date: Sun, 27 Dec 2020 13:48:34 +0000 (+0100) Subject: refactor: move omit to devtools X-Git-Tag: v4.0.2~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F672%2Fhead;p=thirdparty%2Fvuejs%2Frouter.git refactor: move omit to devtools --- 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 -}