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.

17 lines
421 B

4 years ago
'use strict';
module.exports = function forPage(page, chunk) {
var _this = this;
var collection = {};
if (Array.isArray(this.items)) {
collection = this.items.slice(page * chunk - chunk, page * chunk);
} else {
Object.keys(this.items).slice(page * chunk - chunk, page * chunk).forEach(function (key) {
collection[key] = _this.items[key];
});
}
return new this.constructor(collection);
};