-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
48 lines (46 loc) · 1.29 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
export interface Options {
/**
* @description
* whether keep the passed parameter `directoryPath` on the result keys or not
* @example
* ```js
* importDirectory("./routes", {keepPathOnKey:false})
* directoryPath = "./routes" > "/home/user/app/routes"
* results = {
* "/index.ts": Module
* }
*
* importDirectory("./routes", {keepPathOnKey:true})
* directoryPath = "./routes" > "/home/user/app/routes"
* results = {
* "/home/user/app/routes/index.ts": Module
* }
* ```
* @default false
*/
keepPathOnKey?: boolean
/**
* @description prefix to all results keys
* @example
* ```js
* importDirectory("./", {prefixKey:"/app"})
* "/utils/index.js" > "/app/utils/index.js"
* ```
*/
prefixKey?: string
/**
* @description whether remove extension file or not
* @default false
*/
removeExtensionFile?: boolean
/**
* @description valid extenstions to import
* @default [".js", ".cjs", ".mjs", ".jsx", ".ts", ".cts", ".mts", ".tsx"]
*/
extensions?: string[]
}
export declare function importDirectory<T extends unknown = unknown>(
directoryPath: string,
options?: Options
): Promise<Record<string, T>>
export declare const DEFAULT_EXTENSIONS: readonly [".js", ".cjs", ".mjs", ".jsx", ".ts", ".cts", ".mts", ".tsx"]