Isso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isso = (function(root){ | |
var value = undefined; | |
function isso(v){ | |
return (v)? new inner(v): ex; | |
} | |
function inner(v){ | |
this.value = v; | |
return this; | |
} | |
// Undefined? | |
inner.prototype.undef = function undef(){ | |
return (this.value === null || this.value === undefined); | |
} | |
// Defined? | |
inner.prototype.def = function def(){ | |
return !this.undef(); | |
} | |
inner.prototype.empty = function(){ | |
return (this.def() || this.value === {} || this.value === "" || this.value === []); | |
} | |
inner.prototype.falsy = function falsy(){ | |
return (this.undef() || this.empty() || this.value === 0 || this.value === false); | |
}; | |
inner.prototype.truthy = function truthy(){ | |
return !this.falsy(); | |
}; | |
inner.prototype.type = function type(){ | |
return Object.prototype.toString.call(this.value).slice(8, -1).toLowerCase(); | |
}; | |
var ex = { | |
extend: function(name, fn) { | |
inner.prototype[name] = fn; | |
} | |
}; | |
return isso; | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment