Created
February 3, 2010 07:44
-
-
Save josher19/293452 to your computer and use it in GitHub Desktop.
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 proplist = _.keys(_); | |
var undef | |
proplist.push(undef); | |
proplist.push(null); | |
proplist = proplist.concat(proplist); | |
// proplist.push(proplist); | |
_.isNewFunction = function (obj) { return typeof obj === 'function' } | |
_.isA = function isA(o,c) {return o==null ? o===c : (o.constructor===c || ( _.isFunction(c) && o instanceof c));} | |
_.isA_t = function isA(o,c) {return o==null ? o===c : (o.constructor===c || ( typeof c === "function" && o instanceof c));} | |
_.isA_min = function isA(o,c) {return o==null ? o===c : (o.constructor===c || o instanceof c);} | |
// select all elements that match a regex | |
_.grep = function(obj,re) { | |
return _.select(obj, function(s){ var s =_.isString(s)?s:new String(s); return s.match(re) }); | |
}; | |
_.grep_t = function(obj,re) { | |
return _.select(obj, function(s){ var s = (typeof s === "string")?s:new String(s); return s.match(re) }); | |
}; | |
JSLitmus.test('_.isNewFunction()', function() { | |
return _.select(proplist, function(prop) { return _.isNewFunction(_[prop]) }) | |
}); | |
JSLitmus.test('_.isFunction()', function() { | |
return _.select(proplist, function(prop){ return _.isFunction(_[prop]) }) | |
}); | |
JSLitmus.test('_.isA', function() { | |
return _.select(proplist, function(prop) { return _.isA(_[prop], Function) }) | |
}); | |
JSLitmus.test('_.isA_t', function() { | |
return _.select(proplist, function(prop) { return _.isA_t(_[prop], Function) }) | |
}); | |
JSLitmus.test('_.isA_min', function() { | |
return _.select(proplist, function(prop) { return _.isA_min(_[prop], Function) }) | |
}); | |
JSLitmus.test('_.grep', function() { | |
return _.grep( proplist, /^is/ ) | |
}); | |
JSLitmus.test('_.grep_t', function() { | |
return _.grep_t( proplist, /^is/ ) | |
}); | |
JSLitmus.test('_.functions', function() { | |
return _.functions( _ ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment