-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (44 loc) · 1 KB
/
index.js
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
49
50
//imports
import path from "path";
import File from "./lib/File";
import Dir from "./lib/Dir";
/**
* Creates a file wrapper for asserting.
*
* @overload
* @param path:string The file path.
* @return File
*
* @overload
* @param dir:string The directory path.
* @param file:string The file name.
*/
export function file(...args) {
var fp;
//(1) arguments
if (args.length === 0) throw new Error("File path expected.");
else if (args.length == 1) fp = args[0];
else fp = path.join(...args);
//(2) return
return new File(fp);
}
/**
* Creates a dir wrapper for asserting.
*
* @overload
* @param path:string The directory path.
* @return Dir
*
* @overload
* @param parent:string The parent directory.
* @param name:string The directory name.
*/
export function dir(...args) {
var dp;
//(1) arguments
if (args.length === 0) throw new Error("Directory path expected.");
else if (args.length == 1) dp = args[0];
else dp = path.join(...args);
//(2) return
return new Dir(dp);
}