my-idlers/node_modules/collect.js/dist/methods/forPage.js
cp6 fd22b0bf58 V2 (Laravel re-make)
V2 (Laravel re-make)
2022-03-06 02:02:12 +11:00

17 lines
421 B
JavaScript
Vendored

'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);
};