New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@matrixai/pagination

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@matrixai/pagination - npm Package Compare versions

Comparing version 0.0.9 to 0.1.0

2

dist/browser/index.js

@@ -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 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 S(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 S(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 S(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 S(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 h(e,t,n){return S(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 S(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 S(t,v(e,n,r))}function A(e,t,n){return{seek:t,limit:null!=n?n:e.limit}}function O(e,t,n,r){return S(t,A(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 S(t,w(e,n,r))}function M(e,t,n){const r=null!=n?n:e.limit;return{seek:Math.max(t,0)*e.limit,limit:r}}function R(e,t,n,r){return S(t,M(e,n,r))}function S(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,"pageCurrA",(function(){return s})),n.d(t,"pageCurrRaw",(function(){return a})),n.d(t,"pageCurrRawA",(function(){return d})),n.d(t,"pagePrev",(function(){return p})),n.d(t,"pagePrevA",(function(){return m})),n.d(t,"pagePrevRaw",(function(){return g})),n.d(t,"pagePrevRawA",(function(){return k})),n.d(t,"pageNext",(function(){return b})),n.d(t,"pageNextA",(function(){return h})),n.d(t,"pageNextRaw",(function(){return x})),n.d(t,"pageNextRawA",(function(){return j})),n.d(t,"pageSeek",(function(){return v})),n.d(t,"pageSeekA",(function(){return y})),n.d(t,"pageSeekRaw",(function(){return A})),n.d(t,"pageSeekRawA",(function(){return O})),n.d(t,"pageJump",(function(){return w})),n.d(t,"pageJumpA",(function(){return P})),n.d(t,"pageJumpRaw",(function(){return M})),n.d(t,"pageJumpRawA",(function(){return R}))},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,n){return l(t,r(e,n))}function i(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 o(e,t,n){return l(t,i(e,n))}function c(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 f(e,t,n){return l(t,c(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,"pageCurrA",(function(){return u})),n.d(t,"pagePrev",(function(){return i})),n.d(t,"pagePrevA",(function(){return o})),n.d(t,"pageNext",(function(){return c})),n.d(t,"pageNextA",(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 Array.from({length:t-e},(t,n)=>n+e)}function u(e,t){return Math.floor(e/t)}function i(e,t){return Math.ceil(e/t)}function o(e){return 0===e}function f(e,t){return e===t-1}function c(e){return r(1,e+1)}function*l(e){for(let t=1;t<=e;++t)yield t}function s(e,t,n,u,i){const o=n+1+u+1+i;if(e<=o)return[c(e)];const f=n,l=t-Math.floor(u/2)+1,s=t+Math.floor(u/2)+1,a=e-i+1,d=e;if(l<=f+1){return[r(1,o-i),r(a,d+1)]}if(s>=a-1){const t=o-n-2;return[r(1,f+1),r(e-t,d+1)]}return[r(1,f+1),r(l,s+1),r(a,d+1)]}function a(e,t){const n=null!=t?t:e.limit;return{seek:u(e.seek,n)*n,limit:n}}function d(e,t,n){return F(t,a(e,n))}function p(e,t){const n=null!=t?t:e.limit;return{seek:e.seek,limit:n}}function m(e,t,n){return F(t,p(e,n))}function g(e,t){const n=null!=t?t:e.limit;let r=u(e.seek,n);return{seek:(r=Math.max(r-1,0))*n,limit:n}}function k(e,t,n){return F(t,g(e,n))}function b(e,t){const n=null!=t?t:e.limit;return{seek:e.seek-n,limit:n}}function h(e,t,n){return F(t,b(e,n))}function x(e,t){const n=null!=t?t:e.limit;let r=u(e.seek,n);return{seek:(r+=1)*n,limit:n}}function j(e,t,n){return F(t,x(e,n))}function v(e,t){const n=null!=t?t:e.limit;return{seek:e.seek+n,limit:n}}function y(e,t,n){return F(t,v(e,n))}function A(e,t,n){const r=null!=n?n:e.limit;let i=u(t,r);return{seek:(i=Math.max(i,0))*r,limit:r}}function O(e,t,n,r){return F(t,A(e,n,r))}function w(e,t,n){return{seek:t,limit:null!=n?n:e.limit}}function P(e,t,n,r){return F(t,w(e,n,r))}function M(e,t,n){const r=null!=n?n:e.limit;return{seek:Math.max(t,0)*r,limit:r}}function R(e,t,n,r){return F(t,M(e,n,r))}function S(e,t,n){const r=null!=n?n:e.limit;return{seek:Math.max(t,0)*e.limit,limit:r}}function C(e,t,n,r){return F(t,S(e,n,r))}function F(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 u})),n.d(t,"pageCount",(function(){return i})),n.d(t,"pageFirst",(function(){return o})),n.d(t,"pageLast",(function(){return f})),n.d(t,"pages",(function(){return c})),n.d(t,"pagesI",(function(){return l})),n.d(t,"pagesT",(function(){return s})),n.d(t,"pageCurr",(function(){return a})),n.d(t,"pageCurrA",(function(){return d})),n.d(t,"pageCurrRaw",(function(){return p})),n.d(t,"pageCurrRawA",(function(){return m})),n.d(t,"pagePrev",(function(){return g})),n.d(t,"pagePrevA",(function(){return k})),n.d(t,"pagePrevRaw",(function(){return b})),n.d(t,"pagePrevRawA",(function(){return h})),n.d(t,"pageNext",(function(){return x})),n.d(t,"pageNextA",(function(){return j})),n.d(t,"pageNextRaw",(function(){return v})),n.d(t,"pageNextRawA",(function(){return y})),n.d(t,"pageSeek",(function(){return A})),n.d(t,"pageSeekA",(function(){return O})),n.d(t,"pageSeekRaw",(function(){return w})),n.d(t,"pageSeekRawA",(function(){return P})),n.d(t,"pageJump",(function(){return M})),n.d(t,"pageJumpA",(function(){return R})),n.d(t,"pageJumpRaw",(function(){return S})),n.d(t,"pageJumpRawA",(function(){return C}))},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,n){return l(t,r(e,n))}function i(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 o(e,t,n){return l(t,i(e,n))}function f(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 c(e,t,n){return l(t,f(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,"pageCurrA",(function(){return u})),n.d(t,"pagePrev",(function(){return i})),n.d(t,"pagePrevA",(function(){return o})),n.d(t,"pageNext",(function(){return f})),n.d(t,"pageNextA",(function(){return c}))},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 S(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 S(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 S(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 S(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 x(n,t,e){return S(t,b(n,e))}function y(n,t){const e=null!=t?t:n.limit;return{seek:n.seek+e,limit:e}}function j(n,t,e){return S(t,y(n,e))}function v(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 h(n,t,e,r){return S(t,v(n,e,r))}function w(n,t,e){return{seek:t,limit:null!=e?e:n.limit}}function A(n,t,e,r){return S(t,w(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 M(n,t,e,r){return S(t,O(n,e,r))}function P(n,t,e){const r=null!=e?e:n.limit;return{seek:Math.max(t,0)*n.limit,limit:r}}function R(n,t,e,r){return S(t,P(n,e,r))}function S(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,"pageCurrA",(function(){return a})),e.d(t,"pageCurrRaw",(function(){return s})),e.d(t,"pageCurrRawA",(function(){return p})),e.d(t,"pagePrev",(function(){return d})),e.d(t,"pagePrevA",(function(){return m})),e.d(t,"pagePrevRaw",(function(){return g})),e.d(t,"pagePrevRawA",(function(){return k})),e.d(t,"pageNext",(function(){return b})),e.d(t,"pageNextA",(function(){return x})),e.d(t,"pageNextRaw",(function(){return y})),e.d(t,"pageNextRawA",(function(){return j})),e.d(t,"pageSeek",(function(){return v})),e.d(t,"pageSeekA",(function(){return h})),e.d(t,"pageSeekRaw",(function(){return w})),e.d(t,"pageSeekRawA",(function(){return A})),e.d(t,"pageJump",(function(){return O})),e.d(t,"pageJumpA",(function(){return M})),e.d(t,"pageJumpRaw",(function(){return P})),e.d(t,"pageJumpRawA",(function(){return R}))}])}));
!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 Array.from({length:t-n},(t,e)=>e+n)}function u(n,t){return Math.floor(n/t)}function i(n,t){return Math.ceil(n/t)}function o(n){return 0===n}function c(n,t){return n===t-1}function f(n){return r(1,n+1)}function*l(n){for(let t=1;t<=n;++t)yield t}function a(n,t,e,u,i){const o=e+1+u+1+i;if(n<=o)return[f(n)];const c=e,l=t-Math.floor(u/2)+1,a=t+Math.floor(u/2)+1,s=n-i+1,p=n;if(l<=c+1){return[r(1,o-i),r(s,p+1)]}if(a>=s-1){const t=o-e-2;return[r(1,c+1),r(n-t,p+1)]}return[r(1,c+1),r(l,a+1),r(s,p+1)]}function s(n,t){const e=null!=t?t:n.limit;return{seek:u(n.seek,e)*e,limit:e}}function p(n,t,e){return C(t,s(n,e))}function d(n,t){const e=null!=t?t:n.limit;return{seek:n.seek,limit:e}}function m(n,t,e){return C(t,d(n,e))}function g(n,t){const e=null!=t?t:n.limit;let r=u(n.seek,e);return{seek:(r=Math.max(r-1,0))*e,limit:e}}function k(n,t,e){return C(t,g(n,e))}function b(n,t){const e=null!=t?t:n.limit;return{seek:n.seek-e,limit:e}}function x(n,t,e){return C(t,b(n,e))}function y(n,t){const e=null!=t?t:n.limit;let r=u(n.seek,e);return{seek:(r+=1)*e,limit:e}}function h(n,t,e){return C(t,y(n,e))}function j(n,t){const e=null!=t?t:n.limit;return{seek:n.seek+e,limit:e}}function v(n,t,e){return C(t,j(n,e))}function w(n,t,e){const r=null!=e?e:n.limit;let i=u(t,r);return{seek:(i=Math.max(i,0))*r,limit:r}}function M(n,t,e,r){return C(t,w(n,e,r))}function A(n,t,e){return{seek:t,limit:null!=e?e:n.limit}}function O(n,t,e,r){return C(t,A(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 C(t,P(n,e,r))}function S(n,t,e){const r=null!=e?e:n.limit;return{seek:Math.max(t,0)*n.limit,limit:r}}function _(n,t,e,r){return C(t,S(n,e,r))}function C(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 u})),e.d(t,"pageCount",(function(){return i})),e.d(t,"pageFirst",(function(){return o})),e.d(t,"pageLast",(function(){return c})),e.d(t,"pages",(function(){return f})),e.d(t,"pagesI",(function(){return l})),e.d(t,"pagesT",(function(){return a})),e.d(t,"pageCurr",(function(){return s})),e.d(t,"pageCurrA",(function(){return p})),e.d(t,"pageCurrRaw",(function(){return d})),e.d(t,"pageCurrRawA",(function(){return m})),e.d(t,"pagePrev",(function(){return g})),e.d(t,"pagePrevA",(function(){return k})),e.d(t,"pagePrevRaw",(function(){return b})),e.d(t,"pagePrevRawA",(function(){return x})),e.d(t,"pageNext",(function(){return y})),e.d(t,"pageNextA",(function(){return h})),e.d(t,"pageNextRaw",(function(){return j})),e.d(t,"pageNextRawA",(function(){return v})),e.d(t,"pageSeek",(function(){return w})),e.d(t,"pageSeekA",(function(){return M})),e.d(t,"pageSeekRaw",(function(){return A})),e.d(t,"pageSeekRawA",(function(){return O})),e.d(t,"pageJump",(function(){return P})),e.d(t,"pageJumpA",(function(){return R})),e.d(t,"pageJumpRaw",(function(){return S})),e.d(t,"pageJumpRawA",(function(){return _}))}])}));
//# sourceMappingURL=Offset.js.map

@@ -100,2 +100,3 @@ module.exports =

/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pagesI", function() { return pagesI; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pagesT", function() { return pagesT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pageCurr", function() { return pageCurr; });

@@ -124,2 +125,5 @@ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pageCurrA", function() { return pageCurrA; });

*/
function range(start, end) {
return Array.from({ length: end - start }, (_, i) => i + start);
}
function pageIndex(seek, limit) {

@@ -138,3 +142,3 @@ return Math.floor(seek / limit);

function pages(count) {
return Array.from({ length: count }, (_, i) => i + 1);
return range(1, count + 1);
}

@@ -146,2 +150,35 @@ function* pagesI(count) {

}
function pagesT(count, index, countLeft, countIndex, countRight) {
const countSlots = countLeft + 1 + countIndex + 1 + countRight;
if (count <= countSlots) {
return [pages(count)];
}
const leftStart = 1;
const leftEnd = countLeft;
const indexStart = index - Math.floor(countIndex / 2) + 1;
const indexEnd = index + Math.floor(countIndex / 2) + 1;
const rightStart = count - countRight + 1;
const rightEnd = count;
if (indexStart <= leftEnd + 1) {
const countLeftNew = countSlots - countRight;
return [
range(leftStart, countLeftNew),
range(rightStart, rightEnd + 1)
];
}
else if (indexEnd >= rightStart - 1) {
const countRightNew = countSlots - countLeft - 2;
return [
range(leftStart, leftEnd + 1),
range(count - countRightNew, rightEnd + 1)
];
}
else {
return [
range(leftStart, leftEnd + 1),
range(indexStart, indexEnd + 1),
range(rightStart, rightEnd + 1)
];
}
}
function pageCurr(page, limit) {

@@ -148,0 +185,0 @@ const limitNew = (limit != null) ? limit : page.limit;

@@ -28,2 +28,3 @@ /**

declare function pagesI(count: number): IterableIterator<number>;
declare function pagesT(count: number, index: number, countLeft: number, countIndex: number, countRight: number): ([Array<number>] | [Array<number>, Array<number>] | [Array<number>, Array<number>, Array<number>]);
declare function pageCurr<I extends Iterable<any>>(page: Pagination<I>, limit?: number): Patch;

@@ -59,2 +60,2 @@ declare function pageCurrA<I extends Iterable<any>>(page: Pagination<I>, action: ActionAsync<I>, limit?: number): Promise<Pagination<I>>;

declare function pageJumpRawA<I extends Iterable<any>>(page: Pagination<I>, action: ActionSync<I>, seek: number, limit?: number): Pagination<I>;
export { Pagination, Patch, ActionAsync, ActionSync, ActionResult, pageIndex, pageCount, pageFirst, pageLast, pages, pagesI, pageCurr, pageCurrA, pageCurrRaw, pageCurrRawA, pagePrev, pagePrevA, pagePrevRaw, pagePrevRawA, pageNext, pageNextA, pageNextRaw, pageNextRawA, pageSeek, pageSeekA, pageSeekRaw, pageSeekRawA, pageJump, pageJumpA, pageJumpRaw, pageJumpRawA };
export { Pagination, Patch, ActionAsync, ActionSync, ActionResult, pageIndex, pageCount, pageFirst, pageLast, pages, pagesI, pagesT, pageCurr, pageCurrA, pageCurrRaw, pageCurrRawA, pagePrev, pagePrevA, pagePrevRaw, pagePrevRawA, pageNext, pageNextA, pageNextRaw, pageNextRawA, pageSeek, pageSeekA, pageSeekRaw, pageSeekRawA, pageJump, pageJumpA, pageJumpRaw, pageJumpRawA };

@@ -100,2 +100,3 @@ module.exports =

/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pagesI", function() { return pagesI; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pagesT", function() { return pagesT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pageCurr", function() { return pageCurr; });

@@ -124,2 +125,5 @@ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pageCurrA", function() { return pageCurrA; });

*/
function range(start, end) {
return Array.from({ length: end - start }, (_, i) => i + start);
}
function pageIndex(seek, limit) {

@@ -138,3 +142,3 @@ return Math.floor(seek / limit);

function pages(count) {
return Array.from({ length: count }, (_, i) => i + 1);
return range(1, count + 1);
}

@@ -146,2 +150,35 @@ function* pagesI(count) {

}
function pagesT(count, index, countLeft, countIndex, countRight) {
const countSlots = countLeft + 1 + countIndex + 1 + countRight;
if (count <= countSlots) {
return [pages(count)];
}
const leftStart = 1;
const leftEnd = countLeft;
const indexStart = index - Math.floor(countIndex / 2) + 1;
const indexEnd = index + Math.floor(countIndex / 2) + 1;
const rightStart = count - countRight + 1;
const rightEnd = count;
if (indexStart <= leftEnd + 1) {
const countLeftNew = countSlots - countRight;
return [
range(leftStart, countLeftNew),
range(rightStart, rightEnd + 1)
];
}
else if (indexEnd >= rightStart - 1) {
const countRightNew = countSlots - countLeft - 2;
return [
range(leftStart, leftEnd + 1),
range(count - countRightNew, rightEnd + 1)
];
}
else {
return [
range(leftStart, leftEnd + 1),
range(indexStart, indexEnd + 1),
range(rightStart, rightEnd + 1)
];
}
}
function pageCurr(page, limit) {

@@ -148,0 +185,0 @@ const limitNew = (limit != null) ? limit : page.limit;

{
"name": "@matrixai/pagination",
"version": "0.0.9",
"version": "0.1.0",
"description": "Offset-based and cursor-based pagination utilities",

@@ -5,0 +5,0 @@ "keywords": [

@@ -40,1 +40,10 @@ # Pagination

Cursor pagination does not allow random access of the pages. You can however randomly access if you know the seek key you want.
## Development
```sh
type='patch'
npm run build
npm version $type
npm publish
```

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc