mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
711 B
29 lines
711 B
var fs = require( 'graceful-fs' );
|
|
var write = require( 'write' );
|
|
var circularJson = require( 'circular-json' );
|
|
|
|
module.exports = {
|
|
|
|
/**
|
|
* Read json file synchronously using circular-json
|
|
*
|
|
* @method readJSON
|
|
* @param {String} filePath Json filepath
|
|
* @returns {*} parse result
|
|
*/
|
|
readJSON: function ( filePath ) {
|
|
return circularJson.parse( fs.readFileSync( filePath ).toString() );
|
|
},
|
|
|
|
/**
|
|
* Write json file synchronously using circular-json
|
|
*
|
|
* @method writeJSON
|
|
* @param {String} filePath Json filepath
|
|
* @param {*} data Object to serialize
|
|
*/
|
|
writeJSON: function (filePath, data ) {
|
|
write.sync( filePath, circularJson.stringify( data ) );
|
|
}
|
|
|
|
};
|
|
|