@matrixai/pagination
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -1,2 +0,2 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([,function(e,t,r){"use strict";function n(e,t){if(!0===e.order){const r=null!=t?t:e.limit;return{order:!0,seek:e.seek,limit:r}}if(!1===e.order){const r=null!=t?t:e.limit;return{order:!1,seek:e.seek,limit:r}}return{order:null,seekAfter:e.seekAfter,seekBefore:e.seekBefore}}function o(e,t){let r;return r=null===e.order?null!=t?t:e.count:null!=t?t:e.limit,{order:!1,seek:e.seekFirst,limit:r}}function u(e,t){let r;return r=null===e.order?null!=t?t:e.count:null!=t?t:e.limit,{order:!0,seek:e.seekLast,limit:r}}function i(e,t,r){return l(t,n(e,r))}function s(e,t,r){return l(t,o(e,r))}function f(e,t,r){return l(t,u(e,r))}function l(e,t){let r;return(r=null===t.order?e(t.order,t.seekAfter,t.seekBefore):e(t.order,t.seek,t.limit))instanceof Promise?r.then(e=>Object.assign(Object.assign({},t),{count:e.count,seekFirst:e.seekFirst,seekLast:e.seekLast,items:e.items})):Object.assign(Object.assign({},t),{count:r.count,seekFirst:r.seekFirst,seekLast:r.seekLast,items:r.items})}r.r(t),r.d(t,"pageCurr",(function(){return n})),r.d(t,"pagePrev",(function(){return o})),r.d(t,"pageNext",(function(){return u})),r.d(t,"pageCurrM",(function(){return i})),r.d(t,"pagePrevM",(function(){return s})),r.d(t,"pageNextM",(function(){return f}))}])})); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([,function(e,t,r){"use strict";function n(e,t){if(!0===e.order){const r=null!=t?t:e.limit;return{order:!0,seek:e.seek,limit:r}}if(!1===e.order){const r=null!=t?t:e.limit;return{order:!1,seek:e.seek,limit:r}}return{order:null,seekAfter:e.seekAfter,seekBefore:e.seekBefore}}function o(e,t){let r;return r=null===e.order?null!=t?t:e.length:null!=t?t:e.limit,{order:!1,seek:e.seekFirst,limit:r}}function i(e,t){let r;return r=null===e.order?null!=t?t:e.length:null!=t?t:e.limit,{order:!0,seek:e.seekLast,limit:r}}function u(e,t,r){return f(t,n(e,r))}function s(e,t,r){return f(t,o(e,r))}function l(e,t,r){return f(t,i(e,r))}function f(e,t){let r;return(r=null===t.order?e(t.order,t.seekAfter,t.seekBefore):e(t.order,t.seek,t.limit))instanceof Promise?r.then(e=>Object.assign(Object.assign({},t),{length:e.length,seekFirst:e.seekFirst,seekLast:e.seekLast,items:e.items})):Object.assign(Object.assign({},t),{length:r.length,seekFirst:r.seekFirst,seekLast:r.seekLast,items:r.items})}r.r(t),r.d(t,"pageCurr",(function(){return n})),r.d(t,"pagePrev",(function(){return o})),r.d(t,"pageNext",(function(){return i})),r.d(t,"pageCurrM",(function(){return u})),r.d(t,"pagePrevM",(function(){return s})),r.d(t,"pageNextM",(function(){return l}))}])})); | ||
//# sourceMappingURL=Cursor.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var u=t[r]={i:r,l:!1,exports:{}};return e[r].call(u.exports,u,u.exports,n),u.l=!0,u.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)n.d(r,u,function(t){return e[t]}.bind(null,u));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";function r(e,t){return Math.floor(e/t)}function u(e,t){return Math.ceil(e/t)}function i(e){return 0===e}function o(e,t){return e===t-1}function c(e){return Array.from({length:e},(e,t)=>t+1)}function*f(e){for(let t=1;t<=e;++t)yield t}function s(e,t){const n=null!=t?t:e.limit;return{seek:r(e.seek,n)*n,limit:n}}function l(e,t,n){return C(t,s(e,n))}function a(e,t){const n=null!=t?t:e.limit;return{seek:e.seek,limit:n}}function d(e,t,n){return C(t,a(e,n))}function p(e,t){const n=null!=t?t:e.limit;let u=r(e.seek,n);return{seek:(u=Math.max(u-1,0))*n,limit:n}}function m(e,t,n){return C(t,p(e,n))}function g(e,t){const n=null!=t?t:e.limit;return{seek:e.seek-n,limit:n}}function k(e,t,n){return C(t,g(e,n))}function b(e,t){const n=null!=t?t:e.limit;let u=r(e.seek,n);return{seek:(u+=1)*n,limit:n}}function M(e,t,n){return C(t,b(e,n))}function x(e,t){const n=null!=t?t:e.limit;return{seek:e.seek+n,limit:n}}function j(e,t,n){return C(t,x(e,n))}function v(e,t,n){const u=null!=n?n:e.limit;let i=r(t,u);return{seek:(i=Math.max(i,0))*u,limit:u}}function y(e,t,n,r){return C(t,v(e,n,r))}function O(e,t,n){return{seek:t,limit:null!=n?n:e.limit}}function w(e,t,n,r){return C(t,O(e,n,r))}function P(e,t,n){const r=null!=n?n:e.limit;return{seek:Math.max(t,0)*r,limit:r}}function h(e,t,n,r){return C(t,P(e,n,r))}function R(e,t,n){const r=null!=n?n:e.limit;return{seek:Math.max(t,0)*e.limit,limit:r}}function S(e,t,n,r){return C(t,R(e,n,r))}function C(e,t){const n=e(t.seek,t.limit);return n instanceof Promise?n.then(e=>Object.assign(Object.assign({},t),{total:e.total,count:e.count,items:e.items})):Object.assign(Object.assign({},t),{total:n.total,count:n.count,items:n.items})}n.r(t),n.d(t,"pageIndex",(function(){return r})),n.d(t,"pageCount",(function(){return u})),n.d(t,"pageFirst",(function(){return i})),n.d(t,"pageLast",(function(){return o})),n.d(t,"pages",(function(){return c})),n.d(t,"pagesI",(function(){return f})),n.d(t,"pageCurr",(function(){return s})),n.d(t,"pageCurrM",(function(){return l})),n.d(t,"pageCurrRaw",(function(){return a})),n.d(t,"pageCurrRawM",(function(){return d})),n.d(t,"pagePrev",(function(){return p})),n.d(t,"pagePrevM",(function(){return m})),n.d(t,"pagePrevRaw",(function(){return g})),n.d(t,"pagePrevRawM",(function(){return k})),n.d(t,"pageNext",(function(){return b})),n.d(t,"pageNextM",(function(){return M})),n.d(t,"pageNextRaw",(function(){return x})),n.d(t,"pageNextRawM",(function(){return j})),n.d(t,"pageSeek",(function(){return v})),n.d(t,"pageSeekM",(function(){return y})),n.d(t,"pageSeekRaw",(function(){return O})),n.d(t,"pageSeekRawM",(function(){return w})),n.d(t,"pageJump",(function(){return P})),n.d(t,"pageJumpM",(function(){return h})),n.d(t,"pageJumpRaw",(function(){return R})),n.d(t,"pageJumpRawM",(function(){return S}))},function(e,t,n){"use strict";function r(e,t){if(!0===e.order){const n=null!=t?t:e.limit;return{order:!0,seek:e.seek,limit:n}}if(!1===e.order){const n=null!=t?t:e.limit;return{order:!1,seek:e.seek,limit:n}}return{order:null,seekAfter:e.seekAfter,seekBefore:e.seekBefore}}function u(e,t){let n;return n=null===e.order?null!=t?t:e.count:null!=t?t:e.limit,{order:!1,seek:e.seekFirst,limit:n}}function i(e,t){let n;return n=null===e.order?null!=t?t:e.count:null!=t?t:e.limit,{order:!0,seek:e.seekLast,limit:n}}function o(e,t,n){return s(t,r(e,n))}function c(e,t,n){return s(t,u(e,n))}function f(e,t,n){return s(t,i(e,n))}function s(e,t){let n;return(n=null===t.order?e(t.order,t.seekAfter,t.seekBefore):e(t.order,t.seek,t.limit))instanceof Promise?n.then(e=>Object.assign(Object.assign({},t),{count:e.count,seekFirst:e.seekFirst,seekLast:e.seekLast,items:e.items})):Object.assign(Object.assign({},t),{count:n.count,seekFirst:n.seekFirst,seekLast:n.seekLast,items:n.items})}n.r(t),n.d(t,"pageCurr",(function(){return r})),n.d(t,"pagePrev",(function(){return u})),n.d(t,"pageNext",(function(){return i})),n.d(t,"pageCurrM",(function(){return o})),n.d(t,"pagePrevM",(function(){return c})),n.d(t,"pageNextM",(function(){return f}))},function(e,t,n){"use strict";n.r(t);var r=n(0);n.d(t,"Offset",(function(){return r}));var u=n(1);n.d(t,"Cursor",(function(){return u}))}])})); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var u=t[r]={i:r,l:!1,exports:{}};return e[r].call(u.exports,u,u.exports,n),u.l=!0,u.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)n.d(r,u,function(t){return e[t]}.bind(null,u));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";function r(e,t){return Math.floor(e/t)}function u(e,t){return Math.ceil(e/t)}function i(e){return 0===e}function o(e,t){return e===t-1}function c(e){return Array.from({length:e},(e,t)=>t+1)}function*f(e){for(let t=1;t<=e;++t)yield t}function l(e,t){const n=null!=t?t:e.limit;return{seek:r(e.seek,n)*n,limit:n}}function s(e,t,n){return C(t,l(e,n))}function a(e,t){const n=null!=t?t:e.limit;return{seek:e.seek,limit:n}}function d(e,t,n){return C(t,a(e,n))}function p(e,t){const n=null!=t?t:e.limit;let u=r(e.seek,n);return{seek:(u=Math.max(u-1,0))*n,limit:n}}function m(e,t,n){return C(t,p(e,n))}function g(e,t){const n=null!=t?t:e.limit;return{seek:e.seek-n,limit:n}}function k(e,t,n){return C(t,g(e,n))}function b(e,t){const n=null!=t?t:e.limit;let u=r(e.seek,n);return{seek:(u+=1)*n,limit:n}}function M(e,t,n){return C(t,b(e,n))}function h(e,t){const n=null!=t?t:e.limit;return{seek:e.seek+n,limit:n}}function x(e,t,n){return C(t,h(e,n))}function j(e,t,n){const u=null!=n?n:e.limit;let i=r(t,u);return{seek:(i=Math.max(i,0))*u,limit:u}}function v(e,t,n,r){return C(t,j(e,n,r))}function y(e,t,n){return{seek:t,limit:null!=n?n:e.limit}}function O(e,t,n,r){return C(t,y(e,n,r))}function w(e,t,n){const r=null!=n?n:e.limit;return{seek:Math.max(t,0)*r,limit:r}}function P(e,t,n,r){return C(t,w(e,n,r))}function R(e,t,n){const r=null!=n?n:e.limit;return{seek:Math.max(t,0)*e.limit,limit:r}}function S(e,t,n,r){return C(t,R(e,n,r))}function C(e,t){const n=e(t.seek,t.limit);return n instanceof Promise?n.then(e=>Object.assign(Object.assign({},t),{total:e.total,length:e.length,items:e.items})):Object.assign(Object.assign({},t),{total:n.total,length:n.length,items:n.items})}n.r(t),n.d(t,"pageIndex",(function(){return r})),n.d(t,"pageCount",(function(){return u})),n.d(t,"pageFirst",(function(){return i})),n.d(t,"pageLast",(function(){return o})),n.d(t,"pages",(function(){return c})),n.d(t,"pagesI",(function(){return f})),n.d(t,"pageCurr",(function(){return l})),n.d(t,"pageCurrM",(function(){return s})),n.d(t,"pageCurrRaw",(function(){return a})),n.d(t,"pageCurrRawM",(function(){return d})),n.d(t,"pagePrev",(function(){return p})),n.d(t,"pagePrevM",(function(){return m})),n.d(t,"pagePrevRaw",(function(){return g})),n.d(t,"pagePrevRawM",(function(){return k})),n.d(t,"pageNext",(function(){return b})),n.d(t,"pageNextM",(function(){return M})),n.d(t,"pageNextRaw",(function(){return h})),n.d(t,"pageNextRawM",(function(){return x})),n.d(t,"pageSeek",(function(){return j})),n.d(t,"pageSeekM",(function(){return v})),n.d(t,"pageSeekRaw",(function(){return y})),n.d(t,"pageSeekRawM",(function(){return O})),n.d(t,"pageJump",(function(){return w})),n.d(t,"pageJumpM",(function(){return P})),n.d(t,"pageJumpRaw",(function(){return R})),n.d(t,"pageJumpRawM",(function(){return S}))},function(e,t,n){"use strict";function r(e,t){if(!0===e.order){const n=null!=t?t:e.limit;return{order:!0,seek:e.seek,limit:n}}if(!1===e.order){const n=null!=t?t:e.limit;return{order:!1,seek:e.seek,limit:n}}return{order:null,seekAfter:e.seekAfter,seekBefore:e.seekBefore}}function u(e,t){let n;return n=null===e.order?null!=t?t:e.length:null!=t?t:e.limit,{order:!1,seek:e.seekFirst,limit:n}}function i(e,t){let n;return n=null===e.order?null!=t?t:e.length:null!=t?t:e.limit,{order:!0,seek:e.seekLast,limit:n}}function o(e,t,n){return l(t,r(e,n))}function c(e,t,n){return l(t,u(e,n))}function f(e,t,n){return l(t,i(e,n))}function l(e,t){let n;return(n=null===t.order?e(t.order,t.seekAfter,t.seekBefore):e(t.order,t.seek,t.limit))instanceof Promise?n.then(e=>Object.assign(Object.assign({},t),{length:e.length,seekFirst:e.seekFirst,seekLast:e.seekLast,items:e.items})):Object.assign(Object.assign({},t),{length:n.length,seekFirst:n.seekFirst,seekLast:n.seekLast,items:n.items})}n.r(t),n.d(t,"pageCurr",(function(){return r})),n.d(t,"pagePrev",(function(){return u})),n.d(t,"pageNext",(function(){return i})),n.d(t,"pageCurrM",(function(){return o})),n.d(t,"pagePrevM",(function(){return c})),n.d(t,"pageNextM",(function(){return f}))},function(e,t,n){"use strict";n.r(t);var r=n(0);n.d(t,"Offset",(function(){return r}));var u=n(1);n.d(t,"Cursor",(function(){return u}))}])})); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e=t();for(var r in e)("object"==typeof exports?exports:n)[r]=e[r]}}(window,(function(){return function(n){var t={};function e(r){if(t[r])return t[r].exports;var u=t[r]={i:r,l:!1,exports:{}};return n[r].call(u.exports,u,u.exports,e),u.l=!0,u.exports}return e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:r})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var u in n)e.d(r,u,function(t){return n[t]}.bind(null,u));return r},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e(e.s=0)}([function(n,t,e){"use strict";function r(n,t){return Math.floor(n/t)}function u(n,t){return Math.ceil(n/t)}function i(n){return 0===n}function o(n,t){return n===t-1}function c(n){return Array.from({length:n},(n,t)=>t+1)}function*f(n){for(let t=1;t<=n;++t)yield t}function l(n,t){const e=null!=t?t:n.limit;return{seek:r(n.seek,e)*e,limit:e}}function a(n,t,e){return _(t,l(n,e))}function s(n,t){const e=null!=t?t:n.limit;return{seek:n.seek,limit:e}}function p(n,t,e){return _(t,s(n,e))}function d(n,t){const e=null!=t?t:n.limit;let u=r(n.seek,e);return{seek:(u=Math.max(u-1,0))*e,limit:e}}function m(n,t,e){return _(t,d(n,e))}function g(n,t){const e=null!=t?t:n.limit;return{seek:n.seek-e,limit:e}}function k(n,t,e){return _(t,g(n,e))}function b(n,t){const e=null!=t?t:n.limit;let u=r(n.seek,e);return{seek:(u+=1)*e,limit:e}}function M(n,t,e){return _(t,b(n,e))}function x(n,t){const e=null!=t?t:n.limit;return{seek:n.seek+e,limit:e}}function y(n,t,e){return _(t,x(n,e))}function j(n,t,e){const u=null!=e?e:n.limit;let i=r(t,u);return{seek:(i=Math.max(i,0))*u,limit:u}}function v(n,t,e,r){return _(t,j(n,e,r))}function w(n,t,e){return{seek:t,limit:null!=e?e:n.limit}}function O(n,t,e,r){return _(t,w(n,e,r))}function P(n,t,e){const r=null!=e?e:n.limit;return{seek:Math.max(t,0)*r,limit:r}}function R(n,t,e,r){return _(t,P(n,e,r))}function h(n,t,e){const r=null!=e?e:n.limit;return{seek:Math.max(t,0)*n.limit,limit:r}}function S(n,t,e,r){return _(t,h(n,e,r))}function _(n,t){const e=n(t.seek,t.limit);return e instanceof Promise?e.then(n=>Object.assign(Object.assign({},t),{total:n.total,count:n.count,items:n.items})):Object.assign(Object.assign({},t),{total:e.total,count:e.count,items:e.items})}e.r(t),e.d(t,"pageIndex",(function(){return r})),e.d(t,"pageCount",(function(){return u})),e.d(t,"pageFirst",(function(){return i})),e.d(t,"pageLast",(function(){return o})),e.d(t,"pages",(function(){return c})),e.d(t,"pagesI",(function(){return f})),e.d(t,"pageCurr",(function(){return l})),e.d(t,"pageCurrM",(function(){return a})),e.d(t,"pageCurrRaw",(function(){return s})),e.d(t,"pageCurrRawM",(function(){return p})),e.d(t,"pagePrev",(function(){return d})),e.d(t,"pagePrevM",(function(){return m})),e.d(t,"pagePrevRaw",(function(){return g})),e.d(t,"pagePrevRawM",(function(){return k})),e.d(t,"pageNext",(function(){return b})),e.d(t,"pageNextM",(function(){return M})),e.d(t,"pageNextRaw",(function(){return x})),e.d(t,"pageNextRawM",(function(){return y})),e.d(t,"pageSeek",(function(){return j})),e.d(t,"pageSeekM",(function(){return v})),e.d(t,"pageSeekRaw",(function(){return w})),e.d(t,"pageSeekRawM",(function(){return O})),e.d(t,"pageJump",(function(){return P})),e.d(t,"pageJumpM",(function(){return R})),e.d(t,"pageJumpRaw",(function(){return h})),e.d(t,"pageJumpRawM",(function(){return S}))}])})); | ||
!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e=t();for(var r in e)("object"==typeof exports?exports:n)[r]=e[r]}}(window,(function(){return function(n){var t={};function e(r){if(t[r])return t[r].exports;var u=t[r]={i:r,l:!1,exports:{}};return n[r].call(u.exports,u,u.exports,e),u.l=!0,u.exports}return e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:r})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var u in n)e.d(r,u,function(t){return n[t]}.bind(null,u));return r},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e(e.s=0)}([function(n,t,e){"use strict";function r(n,t){return Math.floor(n/t)}function u(n,t){return Math.ceil(n/t)}function i(n){return 0===n}function o(n,t){return n===t-1}function c(n){return Array.from({length:n},(n,t)=>t+1)}function*f(n){for(let t=1;t<=n;++t)yield t}function l(n,t){const e=null!=t?t:n.limit;return{seek:r(n.seek,e)*e,limit:e}}function a(n,t,e){return _(t,l(n,e))}function s(n,t){const e=null!=t?t:n.limit;return{seek:n.seek,limit:e}}function p(n,t,e){return _(t,s(n,e))}function d(n,t){const e=null!=t?t:n.limit;let u=r(n.seek,e);return{seek:(u=Math.max(u-1,0))*e,limit:e}}function m(n,t,e){return _(t,d(n,e))}function g(n,t){const e=null!=t?t:n.limit;return{seek:n.seek-e,limit:e}}function k(n,t,e){return _(t,g(n,e))}function b(n,t){const e=null!=t?t:n.limit;let u=r(n.seek,e);return{seek:(u+=1)*e,limit:e}}function M(n,t,e){return _(t,b(n,e))}function x(n,t){const e=null!=t?t:n.limit;return{seek:n.seek+e,limit:e}}function y(n,t,e){return _(t,x(n,e))}function j(n,t,e){const u=null!=e?e:n.limit;let i=r(t,u);return{seek:(i=Math.max(i,0))*u,limit:u}}function v(n,t,e,r){return _(t,j(n,e,r))}function h(n,t,e){return{seek:t,limit:null!=e?e:n.limit}}function w(n,t,e,r){return _(t,h(n,e,r))}function O(n,t,e){const r=null!=e?e:n.limit;return{seek:Math.max(t,0)*r,limit:r}}function P(n,t,e,r){return _(t,O(n,e,r))}function R(n,t,e){const r=null!=e?e:n.limit;return{seek:Math.max(t,0)*n.limit,limit:r}}function S(n,t,e,r){return _(t,R(n,e,r))}function _(n,t){const e=n(t.seek,t.limit);return e instanceof Promise?e.then(n=>Object.assign(Object.assign({},t),{total:n.total,length:n.length,items:n.items})):Object.assign(Object.assign({},t),{total:e.total,length:e.length,items:e.items})}e.r(t),e.d(t,"pageIndex",(function(){return r})),e.d(t,"pageCount",(function(){return u})),e.d(t,"pageFirst",(function(){return i})),e.d(t,"pageLast",(function(){return o})),e.d(t,"pages",(function(){return c})),e.d(t,"pagesI",(function(){return f})),e.d(t,"pageCurr",(function(){return l})),e.d(t,"pageCurrM",(function(){return a})),e.d(t,"pageCurrRaw",(function(){return s})),e.d(t,"pageCurrRawM",(function(){return p})),e.d(t,"pagePrev",(function(){return d})),e.d(t,"pagePrevM",(function(){return m})),e.d(t,"pagePrevRaw",(function(){return g})),e.d(t,"pagePrevRawM",(function(){return k})),e.d(t,"pageNext",(function(){return b})),e.d(t,"pageNextM",(function(){return M})),e.d(t,"pageNextRaw",(function(){return x})),e.d(t,"pageNextRawM",(function(){return y})),e.d(t,"pageSeek",(function(){return j})),e.d(t,"pageSeekM",(function(){return v})),e.d(t,"pageSeekRaw",(function(){return h})),e.d(t,"pageSeekRawM",(function(){return w})),e.d(t,"pageJump",(function(){return O})),e.d(t,"pageJumpM",(function(){return P})),e.d(t,"pageJumpRaw",(function(){return R})),e.d(t,"pageJumpRawM",(function(){return S}))}])})); | ||
//# sourceMappingURL=Offset.js.map |
/** | ||
* Cursor pagination | ||
* | ||
* @remarks | ||
* | ||
* Cursor pagination relies on unique orderable seek key. | ||
* | ||
* Consider the resource we are paginating is: | ||
* | ||
* ```ts | ||
* ['A', 'B', 'C', 'D'] | ||
* ``` | ||
* | ||
* Assume that the seek key is `[0, 1, 2, 3]`. | ||
* Using `order = true`, `seek = 0` and `limit = 2`, you would get `['B', 'C']`. | ||
* Using `order = false`, `seek = 2` and `limit = 2`, you would get `['A', 'B']`. | ||
* Using `order = null`, `seekAfter = 1`, `seekBefore = 3`, you would get `['C']`. | ||
* | ||
* Cursor pagination does not allow random access of the pages. | ||
* You can however randomly access if you know the seek key you want. | ||
*/ | ||
@@ -26,3 +8,3 @@ declare type Pagination<I extends Iterable<[S, any]>, S> = Readonly<{ | ||
limit: number; | ||
count: number; | ||
length: number; | ||
seekFirst: S; | ||
@@ -35,3 +17,3 @@ seekLast: S; | ||
limit: number; | ||
count: number; | ||
length: number; | ||
seekFirst: S; | ||
@@ -46,3 +28,3 @@ seekLast: S; | ||
seekLast: S; | ||
count: number; | ||
length: number; | ||
items: I; | ||
@@ -69,3 +51,3 @@ }>; | ||
declare type ActionResult<I, S> = Readonly<{ | ||
count: number; | ||
length: number; | ||
seekFirst: S; | ||
@@ -72,0 +54,0 @@ seekLast: S; |
@@ -103,20 +103,2 @@ module.exports = | ||
* Cursor pagination | ||
* | ||
* @remarks | ||
* | ||
* Cursor pagination relies on unique orderable seek key. | ||
* | ||
* Consider the resource we are paginating is: | ||
* | ||
* ```ts | ||
* ['A', 'B', 'C', 'D'] | ||
* ``` | ||
* | ||
* Assume that the seek key is `[0, 1, 2, 3]`. | ||
* Using `order = true`, `seek = 0` and `limit = 2`, you would get `['B', 'C']`. | ||
* Using `order = false`, `seek = 2` and `limit = 2`, you would get `['A', 'B']`. | ||
* Using `order = null`, `seekAfter = 1`, `seekBefore = 3`, you would get `['C']`. | ||
* | ||
* Cursor pagination does not allow random access of the pages. | ||
* You can however randomly access if you know the seek key you want. | ||
*/ | ||
@@ -151,3 +133,3 @@ function pageCurr(page, limit) { | ||
if (page.order === null) { | ||
limitNew = (limit != null) ? limit : page.count; | ||
limitNew = (limit != null) ? limit : page.length; | ||
} | ||
@@ -166,3 +148,3 @@ else { | ||
if (page.order === null) { | ||
limitNew = (limit != null) ? limit : page.count; | ||
limitNew = (limit != null) ? limit : page.length; | ||
} | ||
@@ -199,6 +181,6 @@ else { | ||
if (result instanceof Promise) { | ||
return result.then((result_) => (Object.assign(Object.assign({}, patch), { count: result_.count, seekFirst: result_.seekFirst, seekLast: result_.seekLast, items: result_.items }))); | ||
return result.then((result_) => (Object.assign(Object.assign({}, patch), { length: result_.length, seekFirst: result_.seekFirst, seekLast: result_.seekLast, items: result_.items }))); | ||
} | ||
else { | ||
return Object.assign(Object.assign({}, patch), { count: result.count, seekFirst: result.seekFirst, seekLast: result.seekLast, items: result.items }); | ||
return Object.assign(Object.assign({}, patch), { length: result.length, seekFirst: result.seekFirst, seekLast: result.seekLast, items: result.items }); | ||
} | ||
@@ -205,0 +187,0 @@ } |
@@ -122,24 +122,2 @@ module.exports = | ||
* Offset pagination | ||
* | ||
* @remarks | ||
* | ||
* Offset pagination relies on a seek and limit number. | ||
* | ||
* Consider the resource we are paginating is: | ||
* | ||
* ```ts | ||
* ['A', 'B', 'C', 'D'] | ||
* ``` | ||
* | ||
* The seek index starts at 0. | ||
* The limit is entire length of the returned pagination view. | ||
* A seek and limit of `[0, 2]` would return `['A', 'B']`. | ||
* | ||
* The page numbers start at 1. So by using `[0, 2]` | ||
* we get page numbers of `[1, 2]`. We still refer to these numbers | ||
* with the page index. | ||
* | ||
* Note that the total represents the total number of items | ||
* when the pagination was fetched. The true total of items may have | ||
* changed on the server side since fetching a pagination. | ||
*/ | ||
@@ -158,7 +136,7 @@ function pageIndex(seek, limit) { | ||
} | ||
function pages(pageCount) { | ||
return Array.from({ length: pageCount }, (_, i) => i + 1); | ||
function pages(count) { | ||
return Array.from({ length: count }, (_, i) => i + 1); | ||
} | ||
function* pagesI(pageCount) { | ||
for (let i = 1; i <= pageCount; ++i) { | ||
function* pagesI(count) { | ||
for (let i = 1; i <= count; ++i) { | ||
yield i; | ||
@@ -271,7 +249,7 @@ } | ||
return result.then((result_) => { | ||
return Object.assign(Object.assign({}, patch), { total: result_.total, count: result_.count, items: result_.items }); | ||
return Object.assign(Object.assign({}, patch), { total: result_.total, length: result_.length, items: result_.items }); | ||
}); | ||
} | ||
else { | ||
return Object.assign(Object.assign({}, patch), { total: result.total, count: result.count, items: result.items }); | ||
return Object.assign(Object.assign({}, patch), { total: result.total, length: result.length, items: result.items }); | ||
} | ||
@@ -296,20 +274,2 @@ } | ||
* Cursor pagination | ||
* | ||
* @remarks | ||
* | ||
* Cursor pagination relies on unique orderable seek key. | ||
* | ||
* Consider the resource we are paginating is: | ||
* | ||
* ```ts | ||
* ['A', 'B', 'C', 'D'] | ||
* ``` | ||
* | ||
* Assume that the seek key is `[0, 1, 2, 3]`. | ||
* Using `order = true`, `seek = 0` and `limit = 2`, you would get `['B', 'C']`. | ||
* Using `order = false`, `seek = 2` and `limit = 2`, you would get `['A', 'B']`. | ||
* Using `order = null`, `seekAfter = 1`, `seekBefore = 3`, you would get `['C']`. | ||
* | ||
* Cursor pagination does not allow random access of the pages. | ||
* You can however randomly access if you know the seek key you want. | ||
*/ | ||
@@ -344,3 +304,3 @@ function pageCurr(page, limit) { | ||
if (page.order === null) { | ||
limitNew = (limit != null) ? limit : page.count; | ||
limitNew = (limit != null) ? limit : page.length; | ||
} | ||
@@ -359,3 +319,3 @@ else { | ||
if (page.order === null) { | ||
limitNew = (limit != null) ? limit : page.count; | ||
limitNew = (limit != null) ? limit : page.length; | ||
} | ||
@@ -392,6 +352,6 @@ else { | ||
if (result instanceof Promise) { | ||
return result.then((result_) => (Object.assign(Object.assign({}, patch), { count: result_.count, seekFirst: result_.seekFirst, seekLast: result_.seekLast, items: result_.items }))); | ||
return result.then((result_) => (Object.assign(Object.assign({}, patch), { length: result_.length, seekFirst: result_.seekFirst, seekLast: result_.seekLast, items: result_.items }))); | ||
} | ||
else { | ||
return Object.assign(Object.assign({}, patch), { count: result.count, seekFirst: result.seekFirst, seekLast: result.seekLast, items: result.items }); | ||
return Object.assign(Object.assign({}, patch), { length: result.length, seekFirst: result.seekFirst, seekLast: result.seekLast, items: result.items }); | ||
} | ||
@@ -398,0 +358,0 @@ } |
/** | ||
* Offset pagination | ||
* | ||
* @remarks | ||
* | ||
* Offset pagination relies on a seek and limit number. | ||
* | ||
* Consider the resource we are paginating is: | ||
* | ||
* ```ts | ||
* ['A', 'B', 'C', 'D'] | ||
* ``` | ||
* | ||
* The seek index starts at 0. | ||
* The limit is entire length of the returned pagination view. | ||
* A seek and limit of `[0, 2]` would return `['A', 'B']`. | ||
* | ||
* The page numbers start at 1. So by using `[0, 2]` | ||
* we get page numbers of `[1, 2]`. We still refer to these numbers | ||
* with the page index. | ||
* | ||
* Note that the total represents the total number of items | ||
* when the pagination was fetched. The true total of items may have | ||
* changed on the server side since fetching a pagination. | ||
*/ | ||
@@ -30,3 +8,3 @@ declare type Pagination<I extends Iterable<any>> = Readonly<{ | ||
total: number; | ||
count: number; | ||
length: number; | ||
items: I; | ||
@@ -42,3 +20,3 @@ }>; | ||
total: number; | ||
count: number; | ||
length: number; | ||
items: I; | ||
@@ -50,4 +28,4 @@ }>; | ||
declare function pageLast(index: number, count: number): boolean; | ||
declare function pages(pageCount: number): Array<number>; | ||
declare function pagesI(pageCount: number): IterableIterator<number>; | ||
declare function pages(count: number): Array<number>; | ||
declare function pagesI(count: number): IterableIterator<number>; | ||
declare function pageCurr<I extends Iterable<any>>(page: Pagination<I>, limit?: number): Patch; | ||
@@ -54,0 +32,0 @@ declare function pageCurrM<I extends Iterable<any>>(page: Pagination<I>, action: ActionAsync<I>, limit?: number): Promise<Pagination<I>>; |
@@ -122,24 +122,2 @@ module.exports = | ||
* Offset pagination | ||
* | ||
* @remarks | ||
* | ||
* Offset pagination relies on a seek and limit number. | ||
* | ||
* Consider the resource we are paginating is: | ||
* | ||
* ```ts | ||
* ['A', 'B', 'C', 'D'] | ||
* ``` | ||
* | ||
* The seek index starts at 0. | ||
* The limit is entire length of the returned pagination view. | ||
* A seek and limit of `[0, 2]` would return `['A', 'B']`. | ||
* | ||
* The page numbers start at 1. So by using `[0, 2]` | ||
* we get page numbers of `[1, 2]`. We still refer to these numbers | ||
* with the page index. | ||
* | ||
* Note that the total represents the total number of items | ||
* when the pagination was fetched. The true total of items may have | ||
* changed on the server side since fetching a pagination. | ||
*/ | ||
@@ -158,7 +136,7 @@ function pageIndex(seek, limit) { | ||
} | ||
function pages(pageCount) { | ||
return Array.from({ length: pageCount }, (_, i) => i + 1); | ||
function pages(count) { | ||
return Array.from({ length: count }, (_, i) => i + 1); | ||
} | ||
function* pagesI(pageCount) { | ||
for (let i = 1; i <= pageCount; ++i) { | ||
function* pagesI(count) { | ||
for (let i = 1; i <= count; ++i) { | ||
yield i; | ||
@@ -271,7 +249,7 @@ } | ||
return result.then((result_) => { | ||
return Object.assign(Object.assign({}, patch), { total: result_.total, count: result_.count, items: result_.items }); | ||
return Object.assign(Object.assign({}, patch), { total: result_.total, length: result_.length, items: result_.items }); | ||
}); | ||
} | ||
else { | ||
return Object.assign(Object.assign({}, patch), { total: result.total, count: result.count, items: result.items }); | ||
return Object.assign(Object.assign({}, patch), { total: result.total, length: result.length, items: result.items }); | ||
} | ||
@@ -278,0 +256,0 @@ } |
{ | ||
"name": "@matrixai/pagination", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Offset-based and cursor-based pagination utilities", | ||
"keywords": [ | ||
"pagination", | ||
"offset", | ||
"cursor" | ||
], | ||
"author": "Roger Qiu <roger.qiu@matrix.ai>", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
@@ -23,5 +30,3 @@ "type": "git", | ||
"webpack-cli": "^3.3.9" | ||
}, | ||
"author": "Roger Qiu <roger.qiu@matrix.ai>", | ||
"license": "Apache-2.0" | ||
} | ||
} |
# Pagination | ||
## Offset | ||
Offset pagination relies on a seek and limit number. | ||
Consider the resource we are paginating is: | ||
```ts | ||
['A', 'B', 'C', 'D'] | ||
``` | ||
The seek index starts at 0. | ||
The limit is the desired length of the returned pagination view. | ||
A seek and limit of `[0, 2]` would return `['A', 'B']`. | ||
Page numbers start from 1. However we refer to them with a page index that starts at 0. | ||
The total represents the total number of items when the pagination was fetched. The true total of items may have changed on the server side since fetching a pagination. | ||
## Cursor | ||
Cursor pagination relies on unique orderable seek key. | ||
Consider the resource we are paginating is: | ||
```ts | ||
['A', 'B', 'C', 'D'] | ||
``` | ||
Assume that the seek key is `[0, 1, 2, 3]`: | ||
* Using `order = true`, `seek = 0` and `limit = 2`, you would get `['B', 'C']`. | ||
* Using `order = false`, `seek = 2` and `limit = 2`, you would get `['A', 'B']`. | ||
* Using `order = null`, `seekAfter = 1`, `seekBefore = 3`, you would get `['C']`. | ||
Cursor pagination does not allow random access of the pages. You can however randomly access if you know the seek key you want. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
40
180315
18
966