JSFiddle - React, Tailwind, and code Playground
by st3fan
JavaScript
var assert = function(test, result, expected) {
var passed = result === expected;
console.log(test, passed ? 'PASSED' : 'ERROR');
};
_.mixin({
isNullOrEmpty: function(obj) {
return _.isNull(obj) || _.isEmpty(obj);
},
isNullOrWhitespace: function(str) {
return _.isNullOrEmpty(str.trim());
}
});
// Preperations
// Tests
assert('isNullOrEmpty A', _.isNullOrEmpty(''), true);
assert('isNullOrEmpty B', _.isNullOrEmpty(null), true);
assert('isNullOrEmpty C', _.isNullOrEmpty(), true);
assert('isNullOrEmpty D', _.isNullOrEmpty('abc'), false);
assert('isNullOrEmpty E', _.isNullOrEmpty(' '), false);
assert('isNullOrWhitespace A', _.isNullOrWhitespace(' '), true);
assert('isNullOrWhitespace B', _.isNullOrWhitespace(' '), true);