Skip to content

Commit

Permalink
Merge pull request #93 from electron-userland/default-callback-to-noop
Browse files Browse the repository at this point in the history
Default callback to _.noop
  • Loading branch information
jviotti authored Oct 19, 2017
2 parents fcf3989 + 8c0519c commit 1a4a961
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ exports.get = function(key, options, callback) {
callback = options;
}

callback = callback || _.noop;

async.waterfall([
async.asyncify(_.partial(utils.getFileName, key, {
dataPath: options.dataPath
Expand Down Expand Up @@ -181,6 +183,8 @@ exports.getMany = function(keys, options, callback) {
options = {};
}

callback = callback || _.noop;

async.reduce(keys, {}, function(reducer, key, callback) {
exports.get(key, options, function(error, data) {
if (error) {
Expand Down Expand Up @@ -218,6 +222,8 @@ exports.getAll = function(options, callback) {
options = {};
}

callback = callback || _.noop;

async.waterfall([
_.partial(exports.keys, options),
function(keys, callback) {
Expand Down Expand Up @@ -256,6 +262,8 @@ exports.set = function(key, json, options, callback) {
callback = options;
}

callback = callback || _.noop;

async.waterfall([
async.asyncify(_.partial(utils.getFileName, key, {
dataPath: options.dataPath
Expand Down Expand Up @@ -312,6 +320,8 @@ exports.has = function(key, options, callback) {
callback = options;
}

callback = callback || _.noop;

async.waterfall([
async.asyncify(_.partial(utils.getFileName, key, {
dataPath: options.dataPath
Expand Down Expand Up @@ -358,6 +368,8 @@ exports.keys = function(options, callback) {
options = {};
}

callback = callback || _.noop;

async.waterfall([
function(callback) {
callback(null, options.dataPath || exports.getDataPath());
Expand Down Expand Up @@ -404,6 +416,8 @@ exports.remove = function(key, options, callback) {
callback = options;
}

callback = callback || _.noop;

async.waterfall([
async.asyncify(_.partial(utils.getFileName, key, {
dataPath: options.dataPath
Expand Down Expand Up @@ -433,6 +447,8 @@ exports.clear = function(options, callback) {
callback = options;
}

callback = callback || _.noop;

const userData = options.dataPath || exports.getDataPath();
const jsonFiles = path.join(userData, '*.json');
rimraf(jsonFiles, callback);
Expand Down

0 comments on commit 1a4a961

Please sign in to comment.