toolbox-x 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/LICENSE +201 -0
  2. package/dist/Color-B3mgF9Dh.d.cts +486 -0
  3. package/dist/Color-D38Xrw65.d.mts +486 -0
  4. package/dist/Stylog-Df7eq3-j.d.cts +519 -0
  5. package/dist/Stylog-jvlLcMQq.d.mts +519 -0
  6. package/dist/array-DvW0zIu6.d.mts +130 -0
  7. package/dist/array-rUnEVisO.d.cts +130 -0
  8. package/dist/basics-D_eSv0cu.cjs +132 -0
  9. package/dist/basics-Dp_aEK81.mjs +115 -0
  10. package/dist/basics-WEYWlnRO.d.cts +95 -0
  11. package/dist/basics-uBSfkBEI.d.mts +95 -0
  12. package/dist/case-BWIt8Ash.mjs +449 -0
  13. package/dist/case-C-S-b5YP.d.cts +327 -0
  14. package/dist/case-CS8Ii3A7.cjs +526 -0
  15. package/dist/case-CybASFPD.d.mts +327 -0
  16. package/dist/change-case.cjs +32 -0
  17. package/dist/change-case.d.cts +18 -0
  18. package/dist/change-case.d.mts +18 -0
  19. package/dist/change-case.mjs +19 -0
  20. package/dist/colors.cjs +574 -0
  21. package/dist/colors.d.cts +355 -0
  22. package/dist/colors.d.mts +355 -0
  23. package/dist/colors.mjs +547 -0
  24. package/dist/constants-2gAw23_7.mjs +144 -0
  25. package/dist/constants-B34K0QPi.d.cts +21 -0
  26. package/dist/constants-BIBDKY1u.cjs +924 -0
  27. package/dist/constants-BWT-810U.cjs +158 -0
  28. package/dist/constants-BwbHnXlM.mjs +662 -0
  29. package/dist/constants-BxN9l5el.cjs +74 -0
  30. package/dist/constants-CLS_bgKD.d.mts +847 -0
  31. package/dist/constants-D73iFu8g.mjs +171 -0
  32. package/dist/constants-DAfRxaa8.mjs +62 -0
  33. package/dist/constants-DQYeCjlx.cjs +207 -0
  34. package/dist/constants-Deeie-iH.d.mts +21 -0
  35. package/dist/constants-DpTG9RP6.d.mts +29 -0
  36. package/dist/constants-DqwnkJ_d.cjs +740 -0
  37. package/dist/constants-DvRUY_FY.cjs +150 -0
  38. package/dist/constants-VcRtQu0K.d.cts +29 -0
  39. package/dist/constants-X5hm1UtB.mjs +912 -0
  40. package/dist/constants-eNd-iYsV.mjs +134 -0
  41. package/dist/constants-qm8FafmD.d.cts +847 -0
  42. package/dist/constants.cjs +415 -0
  43. package/dist/constants.d.cts +184 -0
  44. package/dist/constants.d.mts +184 -0
  45. package/dist/constants.mjs +378 -0
  46. package/dist/convert-BOCgUv2D.cjs +252 -0
  47. package/dist/convert-Bn4jFomQ.mjs +169 -0
  48. package/dist/convert-BrzlG-m_.cjs +475 -0
  49. package/dist/convert-DhaUoPVU.mjs +368 -0
  50. package/dist/converter-1P90_RcP.d.mts +402 -0
  51. package/dist/converter-CmkcAppi.d.cts +402 -0
  52. package/dist/converter.cjs +780 -0
  53. package/dist/converter.d.cts +29 -0
  54. package/dist/converter.d.mts +29 -0
  55. package/dist/converter.mjs +771 -0
  56. package/dist/countries-CIpmtEzV.cjs +1469 -0
  57. package/dist/countries-Cy0xiqS3.mjs +1463 -0
  58. package/dist/css-colors-Bx947Ng3.d.cts +179 -0
  59. package/dist/css-colors-CXCDqQbG.cjs +186 -0
  60. package/dist/css-colors-CXTp1vvy.d.mts +179 -0
  61. package/dist/css-colors-DfUW3nTR.mjs +180 -0
  62. package/dist/date.cjs +332 -0
  63. package/dist/date.d.cts +213 -0
  64. package/dist/date.d.mts +213 -0
  65. package/dist/date.mjs +298 -0
  66. package/dist/dom.cjs +461 -0
  67. package/dist/dom.d.cts +228 -0
  68. package/dist/dom.d.mts +228 -0
  69. package/dist/dom.mjs +429 -0
  70. package/dist/form-BMFVGUrN.d.mts +118 -0
  71. package/dist/form-DRFbryvK.d.cts +118 -0
  72. package/dist/guards-3kaUX66g.mjs +157 -0
  73. package/dist/guards-C8gkvIHb.cjs +240 -0
  74. package/dist/guards-DdyU4h4o.mjs +110 -0
  75. package/dist/guards-Efhp1mNy.cjs +151 -0
  76. package/dist/guards.cjs +172 -0
  77. package/dist/guards.d.cts +399 -0
  78. package/dist/guards.d.mts +399 -0
  79. package/dist/guards.mjs +75 -0
  80. package/dist/hash-B6JPEyAz.d.mts +131 -0
  81. package/dist/hash-NTpeKYB_.d.cts +131 -0
  82. package/dist/hash.cjs +2126 -0
  83. package/dist/hash.d.cts +1239 -0
  84. package/dist/hash.d.mts +1239 -0
  85. package/dist/hash.mjs +2095 -0
  86. package/dist/http-status-BAZdtr7-.d.mts +65 -0
  87. package/dist/http-status-U_3MtoGb.d.cts +65 -0
  88. package/dist/http-status.cjs +173 -0
  89. package/dist/http-status.d.cts +142 -0
  90. package/dist/http-status.d.mts +142 -0
  91. package/dist/http-status.mjs +171 -0
  92. package/dist/index.cjs +2551 -0
  93. package/dist/index.d.cts +1493 -0
  94. package/dist/index.d.mts +1493 -0
  95. package/dist/index.mjs +2357 -0
  96. package/dist/object-B0TV3eHx.d.mts +8052 -0
  97. package/dist/object-Blq0Amdv.d.cts +8052 -0
  98. package/dist/objectify-CDs0Fbr1.mjs +417 -0
  99. package/dist/objectify-DIJ-OBmo.cjs +524 -0
  100. package/dist/paginator.cjs +245 -0
  101. package/dist/paginator.d.cts +144 -0
  102. package/dist/paginator.d.mts +144 -0
  103. package/dist/paginator.mjs +243 -0
  104. package/dist/parse-2ubxXZRp.cjs +211 -0
  105. package/dist/parse-N7g942uy.mjs +164 -0
  106. package/dist/pluralizer-BjMIc6uT.d.mts +42 -0
  107. package/dist/pluralizer-Cb6ZmrDl.d.cts +42 -0
  108. package/dist/pluralizer.cjs +678 -0
  109. package/dist/pluralizer.d.cts +152 -0
  110. package/dist/pluralizer.d.mts +152 -0
  111. package/dist/pluralizer.mjs +676 -0
  112. package/dist/primitives-B26uZolQ.cjs +228 -0
  113. package/dist/primitives-KsFUp3kQ.mjs +144 -0
  114. package/dist/specials-D48_IZbd.d.mts +108 -0
  115. package/dist/specials-DzLr1ZgU.cjs +477 -0
  116. package/dist/specials-LVONlKbQ.d.cts +108 -0
  117. package/dist/specials-uhDuRg8H.mjs +292 -0
  118. package/dist/string-CBAbxaG1.d.mts +258 -0
  119. package/dist/string-CsNsm_65.d.cts +258 -0
  120. package/dist/stylog.cjs +621 -0
  121. package/dist/stylog.d.cts +49 -0
  122. package/dist/stylog.d.mts +49 -0
  123. package/dist/stylog.mjs +614 -0
  124. package/dist/timezone-B2OYK6Fh.mjs +5589 -0
  125. package/dist/timezone-Beh9IGpw.cjs +5625 -0
  126. package/dist/types/array.cjs +16 -0
  127. package/dist/types/array.d.cts +18 -0
  128. package/dist/types/array.d.mts +18 -0
  129. package/dist/types/array.mjs +17 -0
  130. package/dist/types/colors.cjs +16 -0
  131. package/dist/types/colors.d.cts +18 -0
  132. package/dist/types/colors.d.mts +18 -0
  133. package/dist/types/colors.mjs +17 -0
  134. package/dist/types/converter.cjs +16 -0
  135. package/dist/types/converter.d.cts +18 -0
  136. package/dist/types/converter.d.mts +18 -0
  137. package/dist/types/converter.mjs +17 -0
  138. package/dist/types/form.cjs +16 -0
  139. package/dist/types/form.d.cts +18 -0
  140. package/dist/types/form.d.mts +18 -0
  141. package/dist/types/form.mjs +17 -0
  142. package/dist/types/hash.cjs +16 -0
  143. package/dist/types/hash.d.cts +18 -0
  144. package/dist/types/hash.d.mts +18 -0
  145. package/dist/types/hash.mjs +17 -0
  146. package/dist/types/http-status.cjs +16 -0
  147. package/dist/types/http-status.d.cts +18 -0
  148. package/dist/types/http-status.d.mts +18 -0
  149. package/dist/types/http-status.mjs +17 -0
  150. package/dist/types/index.cjs +16 -0
  151. package/dist/types/index.d.cts +18 -0
  152. package/dist/types/index.d.mts +18 -0
  153. package/dist/types/index.mjs +17 -0
  154. package/dist/types/number.cjs +16 -0
  155. package/dist/types/number.d.cts +18 -0
  156. package/dist/types/number.d.mts +18 -0
  157. package/dist/types/number.mjs +17 -0
  158. package/dist/types/object.cjs +16 -0
  159. package/dist/types/object.d.cts +18 -0
  160. package/dist/types/object.d.mts +18 -0
  161. package/dist/types/object.mjs +17 -0
  162. package/dist/types/pluralizer.cjs +16 -0
  163. package/dist/types/pluralizer.d.cts +18 -0
  164. package/dist/types/pluralizer.d.mts +18 -0
  165. package/dist/types/pluralizer.mjs +17 -0
  166. package/dist/types/string.cjs +16 -0
  167. package/dist/types/string.d.cts +18 -0
  168. package/dist/types/string.d.mts +18 -0
  169. package/dist/types/string.mjs +17 -0
  170. package/dist/types/stylog.cjs +16 -0
  171. package/dist/types/stylog.d.cts +18 -0
  172. package/dist/types/stylog.d.mts +18 -0
  173. package/dist/types/stylog.mjs +17 -0
  174. package/dist/types/utils.cjs +16 -0
  175. package/dist/types/utils.d.cts +18 -0
  176. package/dist/types/utils.d.mts +18 -0
  177. package/dist/types/utils.mjs +17 -0
  178. package/dist/types/verbalizer.cjs +16 -0
  179. package/dist/types/verbalizer.d.cts +30 -0
  180. package/dist/types/verbalizer.d.mts +30 -0
  181. package/dist/types/verbalizer.mjs +17 -0
  182. package/dist/utilities-CLUmdQeV.cjs +140 -0
  183. package/dist/utilities-m5yFKqLd.mjs +105 -0
  184. package/dist/utils-ClW9LA6f.mjs +449 -0
  185. package/dist/utils-DLFRgXUC.cjs +568 -0
  186. package/dist/verbalizer.cjs +998 -0
  187. package/dist/verbalizer.d.cts +148 -0
  188. package/dist/verbalizer.d.mts +148 -0
  189. package/dist/verbalizer.mjs +996 -0
  190. package/package.json +249 -0
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
18
+
19
+ //#region src/utils/Paginator.ts
20
+ /** @class Generates pagination logic, offsets, metadata and other pagination logic(s) for APIs and UIs. */
21
+ var Paginator = class Paginator {
22
+ #totalItems;
23
+ #perPage;
24
+ #currentPage;
25
+ /**
26
+ * * Creates an instance of the Paginator.
27
+ * @param options - The options for pagination.
28
+ */
29
+ constructor(options) {
30
+ const { totalItems, itemsPerPage = 10, currentPage = 1 } = options ?? {};
31
+ this.#totalItems = Math.max(0, Number(totalItems));
32
+ this.#perPage = Math.max(1, Number(itemsPerPage));
33
+ this.#currentPage = Math.max(1, Number(currentPage));
34
+ }
35
+ /**
36
+ * @instance Returns a new Paginator instance with the given page number.
37
+ * * This method does not modify the current instance.
38
+ * - **N.B.** *If the provided page is out of range, it will be clamped between 1 and the last page.*
39
+ * @param page - The new current page to use.
40
+ * @returns A new Paginator instance with the updated (clamped) page.
41
+ */
42
+ withPage(page) {
43
+ const safePage = Math.min(Math.max(1, page), this.totalPages());
44
+ return new Paginator({
45
+ totalItems: this.#totalItems,
46
+ itemsPerPage: this.#perPage,
47
+ currentPage: safePage
48
+ });
49
+ }
50
+ /**
51
+ * @instance Returns a new Paginator instance with the given items per page.
52
+ * - **N.B.** *If the value is less than `1`, it will be clamped to 1.*
53
+ * @param perPage - New items per page value.
54
+ * @returns A new Paginator instance with updated items per page.
55
+ */
56
+ withPerPage(perPage) {
57
+ const safePerPage = Math.max(1, perPage);
58
+ return new Paginator({
59
+ totalItems: this.#totalItems,
60
+ itemsPerPage: safePerPage,
61
+ currentPage: this.#currentPage
62
+ });
63
+ }
64
+ /**
65
+ * @instance Returns a new Paginator instance with the given total items.
66
+ * - **N.B.** *If the value is `negative`, it will be clamped to `0`.*
67
+ * @param totalItems - New total items value.
68
+ * @returns A new Paginator instance with updated total items.
69
+ */
70
+ withTotalItems(totalItems) {
71
+ return new Paginator({
72
+ totalItems: Math.max(0, totalItems),
73
+ itemsPerPage: this.#perPage,
74
+ currentPage: this.#currentPage
75
+ });
76
+ }
77
+ /**
78
+ * @instance Returns a new Paginator instance with updated pagination options.
79
+ * - **N.B.** *Any value provided will override the existing one, with clamping applied for safety.*
80
+ * @param options - Partial pagination options to override the current instance.
81
+ * @returns A new Paginator instance with merged and clamped options.
82
+ */
83
+ withOptions(options) {
84
+ const newTotalItems = Math.max(0, options.totalItems ? Number(options.totalItems) : this.#totalItems);
85
+ const newItemsPerPage = Math.max(1, options.itemsPerPage ? Number(options.itemsPerPage) : this.#perPage);
86
+ const totalPages = Math.ceil(newTotalItems / newItemsPerPage);
87
+ return new Paginator({
88
+ totalItems: newTotalItems,
89
+ itemsPerPage: newItemsPerPage,
90
+ currentPage: Math.min(Math.max(1, options.currentPage ? Number(options.currentPage) : this.#currentPage), totalPages)
91
+ });
92
+ }
93
+ /**
94
+ * @instance Calculates the offset (number of items to skip) based on the `current page` and `items per page`.
95
+ * @returns The number of items to skip.
96
+ */
97
+ offset() {
98
+ return (this.#currentPage - 1) * this.#perPage;
99
+ }
100
+ /**
101
+ * @instance Calculates the offset (number of items to skip) based on the `current page` and `items per page`.
102
+ * @alias of {@link offset}
103
+ * @returns The number of items to skip.
104
+ */
105
+ getOffset() {
106
+ return this.offset();
107
+ }
108
+ /**
109
+ * @instance Calculates the number of items to skip based on the `current page` and `items per page`.
110
+ * @alias of {@link offset}
111
+ * @returns The number of items to skip.
112
+ */
113
+ skipCount() {
114
+ return this.offset();
115
+ }
116
+ /**
117
+ * @instance Calculates the total number of pages based on `total items` and `items per page`.
118
+ * @returns The total number of pages.
119
+ */
120
+ totalPages() {
121
+ return Math.ceil(this.#totalItems / this.#perPage);
122
+ }
123
+ /**
124
+ * * Returns pagination metadata useful for API responses or UI rendering.
125
+ * @returns An object with pagination metadata.
126
+ */
127
+ getMeta() {
128
+ const totalPages = this.totalPages();
129
+ return {
130
+ totalItems: this.#totalItems,
131
+ currentPage: this.#currentPage,
132
+ itemsPerPage: this.#perPage,
133
+ totalPages,
134
+ hasPrev: this.hasPrevPage(),
135
+ hasNext: this.hasNextPage(),
136
+ isFirst: this.isFirstPage(),
137
+ isLast: this.isLastPage(),
138
+ offset: this.offset()
139
+ };
140
+ }
141
+ /**
142
+ * @instance Returns the next page number if it exists.
143
+ * @returns The next page number or null if it's the last page.
144
+ */
145
+ nextPage() {
146
+ return this.#currentPage < this.totalPages() ? this.#currentPage + 1 : null;
147
+ }
148
+ /**
149
+ * @instance Returns the previous page number if it exists.
150
+ * @returns The previous page number or null if it's the first page.
151
+ */
152
+ prevPage() {
153
+ return this.#currentPage > 1 ? this.#currentPage - 1 : null;
154
+ }
155
+ /**
156
+ * @instance Checks if the current page is the first page.
157
+ * @returns Whether the current page is the first page.
158
+ */
159
+ isFirstPage() {
160
+ return this.#currentPage === 1;
161
+ }
162
+ /**
163
+ * @instance Checks if the current page is the last page.
164
+ * @returns Whether the current page is the last page.
165
+ */
166
+ isLastPage() {
167
+ return this.#currentPage === this.totalPages();
168
+ }
169
+ /**
170
+ * @instance Checks if a previous page exists.
171
+ * @returns Whether a previous page exists.
172
+ */
173
+ hasPrevPage() {
174
+ return this.#currentPage > 1;
175
+ }
176
+ /**
177
+ * @instance Checks if a next page exists.
178
+ * @returns Whether a next page exists.
179
+ */
180
+ hasNextPage() {
181
+ return this.#currentPage < this.totalPages();
182
+ }
183
+ /**
184
+ * @instance Creates an array of page numbers for UI pagination display.
185
+ * @param options Options for customizing the page list.
186
+ * @returns An array of visible page numbers.
187
+ */
188
+ pageList(options = {}) {
189
+ const total = this.totalPages();
190
+ const edgeCount = Math.max(0, options.edgeCount ?? 1);
191
+ const siblingCount = Math.max(0, options.siblingCount ?? 1);
192
+ const start = Math.max(this.#currentPage - siblingCount, edgeCount + 1);
193
+ const end = Math.min(this.#currentPage + siblingCount, total - edgeCount);
194
+ const _getRange = (from, to) => {
195
+ return from > to ? [] : Array.from({ length: to - from + 1 }, (_, i) => from + i);
196
+ };
197
+ const startPages = _getRange(1, edgeCount);
198
+ const middlePages = _getRange(start, end);
199
+ const endPages = _getRange(total - edgeCount + 1, total);
200
+ const pages = new Set([
201
+ ...startPages,
202
+ ...middlePages,
203
+ ...endPages
204
+ ]);
205
+ return Array.from(pages).sort((a, b) => a - b);
206
+ }
207
+ /**
208
+ * @instance Returns the first page number.
209
+ * @returns Always returns 1.
210
+ */
211
+ firstPage() {
212
+ return 1;
213
+ }
214
+ /**
215
+ * @instance Returns the last page number based on total items and per page count.
216
+ * @returns The last page number.
217
+ */
218
+ lastPage() {
219
+ return this.totalPages();
220
+ }
221
+ /**
222
+ * @instance Checks if a page number is valid within the pagination range.
223
+ * @param page - The page number to validate.
224
+ * @returns Whether the page number is within range.
225
+ */
226
+ isPageValid(page) {
227
+ const p = Math.floor(page);
228
+ return p >= 1 && p <= this.totalPages();
229
+ }
230
+ /**
231
+ * @static Creates a new Paginator instance from a meta object.
232
+ * @param meta - A pagination metadata object.
233
+ * @returns A new Paginator instance.
234
+ */
235
+ static fromMeta(meta) {
236
+ return new Paginator({
237
+ totalItems: meta.totalItems,
238
+ itemsPerPage: meta.itemsPerPage,
239
+ currentPage: meta.currentPage
240
+ });
241
+ }
242
+ };
243
+
244
+ //#endregion
245
+ exports.Paginator = Paginator;
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { Gn as PageListOptions, Kn as PaginatorMeta, Nn as FromMetaOptions, qn as PaginatorOptions } from "./object-Blq0Amdv.cjs";
18
+
19
+ //#region src/utils/Paginator.d.ts
20
+ /** @class Generates pagination logic, offsets, metadata and other pagination logic(s) for APIs and UIs. */
21
+ declare class Paginator {
22
+ #private;
23
+ /**
24
+ * * Creates an instance of the Paginator.
25
+ * @param options - The options for pagination.
26
+ */
27
+ constructor(options: PaginatorOptions);
28
+ /**
29
+ * @instance Returns a new Paginator instance with the given page number.
30
+ * * This method does not modify the current instance.
31
+ * - **N.B.** *If the provided page is out of range, it will be clamped between 1 and the last page.*
32
+ * @param page - The new current page to use.
33
+ * @returns A new Paginator instance with the updated (clamped) page.
34
+ */
35
+ withPage(page: number): Paginator;
36
+ /**
37
+ * @instance Returns a new Paginator instance with the given items per page.
38
+ * - **N.B.** *If the value is less than `1`, it will be clamped to 1.*
39
+ * @param perPage - New items per page value.
40
+ * @returns A new Paginator instance with updated items per page.
41
+ */
42
+ withPerPage(perPage: number): Paginator;
43
+ /**
44
+ * @instance Returns a new Paginator instance with the given total items.
45
+ * - **N.B.** *If the value is `negative`, it will be clamped to `0`.*
46
+ * @param totalItems - New total items value.
47
+ * @returns A new Paginator instance with updated total items.
48
+ */
49
+ withTotalItems(totalItems: number): Paginator;
50
+ /**
51
+ * @instance Returns a new Paginator instance with updated pagination options.
52
+ * - **N.B.** *Any value provided will override the existing one, with clamping applied for safety.*
53
+ * @param options - Partial pagination options to override the current instance.
54
+ * @returns A new Paginator instance with merged and clamped options.
55
+ */
56
+ withOptions(options: Partial<PaginatorOptions>): Paginator;
57
+ /**
58
+ * @instance Calculates the offset (number of items to skip) based on the `current page` and `items per page`.
59
+ * @returns The number of items to skip.
60
+ */
61
+ offset(): number;
62
+ /**
63
+ * @instance Calculates the offset (number of items to skip) based on the `current page` and `items per page`.
64
+ * @alias of {@link offset}
65
+ * @returns The number of items to skip.
66
+ */
67
+ getOffset(): number;
68
+ /**
69
+ * @instance Calculates the number of items to skip based on the `current page` and `items per page`.
70
+ * @alias of {@link offset}
71
+ * @returns The number of items to skip.
72
+ */
73
+ skipCount(): number;
74
+ /**
75
+ * @instance Calculates the total number of pages based on `total items` and `items per page`.
76
+ * @returns The total number of pages.
77
+ */
78
+ totalPages(): number;
79
+ /**
80
+ * * Returns pagination metadata useful for API responses or UI rendering.
81
+ * @returns An object with pagination metadata.
82
+ */
83
+ getMeta(): PaginatorMeta;
84
+ /**
85
+ * @instance Returns the next page number if it exists.
86
+ * @returns The next page number or null if it's the last page.
87
+ */
88
+ nextPage(): number | null;
89
+ /**
90
+ * @instance Returns the previous page number if it exists.
91
+ * @returns The previous page number or null if it's the first page.
92
+ */
93
+ prevPage(): number | null;
94
+ /**
95
+ * @instance Checks if the current page is the first page.
96
+ * @returns Whether the current page is the first page.
97
+ */
98
+ isFirstPage(): boolean;
99
+ /**
100
+ * @instance Checks if the current page is the last page.
101
+ * @returns Whether the current page is the last page.
102
+ */
103
+ isLastPage(): boolean;
104
+ /**
105
+ * @instance Checks if a previous page exists.
106
+ * @returns Whether a previous page exists.
107
+ */
108
+ hasPrevPage(): boolean;
109
+ /**
110
+ * @instance Checks if a next page exists.
111
+ * @returns Whether a next page exists.
112
+ */
113
+ hasNextPage(): boolean;
114
+ /**
115
+ * @instance Creates an array of page numbers for UI pagination display.
116
+ * @param options Options for customizing the page list.
117
+ * @returns An array of visible page numbers.
118
+ */
119
+ pageList(options?: PageListOptions): number[];
120
+ /**
121
+ * @instance Returns the first page number.
122
+ * @returns Always returns 1.
123
+ */
124
+ firstPage(): number;
125
+ /**
126
+ * @instance Returns the last page number based on total items and per page count.
127
+ * @returns The last page number.
128
+ */
129
+ lastPage(): number;
130
+ /**
131
+ * @instance Checks if a page number is valid within the pagination range.
132
+ * @param page - The page number to validate.
133
+ * @returns Whether the page number is within range.
134
+ */
135
+ isPageValid(page: number): boolean;
136
+ /**
137
+ * @static Creates a new Paginator instance from a meta object.
138
+ * @param meta - A pagination metadata object.
139
+ * @returns A new Paginator instance.
140
+ */
141
+ static fromMeta(meta: FromMetaOptions): Paginator;
142
+ }
143
+ //#endregion
144
+ export { Paginator };
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { Gn as PageListOptions, Kn as PaginatorMeta, Nn as FromMetaOptions, qn as PaginatorOptions } from "./object-B0TV3eHx.mjs";
18
+
19
+ //#region src/utils/Paginator.d.ts
20
+ /** @class Generates pagination logic, offsets, metadata and other pagination logic(s) for APIs and UIs. */
21
+ declare class Paginator {
22
+ #private;
23
+ /**
24
+ * * Creates an instance of the Paginator.
25
+ * @param options - The options for pagination.
26
+ */
27
+ constructor(options: PaginatorOptions);
28
+ /**
29
+ * @instance Returns a new Paginator instance with the given page number.
30
+ * * This method does not modify the current instance.
31
+ * - **N.B.** *If the provided page is out of range, it will be clamped between 1 and the last page.*
32
+ * @param page - The new current page to use.
33
+ * @returns A new Paginator instance with the updated (clamped) page.
34
+ */
35
+ withPage(page: number): Paginator;
36
+ /**
37
+ * @instance Returns a new Paginator instance with the given items per page.
38
+ * - **N.B.** *If the value is less than `1`, it will be clamped to 1.*
39
+ * @param perPage - New items per page value.
40
+ * @returns A new Paginator instance with updated items per page.
41
+ */
42
+ withPerPage(perPage: number): Paginator;
43
+ /**
44
+ * @instance Returns a new Paginator instance with the given total items.
45
+ * - **N.B.** *If the value is `negative`, it will be clamped to `0`.*
46
+ * @param totalItems - New total items value.
47
+ * @returns A new Paginator instance with updated total items.
48
+ */
49
+ withTotalItems(totalItems: number): Paginator;
50
+ /**
51
+ * @instance Returns a new Paginator instance with updated pagination options.
52
+ * - **N.B.** *Any value provided will override the existing one, with clamping applied for safety.*
53
+ * @param options - Partial pagination options to override the current instance.
54
+ * @returns A new Paginator instance with merged and clamped options.
55
+ */
56
+ withOptions(options: Partial<PaginatorOptions>): Paginator;
57
+ /**
58
+ * @instance Calculates the offset (number of items to skip) based on the `current page` and `items per page`.
59
+ * @returns The number of items to skip.
60
+ */
61
+ offset(): number;
62
+ /**
63
+ * @instance Calculates the offset (number of items to skip) based on the `current page` and `items per page`.
64
+ * @alias of {@link offset}
65
+ * @returns The number of items to skip.
66
+ */
67
+ getOffset(): number;
68
+ /**
69
+ * @instance Calculates the number of items to skip based on the `current page` and `items per page`.
70
+ * @alias of {@link offset}
71
+ * @returns The number of items to skip.
72
+ */
73
+ skipCount(): number;
74
+ /**
75
+ * @instance Calculates the total number of pages based on `total items` and `items per page`.
76
+ * @returns The total number of pages.
77
+ */
78
+ totalPages(): number;
79
+ /**
80
+ * * Returns pagination metadata useful for API responses or UI rendering.
81
+ * @returns An object with pagination metadata.
82
+ */
83
+ getMeta(): PaginatorMeta;
84
+ /**
85
+ * @instance Returns the next page number if it exists.
86
+ * @returns The next page number or null if it's the last page.
87
+ */
88
+ nextPage(): number | null;
89
+ /**
90
+ * @instance Returns the previous page number if it exists.
91
+ * @returns The previous page number or null if it's the first page.
92
+ */
93
+ prevPage(): number | null;
94
+ /**
95
+ * @instance Checks if the current page is the first page.
96
+ * @returns Whether the current page is the first page.
97
+ */
98
+ isFirstPage(): boolean;
99
+ /**
100
+ * @instance Checks if the current page is the last page.
101
+ * @returns Whether the current page is the last page.
102
+ */
103
+ isLastPage(): boolean;
104
+ /**
105
+ * @instance Checks if a previous page exists.
106
+ * @returns Whether a previous page exists.
107
+ */
108
+ hasPrevPage(): boolean;
109
+ /**
110
+ * @instance Checks if a next page exists.
111
+ * @returns Whether a next page exists.
112
+ */
113
+ hasNextPage(): boolean;
114
+ /**
115
+ * @instance Creates an array of page numbers for UI pagination display.
116
+ * @param options Options for customizing the page list.
117
+ * @returns An array of visible page numbers.
118
+ */
119
+ pageList(options?: PageListOptions): number[];
120
+ /**
121
+ * @instance Returns the first page number.
122
+ * @returns Always returns 1.
123
+ */
124
+ firstPage(): number;
125
+ /**
126
+ * @instance Returns the last page number based on total items and per page count.
127
+ * @returns The last page number.
128
+ */
129
+ lastPage(): number;
130
+ /**
131
+ * @instance Checks if a page number is valid within the pagination range.
132
+ * @param page - The page number to validate.
133
+ * @returns Whether the page number is within range.
134
+ */
135
+ isPageValid(page: number): boolean;
136
+ /**
137
+ * @static Creates a new Paginator instance from a meta object.
138
+ * @param meta - A pagination metadata object.
139
+ * @returns A new Paginator instance.
140
+ */
141
+ static fromMeta(meta: FromMetaOptions): Paginator;
142
+ }
143
+ //#endregion
144
+ export { Paginator };