UNPKG

1.47 kBTypeScriptView Raw
1export interface Options {
2 /* a list of files to search */
3 files?: string[]
4 /* the directory to search from */
5 cwd?: string
6 /* the directory to stop searching */
7 stopDir?: string
8 /* the key in package.json to read data at */
9 packageKey?: string
10 /* the function used to parse json */
11 parseJSON?: (str: string) => any
12}
13
14export interface LoadResult {
15 /* file path */
16 path?: string
17 /* file data */
18 data?: any
19}
20
21export interface AsyncLoader {
22 /** Optional loader name */
23 name?: string
24 test: RegExp
25 load(filepath: string): Promise<any>
26}
27
28export interface SyncLoader {
29 /** Optional loader name */
30 name?: string
31 test: RegExp
32 loadSync(filepath: string): any
33}
34
35export interface MultiLoader {
36 /** Optional loader name */
37 name?: string
38 test: RegExp
39 load(filepath: string): Promise<any>
40 loadSync(filepath: string): any
41}
42
43declare class JoyCon {
44 constructor(public options?: Options)
45
46 resolve(files?: string[] | Options, cwd?: string, stopDir?: string): Promise<string | null>
47 resolveSync(files?: string[] | Options, cwd?: string, stopDir?: string): string | null
48
49 load(files?: string[] | Options, cwd?: string, stopDir?: string): Promise<LoadResult>
50 loadSync(files?: string[] | Options, cwd?: string, stopDir?: string): LoadResult
51
52 addLoader(loader: AsyncLoader | SyncLoader | MultiLoader): this
53 removeLoader(name: string): this
54
55 /** Clear internal cache */
56 clearCache(): this
57}
58
59
60export default JoyCon