@simcups/swiss-tools 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 (53) hide show
  1. package/dist/array-utils.d.ts +4 -0
  2. package/dist/array-utils.d.ts.map +1 -0
  3. package/dist/array-utils.js +11 -0
  4. package/dist/array-utils.js.map +1 -0
  5. package/dist/chunk-pots.d.ts +2 -0
  6. package/dist/chunk-pots.d.ts.map +1 -0
  7. package/dist/chunk-pots.js +7 -0
  8. package/dist/chunk-pots.js.map +1 -0
  9. package/dist/delay.d.ts +2 -0
  10. package/dist/delay.d.ts.map +1 -0
  11. package/dist/delay.js +2 -0
  12. package/dist/delay.js.map +1 -0
  13. package/dist/errors.d.ts +4 -0
  14. package/dist/errors.d.ts.map +1 -0
  15. package/dist/errors.js +7 -0
  16. package/dist/errors.js.map +1 -0
  17. package/dist/get-number-with-sign.d.ts +2 -0
  18. package/dist/get-number-with-sign.d.ts.map +1 -0
  19. package/dist/get-number-with-sign.js +6 -0
  20. package/dist/get-number-with-sign.js.map +1 -0
  21. package/dist/get-ordinal.d.ts +2 -0
  22. package/dist/get-ordinal.d.ts.map +1 -0
  23. package/dist/get-ordinal.js +16 -0
  24. package/dist/get-ordinal.js.map +1 -0
  25. package/dist/get-percentage.d.ts +2 -0
  26. package/dist/get-percentage.d.ts.map +1 -0
  27. package/dist/get-percentage.js +4 -0
  28. package/dist/get-percentage.js.map +1 -0
  29. package/dist/has-vals.d.ts +2 -0
  30. package/dist/has-vals.d.ts.map +1 -0
  31. package/dist/has-vals.js +14 -0
  32. package/dist/has-vals.js.map +1 -0
  33. package/dist/index.d.ts +13 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +13 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/is-even.d.ts +2 -0
  38. package/dist/is-even.d.ts.map +1 -0
  39. package/dist/is-even.js +2 -0
  40. package/dist/is-even.js.map +1 -0
  41. package/dist/is-number.d.ts +2 -0
  42. package/dist/is-number.d.ts.map +1 -0
  43. package/dist/is-number.js +4 -0
  44. package/dist/is-number.js.map +1 -0
  45. package/dist/pagination-helpers.d.ts +8 -0
  46. package/dist/pagination-helpers.d.ts.map +1 -0
  47. package/dist/pagination-helpers.js +21 -0
  48. package/dist/pagination-helpers.js.map +1 -0
  49. package/dist/power-of-2.d.ts +3 -0
  50. package/dist/power-of-2.d.ts.map +1 -0
  51. package/dist/power-of-2.js +14 -0
  52. package/dist/power-of-2.js.map +1 -0
  53. package/package.json +30 -0
@@ -0,0 +1,4 @@
1
+ export declare function hasItems(arr: unknown): arr is unknown[];
2
+ export declare function createArraySize(size: number): number[];
3
+ export declare const arrayRange: (start: number, stop: number, step: number) => number[];
4
+ //# sourceMappingURL=array-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-utils.d.ts","sourceRoot":"","sources":["../src/array-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,EAAE,CAEvD;AACD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAItD;AAED,eAAO,MAAM,UAAU,GACrB,OAAO,MAAM,EACb,MAAM,MAAM,EACZ,MAAM,MAAM,KACX,MAAM,EAGN,CAAC"}
@@ -0,0 +1,11 @@
1
+ export function hasItems(arr) {
2
+ return Array.isArray(arr) && arr.length > 0;
3
+ }
4
+ export function createArraySize(size) {
5
+ return Array(size)
6
+ .fill(null)
7
+ .map((_, i) => i);
8
+ }
9
+ // // https://www.freecodecamp.org/news/javascript-range-create-an-array-of-numbers-with-the-from-method/
10
+ export const arrayRange = (start, stop, step) => Array.from({ length: (stop - start) / step + 1 }, (value, index) => index === 0 ? start : index * step);
11
+ //# sourceMappingURL=array-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-utils.js","sourceRoot":"","sources":["../src/array-utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,GAAY;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9C,CAAC;AACD,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,KAAK,CAAC,IAAI,CAAC;SACf,IAAI,CAAC,IAAI,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC;AACD,yGAAyG;AACzG,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,KAAa,EACb,IAAY,EACZ,IAAY,EACF,EAAE,CACZ,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CACjE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CACnC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function chunkPots<T>(list: T[], minParticipantCountPerPot: number): T[][];
2
+ //# sourceMappingURL=chunk-pots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-pots.d.ts","sourceRoot":"","sources":["../src/chunk-pots.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,yBAAyB,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAOhF"}
@@ -0,0 +1,7 @@
1
+ export function chunkPots(list, minParticipantCountPerPot) {
2
+ const clonedList = structuredClone(list);
3
+ const rest = clonedList.length % minParticipantCountPerPot;
4
+ const pots = Math.floor(list.length / minParticipantCountPerPot);
5
+ return Array.from({ length: pots }, (_, i) => clonedList.splice(0, minParticipantCountPerPot + (i === pots - 1 ? rest : 0)));
6
+ }
7
+ //# sourceMappingURL=chunk-pots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-pots.js","sourceRoot":"","sources":["../src/chunk-pots.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAI,IAAS,EAAE,yBAAiC;IACvE,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,GAAG,yBAAyB,CAAC;IAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,yBAAyB,CAAC,CAAC;IACjE,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAC3C,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,yBAAyB,GAAG,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC9E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const delay: (ms: number) => Promise<unknown>;
2
+ //# sourceMappingURL=delay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../src/delay.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,qBAA4C,CAAA"}
package/dist/delay.js ADDED
@@ -0,0 +1,2 @@
1
+ export const delay = (ms) => new Promise(res => setTimeout(res, ms));
2
+ //# sourceMappingURL=delay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delay.js","sourceRoot":"","sources":["../src/delay.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare class AppError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;gBACrB,OAAO,EAAE,MAAM;CAI5B"}
package/dist/errors.js ADDED
@@ -0,0 +1,7 @@
1
+ export class AppError extends Error {
2
+ constructor(message) {
3
+ super(`${message}`);
4
+ this.name = "AppError";
5
+ }
6
+ }
7
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,YAAY,OAAe;QACzB,KAAK,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export declare function formatSignedNumber(myNumber: number): string;
2
+ //# sourceMappingURL=get-number-with-sign.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-number-with-sign.d.ts","sourceRoot":"","sources":["../src/get-number-with-sign.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,UAIlD"}
@@ -0,0 +1,6 @@
1
+ export function formatSignedNumber(myNumber) {
2
+ return new Intl.NumberFormat("en-US", {
3
+ signDisplay: "exceptZero",
4
+ }).format(myNumber);
5
+ }
6
+ //# sourceMappingURL=get-number-with-sign.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-number-with-sign.js","sourceRoot":"","sources":["../src/get-number-with-sign.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;QACpC,WAAW,EAAE,YAAY;KAC1B,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACtB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function getOrdinal(num: number): string;
2
+ //# sourceMappingURL=get-ordinal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-ordinal.d.ts","sourceRoot":"","sources":["../src/get-ordinal.ts"],"names":[],"mappings":"AAYA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI9C"}
@@ -0,0 +1,16 @@
1
+ const english_ordinal_rules = new Intl.PluralRules("en", { type: "ordinal" });
2
+ // Define the type for the record to match the Intl output
3
+ const suffixes = {
4
+ one: "st",
5
+ two: "nd",
6
+ few: "rd",
7
+ other: "th",
8
+ zero: "th", // Added to satisfy the full type
9
+ many: "th", // Added to satisfy the full type
10
+ };
11
+ export function getOrdinal(num) {
12
+ const category = english_ordinal_rules.select(num);
13
+ const suffix = suffixes[category];
14
+ return `${num}${suffix}`;
15
+ }
16
+ //# sourceMappingURL=get-ordinal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-ordinal.js","sourceRoot":"","sources":["../src/get-ordinal.ts"],"names":[],"mappings":"AAAA,MAAM,qBAAqB,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AAE9E,0DAA0D;AAC1D,MAAM,QAAQ,GAAwC;IACpD,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,IAAI,EAAG,iCAAiC;IAC9C,IAAI,EAAE,IAAI,EAAG,iCAAiC;CAC/C,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,MAAM,QAAQ,GAAG,qBAAqB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAClC,OAAO,GAAG,GAAG,GAAG,MAAM,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function getPercentage(targetValue: number, total: number): number;
2
+ //# sourceMappingURL=get-percentage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-percentage.d.ts","sourceRoot":"","sources":["../src/get-percentage.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAE/D"}
@@ -0,0 +1,4 @@
1
+ export function getPercentage(targetValue, total) {
2
+ return Math.round((targetValue / total) * 100);
3
+ }
4
+ //# sourceMappingURL=get-percentage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-percentage.js","sourceRoot":"","sources":["../src/get-percentage.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,WAAmB,EAAE,KAAa;IAC9D,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function hasVal(val: string | number | any): val is string;
2
+ //# sourceMappingURL=has-vals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-vals.d.ts","sourceRoot":"","sources":["../src/has-vals.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,GAAG,IAAI,MAAM,CAahE"}
@@ -0,0 +1,14 @@
1
+ export function hasVal(val) {
2
+ if (val === null ||
3
+ val === undefined ||
4
+ val === "null" ||
5
+ val === "undefined" ||
6
+ val === "" ||
7
+ !String(val).trim()) {
8
+ return false;
9
+ }
10
+ else {
11
+ return true;
12
+ }
13
+ }
14
+ //# sourceMappingURL=has-vals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-vals.js","sourceRoot":"","sources":["../src/has-vals.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,MAAM,CAAC,GAA0B;IAC/C,IACE,GAAG,KAAK,IAAI;QACZ,GAAG,KAAK,SAAS;QACjB,GAAG,KAAK,MAAM;QACd,GAAG,KAAK,WAAW;QACnB,GAAG,KAAK,EAAE;QACV,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EACnB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ export * from './array-utils';
2
+ export * from './chunk-pots';
3
+ export * from './delay';
4
+ export * from './errors';
5
+ export * from './get-number-with-sign';
6
+ export * from './get-ordinal';
7
+ export * from './get-percentage';
8
+ export * from './has-vals';
9
+ export * from './is-even';
10
+ export * from './is-number';
11
+ export * from './pagination-helpers';
12
+ export * from './power-of-2';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ export * from './array-utils';
2
+ export * from './chunk-pots';
3
+ export * from './delay';
4
+ export * from './errors';
5
+ export * from './get-number-with-sign';
6
+ export * from './get-ordinal';
7
+ export * from './get-percentage';
8
+ export * from './has-vals';
9
+ export * from './is-even';
10
+ export * from './is-number';
11
+ export * from './pagination-helpers';
12
+ export * from './power-of-2';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const isEven: (num: number) => boolean;
2
+ //# sourceMappingURL=is-even.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-even.d.ts","sourceRoot":"","sources":["../src/is-even.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,YAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const isEven = (num) => num % 2 === 0;
2
+ //# sourceMappingURL=is-even.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-even.js","sourceRoot":"","sources":["../src/is-even.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const isNumber: (value: unknown) => value is number;
2
+ //# sourceMappingURL=is-number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-number.d.ts","sourceRoot":"","sources":["../src/is-number.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAElD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export const isNumber = (value) => {
2
+ return typeof value === 'number' && Number.isFinite(value);
3
+ };
4
+ //# sourceMappingURL=is-number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-number.js","sourceRoot":"","sources":["../src/is-number.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE;IACxD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare function getOffset(page: number, itemsPerPage: number): number;
2
+ export declare function getPagination<T>(list: T[], page: number, itemsPerPage: number): {
3
+ total: number;
4
+ page: number;
5
+ items: T[];
6
+ };
7
+ export declare function getTotalPages(listLength: number, itemsPerPage: number): number;
8
+ //# sourceMappingURL=pagination-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination-helpers.d.ts","sourceRoot":"","sources":["../src/pagination-helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAUpE;AAED,wBAAgB,aAAa,CAAC,CAAC,EAC7B,IAAI,EAAE,CAAC,EAAE,EACT,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GACnB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,EAAE,CAAA;CAAE,CAM7C;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAErE"}
@@ -0,0 +1,21 @@
1
+ export function getOffset(page, itemsPerPage) {
2
+ if (isNaN(page)) {
3
+ page = 1;
4
+ }
5
+ let offset = (page - 1) * itemsPerPage;
6
+ if (offset < 0) {
7
+ offset = 0;
8
+ }
9
+ return offset;
10
+ }
11
+ export function getPagination(list, page, itemsPerPage) {
12
+ return {
13
+ total: getTotalPages(list.length, itemsPerPage),
14
+ items: list.slice((page - 1) * itemsPerPage, page * itemsPerPage),
15
+ page: page,
16
+ };
17
+ }
18
+ export function getTotalPages(listLength, itemsPerPage) {
19
+ return Math.ceil(listLength / itemsPerPage);
20
+ }
21
+ //# sourceMappingURL=pagination-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination-helpers.js","sourceRoot":"","sources":["../src/pagination-helpers.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,YAAoB;IAC1D,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAChB,IAAI,GAAG,CAAC,CAAC;IACX,CAAC;IACD,IAAI,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC;IAEvC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,MAAM,GAAG,CAAC,CAAC;IACb,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,IAAS,EACT,IAAY,EACZ,YAAoB;IAEpB,OAAO;QACL,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC;QAC/C,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,YAAY,EAAE,IAAI,GAAG,YAAY,CAAC;QACjE,IAAI,EAAE,IAAI;KACX,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,UAAkB,EAAE,YAAoB;IACpE,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const nextPowerOf2: (num: number) => number;
2
+ export declare function nearestPowerOf2(n: number): number;
3
+ //# sourceMappingURL=power-of-2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"power-of-2.d.ts","sourceRoot":"","sources":["../src/power-of-2.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,WASvC,CAAC;AAEF,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,UAExC"}
@@ -0,0 +1,14 @@
1
+ export const nextPowerOf2 = (num) => {
2
+ if (num > 0 && (num & (num - 1)) === 0)
3
+ return num;
4
+ let result = 1;
5
+ while (num > 0) {
6
+ result = result << 1;
7
+ num = num >> 1;
8
+ }
9
+ return result;
10
+ };
11
+ export function nearestPowerOf2(n) {
12
+ return 1 << (31 - Math.clz32(n));
13
+ }
14
+ //# sourceMappingURL=power-of-2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"power-of-2.js","sourceRoot":"","sources":["../src/power-of-2.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,EAAE;IACxC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACnD,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,OAAO,GAAG,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,GAAG,MAAM,IAAI,CAAC,CAAC;QACrB,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,UAAU,eAAe,CAAC,CAAS;IACrC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@simcups/swiss-tools",
3
+ "version": "1.0.0",
4
+ "description": "Slim utility.",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "prepare": "npm run build",
19
+ "prepublishOnly": "npm run build",
20
+ "clean": "rm -rf dist"
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "author": "kaichunglau <laukaichung@simcups.com>",
26
+ "license": "MIT",
27
+ "devDependencies": {
28
+ "typescript": "^6.0.2"
29
+ }
30
+ }