Open mrDarcyMurphy opened 10 years ago
This has got to be one of the dumbest blocks of code I've ever written.
// ALIASES is.required = is.present is.eq = is.equal is.gt = is.greaterThan is.gte = is.greaterThanOrEqualTo is.lt = is.lessThan is.lte = is.lessThanOrEqualTo is.fn = is.func is.bool = is.boolean is.obj = is.object is.arr = is.array is.rx = is.regex is.str = is.string is.emtStr = is.emptyString is.numstr = is.numberString is.intstr = is.integerString is.num = is.number is.int = is.integer is.hex = is.hexadecimal is.hexStr = is.hexstr = is.hexadecimalString is.past = is.pastDate is.future = is.futureDate
I'm thinking something like…
var is = { VERSION: '2.0.0' } is.fn = is.func = function(x) { // ... do stuff }
But that seems equally verbose and dumb. Maybe something more declarative…
var methodAliases = { 'func': ['fn'], 'required': ['present'] } // pseudocode for (method in methodAliases) { methodAliases[method].forEach(function(alias){ is[alias] = is[method] }) }
Or I could just ditch the alias concept altogether.
This has got to be one of the dumbest blocks of code I've ever written.
I'm thinking something like…
But that seems equally verbose and dumb. Maybe something more declarative…
Or I could just ditch the alias concept altogether.