Skip to content

Commit

Permalink
✨ feat: extractKeyFromArray, isMatchPath 유틸함수 추가 #10
Browse files Browse the repository at this point in the history
  • Loading branch information
froggy1014 committed Aug 22, 2024
1 parent 6fd08f2 commit d3826a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/utils/extractKeyFromArray.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const extractKeyFromArray = <T, K extends keyof T>(
array: Array<T>,
key: K,
): Array<T[K]> => array.map((item) => item[key]);
2 changes: 2 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ export * from "./checkNumber";
export * from "./cn";
export * from "./delay";
export * from "./downloadImageByUrl";
export * from "./extractKeyFromArray";
export * from "./generateQueryString";
export * from "./generateUrlWithParams";
export * from "./getSettledValue";
export * from "./isEmpty";
export * from "./isMatchPath";
export * from "./log";
4 changes: 4 additions & 0 deletions src/utils/isMatchPath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { match } from "path-to-regexp";

export const isMatchPath = (pathname: string, urls: string[]) =>
urls.some((url) => !!match(url)(pathname));

0 comments on commit d3826a6

Please sign in to comment.