fileExists
Description
Resolves the supposedFileLocation parameter if the parameter points to a existing file. It rejects a NotExistingFileError if file is inexisting.
Parameter List | Returns | Rejection Errors |
---|---|---|
| Promise<string || Array> | |
Related Functions | Function Signature | |
function fileExists(supposedString[, tuple]): Promise<string || Array> |
Examples
1
2
3
4
import {fileExists} from 'puddy-m/lib/fileFunctions'
fileExists('path/to/supposed/file')
.then(supposedfilePath=>console.log(supposedfilePath)) // prints 'path/to/supposed/file'
1
2
3
4
import {fileExists} from 'puddy-m/lib/fileFunctions'
fileExists(true)
.catch(e=>e)
1
2
3
4
5
6
// Using it with tuple parameter
import {fileExists} from 'puddy-m/lib/fileFunctions'
fileExists('path/to/supposed/file', [])
.then(tuple=>validateString("World", tuple))
.then(([first, second])=> first + second) // 'path/to/supposed/fileWorld'