Skip to content

Instantly share code, notes, and snippets.

@zenparsing
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zenparsing/fe0298cee7e6fd023370 to your computer and use it in GitHub Desktop.
Save zenparsing/fe0298cee7e6fd023370 to your computer and use it in GitHub Desktop.
jquery direct
(function($) { "use strict";
function wrap(method) {
return function() {
var jq = $(this),
result = jq[method].apply(jq, arguments);
if (result && result.constructor === $)
result = result.toArray();
return result;
};
}
function wrapAll(out) {
var x = $();
for (var name in x)
if (typeof x[name] === "function")
out[name] = wrap(name);
return out;
}
wrapAll(window.jake = {});
})($);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment