new EnumFiles()
Methods
-
<static> files(filepath)
Enumerate files under the filepath.
-
- You can get the files just under the directory (filepath).
- This function does not run search against sub directories.
- When you'd like to run it recursively, call
filesRecursively
instead.return EnumFiles.files('test') .then((files) => { // Here, the files would be like this. // [ // 'test/test1.txt', // 'test/test2.txt' // ] });
- If the file path does not exist, the result would simply be an empty array instead of an error.
Parameters:
Name Type Description filepath
string filepath to find.
Returns:
- Promise.([string, string, string, ...])
- Type
- Promise.<Array>
-
<static> filesRecursively(filepath)
Enumerate files under the filepath *recursively*.
-
- You can get the all files under the directory and its child-directories.
- This function does run search recursively.
return EnumFiles.filesRecursively('test') .then((files) => { // Here, the files would be like this. // [ // 'test/test1.txt', // 'test/test2.txt' // 'test/test1/test1.txt', // 'test/test1/test2.txt' // 'test/test1/test1_1/test1.txt', // 'test/test1/test1_1/test2.txt' // ] });
- If the file path does not exist, the result would simply be an empty array instead of an error.
Parameters:
Name Type Description filepath
string filepath to find.
- See:
Returns:
- Promise.([string, string, string, ...])
- Type
- Promise.<Array>
-
<static> dir(filepath)
Enumerate directories under the filepath.
-
- You can get the directories just under the directory (filepath).
- This function does not run search against sub directories.
- When you'd like to run it recursively, call
dirRecursively
instead.return EnumFiles.dir('test') .then((directories) => { // Here, the directories would be like this. // [ // 'test/test1', // 'test/test2' // ] });
- If the file path does not exist, the result would simply be an empty array instead of an error.
Parameters:
Name Type Description filepath
string filepath to find.
Returns:
- Promise.([string, string, string, ...])
- Type
- Promise.<Array>
-
<static> dirRecursively(filepath)
Enumerate directories under the filepath *recursively*.
-
- You can get the all directories under the directory and its child-directories.
- This function does run search recursively.
return EnumFiles.dirRecursively('test') .then((directories) => { // Here, the directories would be like this. // [ // 'test/test1', // 'test/test1/test1_1', // 'test/test1/test1_2', // 'test/test2' // ] });
- If the file path does not exist, the result would simply be an empty array instead of an error.
Parameters:
Name Type Description filepath
string filepath to find.
- See:
Returns:
- Promise.([string, string, string, ...])
- Type
- Promise.<Array>