fileExists

Resolves the supposedFileLocation parameter if the parameter points to a existing file. It rejects a NotExistingFileError if file is inexisting.
Parameter ListReturnsRejection Errors
  • supposedFileLocation: string
  • tuple: Array (optional)
Promise<string || Array>
Related FunctionsFunction Signature
function fileExists(supposedString[, tuple]): Promise<string || Array>
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'