Skip to content

Commit

Permalink
Changing function name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Podwys committed Dec 21, 2015
1 parent 61fbc7f commit f2180bf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cacheModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function cacheModule(config){
* @param {function} cb
*/
self.get = function(key, cb){
checkMinParams((arguments.length < 2), 'ARGUMENT_EXCEPTION: .get() requires 2 arguments.');
throwErrorIf((arguments.length < 2), 'ARGUMENT_EXCEPTION: .get() requires 2 arguments.');
log(false, 'get() called:', {key: key});
try {
var now = Date.now();
Expand All @@ -66,7 +66,7 @@ function cacheModule(config){
* @param {integer} index
*/
self.mget = function(keys, cb, index){
checkMinParams((arguments.length < 2), 'ARGUMENT_EXCEPTION: .mget() requires 2 arguments.');
throwErrorIf((arguments.length < 2), 'ARGUMENT_EXCEPTION: .mget() requires 2 arguments.');
log(false, '.mget() called:', {keys: keys});
var values = {};
for(var i = 0; i < keys.length; i++){
Expand All @@ -89,7 +89,7 @@ function cacheModule(config){
* @param {function} cb
*/
self.set = function(){
checkMinParams((arguments.length < 2), 'ARGUMENT_EXCEPTION: .set() requires at least 2 arguments.');
throwErrorIf((arguments.length < 2), 'ARGUMENT_EXCEPTION: .set() requires at least 2 arguments.');
var key = arguments[0];
var value = arguments[1];
var expiration = arguments[2] || null;
Expand Down Expand Up @@ -121,7 +121,7 @@ function cacheModule(config){
* @param {function} cb
*/
self.mset = function(obj, expiration, cb){
checkMinParams((arguments.length < 1), 'ARGUMENT_EXCEPTION: .mset() requires at least 1 argument.');
throwErrorIf((arguments.length < 1), 'ARGUMENT_EXCEPTION: .mset() requires at least 1 argument.');
log(false, '.mset() called:', {data: obj});
for(key in obj){
if(obj.hasOwnProperty(key)){
Expand All @@ -143,7 +143,7 @@ function cacheModule(config){
* @param {function} cb
*/
self.del = function(keys, cb){
checkMinParams((arguments.length < 1), 'ARGUMENT_EXCEPTION: .del() requires at least 1 argument.');
throwErrorIf((arguments.length < 1), 'ARGUMENT_EXCEPTION: .del() requires at least 1 argument.');
log(false, '.del() called:', {keys: keys});
if(typeof keys === 'object'){
for(var i = 0; i < keys.length; i++){
Expand Down Expand Up @@ -186,7 +186,7 @@ function cacheModule(config){
storageKey = 'cache-module-storage-mock';
}
else{
var storageType = (config.storage && (config.storage === 'local' || config.storage === 'session')) ? config.storage : 'session';
var storageType = (config.storage === 'local') ? 'local' : 'session';
store = (typeof Storage !== void(0)) ? window[storageType + 'Storage'] : false;
storageKey = 'cache-module-' + storageType + '-storage';
}
Expand Down Expand Up @@ -216,11 +216,11 @@ function cacheModule(config){
}

/**
* Throw an error if insufficient arguments were provided
* Throw a given error if error is true
* @param {boolean} error
* @param {string} message
*/
function checkMinParams(error, message){
function throwErrorIf(error, message){
if(error) throw new Error(message);
}

Expand Down

0 comments on commit f2180bf

Please sign in to comment.