Created
July 18, 2012 12:02
-
-
Save ialpert/3135791 to your computer and use it in GitHub Desktop.
paginate extension for lodash/underscore
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
_.paginate = function(arr, size) { | |
var pages = []; | |
size = size || this.length; | |
while (arr.length) { | |
pages.push(arr.splice(0, size)); | |
} | |
return pages; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To add this to the chaining API too you would want to use
_.mixin
.