Skip to content

Commit 558851c

Browse files
committed
refactor: move omit to devtools
1 parent a2f3e91 commit 558851c

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

src/devtools.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { RouteRecordMatcher } from './matcher/pathMatcher'
1515
import { PathParser } from './matcher/pathParserRanker'
1616
import { Router } from './router'
1717
import { RouteLocationNormalized } from './types'
18-
import { assign, omit } from './utils'
18+
import { assign } from './utils'
1919

2020
function formatRouteLocation(
2121
routeLocation: RouteLocationNormalized,
@@ -472,3 +472,17 @@ function isRouteMatching(route: RouteRecordMatcher, filter: string): boolean {
472472

473473
return route.children.some(child => isRouteMatching(child, filter))
474474
}
475+
476+
function omit<T extends object, K extends [...(keyof T)[]]>(obj: T, keys: K) {
477+
const ret = {} as {
478+
[K2 in Exclude<keyof T, K[number]>]: T[K2]
479+
}
480+
481+
for (let key in obj) {
482+
if (!keys.includes(key as any)) {
483+
// @ts-ignore
484+
ret[key] = obj[key]
485+
}
486+
}
487+
return ret
488+
}

src/utils/index.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,3 @@ export function applyToParams(
2424
}
2525

2626
export let noop = () => {}
27-
28-
export const omit = <T extends Record<string, any>>(
29-
object: T,
30-
paths: Array<keyof T>
31-
) => {
32-
const result: Record<string, any> = {}
33-
for (let key in object) {
34-
if (
35-
paths.indexOf(key) >= 0 ||
36-
!Object.prototype.hasOwnProperty.call(object, key)
37-
) {
38-
continue
39-
}
40-
result[key] = object[key]
41-
}
42-
return result
43-
}

0 commit comments

Comments
 (0)