A collection of functions I often use in my node.js projects
I was tired of either rewriting this stuff, or keeping track of different files of
different versions - so I figured I would group everything into one public place.
File I/O Methods
Method Name
Description
Signature
loadFile
Reads file from given filename, returning promise of that file
(STRING, STRING) -> PROMISE(*)
loadText
Loads file as text, returning promise of read text
(STRING) -> PROMISE(STRING)
loadJSON
Loads file as JSON, returning promise of read JSON
(STRING) -> PROMISE(JSON)
writeFile
Write data to given filename using given encoding, returning a promise of the filename if successful
(STRING, *, STRING) -> PROMISE(STRING)
writeText
Writes text to given filename, returning promise of filename
(STRING) -> PROMISE(STRING)
writeJSON
Write JSON to given filename, returning promise of filename
(STRING) -> PROMISE(STRING)
nameOfFile
Returns filename without path or extension
(STRING) -> PROMISE(STRING)
readDir
Returns a promise for an array of paths for the given directory filepath