Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. this.data = function(data) {
  2. this.modifiedData = data;
  3.  
  4. this.page = function(startIndex, limit) {
  5. this.modifiedData = this.modifiedData.slice(startIndex, startIndex + limit);
  6. return this;
  7. };
  8.  
  9. this.sortBy = function(field, sortAsc, primer) {
  10.  
  11. var key = primer ?
  12. function(x) { return primer(x[field]); } :
  13. function(x) { return x[field]; };
  14.  
  15. var sortExpression = function(a, b) {
  16. return a = key(a), b = key(b), sortAsc * ((a > b) - (b > a));
  17. }
  18.  
  19. this.modifiedData = this.modifiedData.sort(sortExpression);
  20. return this;
  21. };
  22.  
  23. this.filter = function(filters) {
  24.  
  25. return this;
  26. };
  27.  
  28. this.save = function() {
  29. return this.modifiedData;
  30. }
  31.  
  32. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement