node-file-loader

0.1.0 • Public • Published

node-file-loader

Build Status

Installation

npm install node-file-loader --save

Usage

To use the loader, first require it:

var Loader = require('node-file-loader');

Methods

load(filePath)

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
});

yaml(filePath)

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
});

json(filePath)

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
});

Package Sidebar

Install

npm i node-file-loader

Weekly Downloads

1

Version

0.1.0

License

ISC

Last publish

Collaborators

  • jpstevens