npm install node-file-loader --save
To use the loader, first require it:
var Loader = require('node-file-loader');
Load file (UTF-8). Returns a promise object containing the file.
Loader.load(__dirname+'/example.txt')
.then(function (file) {
// handle plain-text file
}).catch(function (err) {
// handle error
});
Load YAML file into a Javascript object. Returns a promise object containing the object.
Loader.yaml(__dirname+'/example.yml')
.then(function (obj) {
// handle the file, as a javascript object
})
.catch(function (err) {
// handle error
});
Load JSON file into a Javascript object. Returns a promise object containing the object.
Loader.json(__dirname+'/example.json')
.then(function (obj) {
// handle the file, as a javascript object
})
.catch(function (err) {
// handle error
});