Returns file content as a UTF-8 string. Returns null if file does not exist (or is a directory) instead of throwing an Error.
npm install --save read-file-string@^1.1.2yarn add read-file-string@^1.1.2
(if configured properly)
npm install --save @jaid/read-file-string@^1.1.2import readFileString from "read-file-string"
readFileString("./existingFile.txt").then(result => {
})
readFileString("./doesNotExist.txt").then(result2 => {
})Variable result will be:
"the file contents"Variable result2 will be:
nullSetting up:
git clone [email protected]:jaid/read-file-string.git
cd read-file-string
npm installTesting:
npm run test:devTesting in production environment:
npm run testMIT License
Copyright © 2021, Jaid <[email protected]> (https://github.com/jaid)