@uxf/core 11.95.0 → 11.97.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.
package/README.md CHANGED
@@ -287,6 +287,18 @@ escapeQuotes('The "quick" fox');
287
287
  // Output: The \"quick\" fox
288
288
  ```
289
289
 
290
+ ## humanIndex
291
+
292
+ Converts a 0-based index to a 1-based (human-readable) index.
293
+
294
+ ```tsx
295
+ import { humanIndex } from "@uxf/core/utils/human-index";
296
+
297
+ humanIndex(0); /* returns 1 */
298
+ humanIndex(9); /* returns 10 */
299
+ humanIndex(-1); /* throws error */
300
+ ```
301
+
290
302
  ## filterNullish
291
303
 
292
304
  ```tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/core",
3
- "version": "11.95.0",
3
+ "version": "11.97.0",
4
4
  "description": "UXF Core",
5
5
  "author": "Petr Vejvoda <vejvoda@uxf.cz>",
6
6
  "homepage": "https://gitlab.com/uxf-npm/core#readme",
@@ -0,0 +1 @@
1
+ export declare function humanIndex(index: number): number;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.humanIndex = humanIndex;
4
+ function humanIndex(index) {
5
+ if (index < 0) {
6
+ throw Error("Negative indexes are not supported.");
7
+ }
8
+ return index + 1;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const human_index_1 = require("./human-index");
4
+ test("human-index", () => {
5
+ expect((0, human_index_1.humanIndex)(0)).toBe(1);
6
+ expect((0, human_index_1.humanIndex)(1)).toBe(2);
7
+ expect((0, human_index_1.humanIndex)(9)).toBe(10);
8
+ expect(() => (0, human_index_1.humanIndex)(-1)).toThrow();
9
+ });