fs

(fs).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’] Kind: inner method of fs
Returns: Array.<string> - - The list of files and directories.
Throws:
  • error - The error encountered during listing.
ParamTypeDescription
pathstringThe path to list files and directories from.
itemTypestringThe type of items to list. Can be ‘file’, ‘dir’, or ‘all’.
Example
let m = require('nuclei/fs'); 
let items = m.ListDir('/tmp', 'all');

(fs).ReadFile(path) ⇒ Uint8Array

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

(fs).ReadFileAsString(path) ⇒ string

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

(fs).ReadFilesFromDir(dir) ⇒ Array.<string>

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