INI
Reads the entire contents of an INI file.
Installation
$ npm install utils-fs-read-ini
Usage
var read = ;
read( path, [ options,] clbk )
Reads the entire contents of an INI file.
;{if errorconsole;elseconsole;}
The function
accepts the same options as properties#parse
, except
path
is alwaystrue
.sections
is alwaystrue
.strict
is alwaystrue
.separators
is always'='
.comments
, by default, begin with';'
.
var opts ='comments': ';' '#';;{if errorconsole;elseconsole;}
read.sync( path[, options] )
Synchronously reads the contents of an entire INI file.
var out = read;if out instanceof Errorthrow out;console;
The function
accepts the same options as fs.readFileSync()
as well as utils-ini-parse options.
Examples
var path =read = ;var file = path;/*** INI reviver.** @param* @param* @param* @returns*/{/* jshint validthis:true */var vals;// Do not split section lines...if thisisSectionreturn this;// Split comma-delimited strings...if typeof value === 'string'vals = value;return valslength === 1 ? value : vals;// Do not split the rest of the lines:return this;}// Sync:var data = read;// returns <object>console;// returns falsedata = read;// returns <error>console;// returns true// Async:;;{if errorif errorcode === 'ENOENT'console;elsethrow error;elseconsole;}
To run the example code from the top-level application directory,
$ node ./examples/index.js
Tests
Unit
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
License
Copyright
Copyright © 2015. Athan Reines.