arcanophile
Installation
npm i arcanophile
import { readFile } from "arcanophile";
Functions
-
folderExists(targetPath, createOnRun) ⇒
Boolean
-
Checks if path exists and is actually a directory, optionally creates the folder whenever investigated
-
fileExists(targetPath, createOnRun) ⇒
Boolean
-
Returns Boolean if path exists and it's a valid folder, optionally creates the folder whenever investigated
-
exists(targetPath) ⇒
Boolean
-
Type independent function to check existence of path
-
makeFolder(targetPath) ⇒
Boolean
-
Shorter alias of a mkdir function to create a folder at specified path
-
makeFile(targetPath, data, options) ⇒
Boolean
-
Shorter alias of a writeFileSync function to create a file at specified path
-
isFolder(targetPath) ⇒
Boolean
-
Verify a given path string is actually a directory and not a type of file
-
readFiles(folderPath, verbose) ⇒
Array
-
Thenable way to get all the file contents of a folder path
-
readFile(folderPath, verbose) ⇒
Array
-
Thenable way to get a file's contents
-
readDirs(folderPath, flatten) ⇒
Array
-
Returns the children filepaths of each folder Array entry
-
readDir(folderPath) ⇒
Array
-
Returns the children filepaths of given folder path
Boolean
folderExists(targetPath, createOnRun) ⇒ Checks if path exists and is actually a directory, optionally creates the folder whenever investigated
Kind: global function
Returns: Boolean
- Whether path existed at time of investigating
Param | Type | Default | Description |
---|---|---|---|
targetPath | String |
Relative or absolute file path | |
createOnRun | Boolean |
true |
If TRUE, create empty folder if didn't previously exist |
Boolean
fileExists(targetPath, createOnRun) ⇒ Returns Boolean if path exists and it's a valid folder, optionally creates the folder whenever investigated
Kind: global function
Returns: Boolean
- Whether path exists
Param | Type | Description |
---|---|---|
targetPath | String |
Relative or absolute file path |
createOnRun | Boolean |
If TRUE, create empty folder if didn't previously exist |
Boolean
exists(targetPath) ⇒ Type independent function to check existence of path
Kind: global function
Returns: Boolean
- Whether path exists
Param | Type | Description |
---|---|---|
targetPath | String |
Relative or absolute file path |
Boolean
makeFolder(targetPath) ⇒ Shorter alias of a mkdir function to create a folder at specified path
Kind: global function
Returns: Boolean
- Whether folder creation was successful
Param | Type | Description |
---|---|---|
targetPath | String |
Relative or absolute file path |
Boolean
makeFile(targetPath, data, options) ⇒ Shorter alias of a writeFileSync function to create a file at specified path
Kind: global function
Returns: Boolean
- Whether folder creation was successful
Param | Type | Default | Description |
---|---|---|---|
targetPath | String |
Relative or absolute file path | |
data |
String | Buffer | URL
|
Contents of file | |
options | Object |
|
Key/values for encoding, mode, and flag |
Boolean
isFolder(targetPath) ⇒ Verify a given path string is actually a directory and not a type of file
Kind: global function
Returns: Boolean
- Whether path exists
Param | Type | Description |
---|---|---|
targetPath | String |
Relative or absolute file path |
Array
readFiles(folderPath, verbose) ⇒ Thenable way to get all the file contents of a folder path
Kind: global function
Returns: Array
- String data of each file contained within
Param | Type | Default | Description |
---|---|---|---|
folderPath | String |
Relative or absolute folder path | |
verbose | Boolean |
true |
If false, only return file content, otherwise return detailed File object |
Array
readFile(folderPath, verbose) ⇒ Thenable way to get a file's contents
Kind: global function
Returns: Array
- String data of each file contained within
Param | Type | Description |
---|---|---|
folderPath | String |
Relative or absolute folder path |
verbose | Boolean |
If false, only return file content, otherwise return detailed File object |
Array
readDirs(folderPath, flatten) ⇒ Returns the children filepaths of each folder Array entry
Kind: global function
Returns: Array
- Any filepaths contained within a target folderpath entry
Param | Type | Description |
---|---|---|
folderPath | String |
Relative or absolute folder path |
flatten | Boolean |
Return as a single Array, otherwise return as Array of separate nested Arrays |
Array
readDir(folderPath) ⇒ Returns the children filepaths of given folder path
Kind: global function
Returns: Array
- Paths to each child file entry
Param | Type | Description |
---|---|---|
folderPath | String |
Relative or absolute folder path |