You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
421 B

4 years ago
  1. 'use strict';
  2. module.exports = function forPage(page, chunk) {
  3. var _this = this;
  4. var collection = {};
  5. if (Array.isArray(this.items)) {
  6. collection = this.items.slice(page * chunk - chunk, page * chunk);
  7. } else {
  8. Object.keys(this.items).slice(page * chunk - chunk, page * chunk).forEach(function (key) {
  9. collection[key] = _this.items[key];
  10. });
  11. }
  12. return new this.constructor(collection);
  13. };