fd22b0bf58
V2 (Laravel re-make)
17 lines
421 B
JavaScript
Vendored
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);
|
|
}; |