arcanophile v1.0.1
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
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 |
fileExists(targetPath, createOnRun) ⇒ Boolean
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 |
exists(targetPath) ⇒ Boolean
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 |
makeFolder(targetPath) ⇒ Boolean
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 |
makeFile(targetPath, data, options) ⇒ Boolean
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 |
isFolder(targetPath) ⇒ Boolean
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 |
readFiles(folderPath, verbose) ⇒ Array
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 |
readFile(folderPath, verbose) ⇒ Array
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 |
readDirs(folderPath, flatten) ⇒ Array
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 |
readDir(folderPath) ⇒ Array
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 |