Skip to content

Instantly share code, notes, and snippets.

@josephdburdick
Forked from brigand/gist:22edd5812be0c1158a00
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save josephdburdick/d6e1806540b629c72d71 to your computer and use it in GitHub Desktop.

Select an option

Save josephdburdick/d6e1806540b629c72d71 to your computer and use it in GitHub Desktop.
// non-modular
jQuery.fn.limit = function(count){
return $(this).filter(function(index){ return index < count; });
};
// non-modular usage
$('sel').limit(3);
// modular
var $ = require('jquery');
var limit = function(count){
return $(this).filter(function(index){ return index < count; });
};
module.exports = Function.call.bind(limit);
// modular usage
var limit = require('./plugins/limit');
limit($('sel'), 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment