Skip to content

Instantly share code, notes, and snippets.

@ialpert
Created July 18, 2012 12:02
Show Gist options
  • Save ialpert/3135791 to your computer and use it in GitHub Desktop.
Save ialpert/3135791 to your computer and use it in GitHub Desktop.
paginate extension for lodash/underscore
_.paginate = function(arr, size) {
var pages = [];
size = size || this.length;
while (arr.length) {
pages.push(arr.splice(0, size));
}
return pages;
};
@jdalton
Copy link

jdalton commented Jul 20, 2012

To add this to the chaining API too you would want to use _.mixin.

_.mixin({
  'paginate': ...
});

@ialpert
Copy link
Author

ialpert commented Jul 23, 2012

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment