/
validityChecks.js
128 lines (104 loc) · 3.99 KB
/
validityChecks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.__validityChecks = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
module.exports = {
checkCallbackStrict: require('./src/checkCallbackStrict'),
requiredParameter: require('./src/requiredParameter'),
isFunction: require('./src/isFunction'),
isObject: require('./src/isObject'),
isEmptyObject: require('./src/isEmptyObject'),
isString: require('./src/isString'),
isDate: require('./src/isDate')
};
},{"./src/checkCallbackStrict":2,"./src/isDate":3,"./src/isEmptyObject":4,"./src/isFunction":5,"./src/isObject":6,"./src/isString":7,"./src/requiredParameter":8}],2:[function(require,module,exports){
'use strict';
var isFunction = require('./isFunction');
/**
* Throws if the cb isnt passed or isnt a function
*
* @param {Function} cb
*/
module.exports = function checkCallback(cb) {
if (!isFunction(cb)) {
throw new Error('Please provide a callback fnc to this get (its async)');
}
};
},{"./isFunction":5}],3:[function(require,module,exports){
'use strict';
/**
* Returns if the param passed is an instanceof the Date object
*
* @param {Date} date
*/
module.exports = function isDate(date) {
return date instanceof Date;
};
},{}],4:[function(require,module,exports){
"use strict";
/**
* Checks to see if a passed in item is an empty
*
* http://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object
*
* @param {*} item
* @returns {boolean} isEmptyObject - is this value a pojo
*/
function isEmptyObject(item) {
if (item === undefined || item === null) {
return false;
}
return Object.keys(item).length === 0 && JSON.stringify(item) === JSON.stringify({});
}
module.exports = isEmptyObject;
},{}],5:[function(require,module,exports){
'use strict';
/**
* Returns false if the cb isnt passed or isnt a function
*
* @param {Function} fnc
*/
module.exports = function checkCallback(fnc) {
return !(!fnc || typeof fnc !== 'function');
};
},{}],6:[function(require,module,exports){
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
/**
* Checks to see if a passed in item is a pojo
*
* @param {*} item
* @returns {boolean} isObject - is this value a pojo
*/
function isObject(item) {
return (typeof item === 'undefined' ? 'undefined' : _typeof(item)) === 'object' && !Array.isArray(item) && item !== null;
}
module.exports = isObject;
},{}],7:[function(require,module,exports){
'use strict';
/**
* Checks to see if a passed in item is of type string
*
* @param {*} item
* @returns {boolean} isString - is this value a string
*/
function isString(item) {
return item !== null && typeof item === 'string';
}
module.exports = isString;
},{}],8:[function(require,module,exports){
'use strict';
function requiredParameter(name) {
throw new Error('Missing parameter "' + name + '"');
}
/**
* Supposed to be used in a default param for a function
* Example:
* (string = requiredParamater('string')) => {
*
* }
*
* if string is not passing this will throw an Error
* @param {string} nameOfParam
*/
module.exports = requiredParameter;
},{}]},{},[1])(1)
});