Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.data = function(data) {
- this.modifiedData = data;
- this.page = function(startIndex, limit) {
- this.modifiedData = this.modifiedData.slice(startIndex, startIndex + limit);
- return this;
- };
- this.sortBy = function(field, sortAsc, primer) {
- var key = primer ?
- function(x) { return primer(x[field]); } :
- function(x) { return x[field]; };
- var sortExpression = function(a, b) {
- return a = key(a), b = key(b), sortAsc * ((a > b) - (b > a));
- }
- this.modifiedData = this.modifiedData.sort(sortExpression);
- return this;
- };
- this.filter = function(filters) {
- return this;
- };
- this.save = function() {
- return this.modifiedData;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement