Initial import from local backup (Documents-Playground/pakerpale)
This commit is contained in:
31
node_modules/r-json/lib/index.js
generated
vendored
Normal file
31
node_modules/r-json/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
// Dependencies
|
||||
var Fs = require("fs");
|
||||
|
||||
/**
|
||||
* rJson
|
||||
*
|
||||
* @name rJson
|
||||
* @function
|
||||
* @param {String} path The JSON file path.
|
||||
* @param {Function} callback An optional callback. If not passed, the function will run in sync mode.
|
||||
*/
|
||||
function rJson(path, callback) {
|
||||
|
||||
if (typeof callback === "function") {
|
||||
Fs.readFile(path, "utf-8", function (err, data) {
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
} catch (e) {
|
||||
err = err || e;
|
||||
}
|
||||
callback(err, data);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
return JSON.parse(Fs.readFileSync(path));
|
||||
}
|
||||
|
||||
module.exports = rJson;
|
||||
Reference in New Issue
Block a user