@@ -10,7 +10,61 @@ export type FileSystem = typeof nodefs;
10
10
export type PathFn = typeof path ;
11
11
12
12
/**
13
- * Emmmm
13
+ * Get a new instance of `PathNice` or `PathNiceArr`.
14
+ *
15
+ * If the argurment is a string or a `PathNice`, a `PathNice` is returned. A `PathNice`
16
+ * instance is a wrapper of the raw path string, so that the path can be easily used to
17
+ * generate additional paths or manipulate files.
18
+ *
19
+ * If there are more than 1 arguments or the only argument is an `Array`, a `PathNiceArr`
20
+ * is returned. The class `PathNiceArr` extends the base class `Array`, adding methods for
21
+ * copying, moving, removing, watching files in a holistic manner.
22
+ *
23
+ * For details, please refer to the documents of [PathNice]()
24
+ * and [PathNiceArr]().
25
+ *
26
+ * @example
27
+ *
28
+ * Get a PathNice instance:
29
+ *
30
+ * ```ts
31
+ * $ let src: PathNice = path('./src')
32
+ * ```
33
+ *
34
+ * Get the raw path string from PathNice:
35
+ *
36
+ * ```ts
37
+ * $ src.raw
38
+ * './src'
39
+ * ```
40
+ *
41
+ * Use `src` to generate another path:
42
+ *
43
+ * ```ts
44
+ * $ src.join('index.ts')
45
+ * PathNice { raw: 'src/index.ts' } // on POSIX
46
+ * PathNice { raw: 'src\\index.ts' } // on Windows
47
+ * ```
48
+ *
49
+ * Use `src` to write a file:
50
+ *
51
+ * ```ts
52
+ * $ src.join('index.ts').writeFile('export default 42;')
53
+ * Promise { <pending> ... }
54
+ * ```
55
+ *
56
+ * Get a PathNiceArr instance:
57
+ *
58
+ * ```ts
59
+ * let arr = path('./README.md', './package.json', './tsconfig.json');
60
+ * ```
61
+ *
62
+ * Filter json files from the array and copy to another folder:
63
+ *
64
+ * ```ts
65
+ * arr.filter(f => f.ext() === '.json')
66
+ * .copyToDir('./config')
67
+ * ```
14
68
*/
15
69
export declare function path < T extends string > ( path : T ) : PathNice < T > ;
16
70
export declare function path < T extends string > ( path : PathNice < T > ) : PathNice < T > ;
@@ -19,7 +73,9 @@ export declare function path(
19
73
path_1 : string | PathNice ,
20
74
...paths_rest : ( string | PathNice ) [ ]
21
75
) : PathNiceArr ;
22
- export declare function path ( paths : Array < string | PathNice > | PathNiceArr ) : PathNiceArr ;
76
+ export declare function path (
77
+ paths : ReadonlyArray < string | PathNice > | PathNiceArr ,
78
+ ) : PathNiceArr ;
23
79
24
80
export declare namespace path {
25
81
/**
0 commit comments