Created
February 9, 2015 02:32
-
-
Save brigand/22edd5812be0c1158a00 to your computer and use it in GitHub Desktop.
jquery fn vs commonjs
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
| // 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