Methods

(inner) ListDir(path, itemType) → {Array.<string>}

ListDir lists all files and directories within a path depending on the itemType provided. itemType can be any one of ['file','dir','all']
Parameters:
NameTypeDescription
pathstringThe path to list files and directories from.
itemTypestringThe type of items to list. Can be 'file', 'dir', or 'all'.
Throws:
- The error encountered during listing.
Type
error
Returns:
- The list of files and directories.
Type: 
Array.<string>
Example
let m = require('nuclei/fs'); 
let items = m.ListDir('/tmp', 'all');

(inner) ReadFile(path) → {Uint8Array}

ReadFile reads file contents within permitted paths
Parameters:
NameTypeDescription
pathstringThe path to the file to read.
Throws:
- The error encountered during reading.
Type
error
Returns:
- The contents of the file.
Type: 
Uint8Array
Example
let m = require('nuclei/fs'); 
let content = m.ReadFile('/tmp/myfile.txt');

(inner) ReadFileAsString(path) → {string}

ReadFileAsString reads file contents within permitted paths and returns content as string
Parameters:
NameTypeDescription
pathstringThe path to the file to read.
Throws:
- The error encountered during reading.
Type
error
Returns:
- The contents of the file as a string.
Type: 
string
Example
let m = require('nuclei/fs'); 
let content = m.ReadFileAsString('/tmp/myfile.txt');

(inner) ReadFilesFromDir(dir) → {Array.<string>}

ReadFilesFromDir reads all files from a directory and returns a array with file contents of all files
Parameters:
NameTypeDescription
dirstringThe directory to read files from.
Throws:
- The error encountered during reading.
Type
error
Returns:
- The contents of all files in the directory.
Type: 
Array.<string>
Example
let m = require('nuclei/fs'); 
let contentArray = m.ReadFilesFromDir('/tmp');