dsh-fishpal 0.9.0 → 0.9.5

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.
package/lib/guard.js CHANGED
@@ -336,3 +336,52 @@ export function expireQuarantine({ days = 7, now = new Date() } = {}) {
336
336
  fs.renameSync(tmp, file);
337
337
  return { expired: ids.length, ids };
338
338
  }
339
+
340
+ /**
341
+ * ��ҳ����һ�Ѽ�¼���г�һҳ����˵�塸���ж���û��ʾ����
342
+ *
343
+ * �� 2026-11-29 �������յ���Ʈƿ̫������ô�죿��
344
+ * ���������̺ͽ��涼����ƿ����һ���� 570 �ֽڡ�����ֻ�� 40 ������
345
+ * ������������ fishpal_review list �Ѵ���**ȫ��**�̳�����
346
+ * 200 �� �� 200 �� = �����֣�һ�ξͰ���������ijű���Ȼ����˭Ҳ������
347
+ *
348
+ * ��̫�ࡹ�������ݶ��ˣ���һ�θ����ˡ�
349
+ *
350
+ * �߽綼�����������ɢ�����ô���
351
+ * limit �Ƿ� / <= 0 �� Ĭ�� 20
352
+ * limit �������� �� �ⶥ��Ĭ�� 100��
353
+ * offset �Ƿ� / ���� �� 0
354
+ * offset �������� �� page Ϊ�ա�more Ϊ 0��oob=true�����÷�Ҫ˵�˻�������ɸ��ģ�
355
+ *
356
+ * @param {Array} list
357
+ * @param {object} opts
358
+ * @param {number} opts.limit
359
+ * @param {number} opts.offset
360
+ * @param {number} opts.maxLimit
361
+ * @returns {{page: Array, more: number, total: number, offset: number, limit: number, oob: boolean}}
362
+ */
363
+ export function pageOf(list, { limit = 20, offset = 0, maxLimit = 100 } = {}) {
364
+ const all = Array.isArray(list) ? list : [];
365
+ const total = all.length;
366
+
367
+ const lim = Number.isFinite(Number(limit)) && Number(limit) > 0
368
+ ? Math.min(Math.floor(Number(limit)), maxLimit)
369
+ : 20;
370
+ const off = Number.isFinite(Number(offset)) && Number(offset) > 0
371
+ ? Math.floor(Number(offset))
372
+ : 0;
373
+
374
+ if (off >= total) {
375
+ return { page: [], more: 0, total, offset: off, limit: lim, oob: total > 0 };
376
+ }
377
+
378
+ const page = all.slice(off, off + lim);
379
+ return {
380
+ page,
381
+ more: total - (off + page.length),
382
+ total,
383
+ offset: off,
384
+ limit: lim,
385
+ oob: false,
386
+ };
387
+ }