Created
June 15, 2010 21:09
-
-
Save FGRibreau/439739 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Do this only one time ! | |
makeChainable(console, 'assert clear count debug dir dirxml error exception group groupCollapsed groupEnd info log profile profileEnd time timeEnd warn'.split(' ')); | |
//Usage: | |
console | |
.profile() | |
.time('testTime') | |
.group('GroupTest') | |
.debug('test', 1, 2, 3) | |
.warn('warniiing!') | |
.log('loo', true) | |
.dir([1, 2, 3, 4]) | |
.info('plop') | |
.groupEnd('GroupTest') | |
.timeEnd('testTime') | |
.profileEnd(); |
This file contains hidden or 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 makeChainable = function(obj, method) { | |
var m = Object.prototype.toString.call(method) === "[object Array]" ? method: [method], | |
i = m.length; | |
while (i--) { | |
obj[m[i]] = function(o) { | |
return function() { | |
o.apply(this, arguments); | |
return this; | |
} | |
} (obj[m[i]]); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment