@zudojs/types 1.1.1 → 1.2.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.
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Runtime type conversion helpers: JSON parsing, string/number/boolean conversion, case transforms.
2
+ * Runtime type conversion helpers: JSON parsing, string/number/boolean conversion, case transforms, count formatting.
3
3
  *
4
4
  * @module typeConverters
5
5
  */
6
6
  export { safeJsonParse, toString, toNumber, toBoolean, toArray, mapToObject, objectToMap, snakeToCamel, camelToSnake, kebabToCamel, camelToKebab, } from "./typeConverters.core.js";
7
+ export { formatCount } from "./typeConverters.count.js";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Runtime type conversion helpers: JSON parsing, string/number/boolean conversion, case transforms.
2
+ * Runtime type conversion helpers: JSON parsing, string/number/boolean conversion, case transforms, count formatting.
3
3
  *
4
4
  * @module typeConverters
5
5
  */
6
6
  export { safeJsonParse, toString, toNumber, toBoolean, toArray, mapToObject, objectToMap, snakeToCamel, camelToSnake, kebabToCamel, camelToKebab, } from "./typeConverters.core.js";
7
+ export { formatCount } from "./typeConverters.count.js";
7
8
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Count-and-noun formatting for human-readable messages.
3
+ *
4
+ * @module typeConverters/count
5
+ */
6
+ /**
7
+ * Formats a count with the singular or plural form of a noun, so messages
8
+ * read "at least 1 character" rather than "at least 1 characters".
9
+ *
10
+ * Only an exact count of 1 (or -1) is singular; 0, fractions and everything
11
+ * else take the plural. The plural defaults to the singular plus "s"; pass it
12
+ * explicitly for irregular nouns.
13
+ *
14
+ * @example
15
+ * formatCount(1, "character"); // "1 character"
16
+ * formatCount(3, "item"); // "3 items"
17
+ * formatCount(2, "entry", "entries"); // "2 entries"
18
+ */
19
+ export declare function formatCount(count: number, singular: string, plural?: string): string;
20
+ //# sourceMappingURL=typeConverters.count.d.ts.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Count-and-noun formatting for human-readable messages.
3
+ *
4
+ * @module typeConverters/count
5
+ */
6
+ /**
7
+ * Formats a count with the singular or plural form of a noun, so messages
8
+ * read "at least 1 character" rather than "at least 1 characters".
9
+ *
10
+ * Only an exact count of 1 (or -1) is singular; 0, fractions and everything
11
+ * else take the plural. The plural defaults to the singular plus "s"; pass it
12
+ * explicitly for irregular nouns.
13
+ *
14
+ * @example
15
+ * formatCount(1, "character"); // "1 character"
16
+ * formatCount(3, "item"); // "3 items"
17
+ * formatCount(2, "entry", "entries"); // "2 entries"
18
+ */
19
+ export function formatCount(count, singular, plural = `${singular}s`) {
20
+ return `${count} ${Math.abs(count) === 1 ? singular : plural}`;
21
+ }
22
+ //# sourceMappingURL=typeConverters.count.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zudojs/types",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Shared type guards, utility types, and type converters for the Zudojs framework.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -29,9 +29,9 @@
29
29
  "node": ">=24.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/node": "^26.4.1",
32
+ "@types/node": "^26.6.2",
33
33
  "typescript": "7.0.2",
34
- "vitest": "^4.1.11"
34
+ "vitest": "^5.0.1"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
@@ -42,7 +42,7 @@
42
42
  "type-guards",
43
43
  "utilities"
44
44
  ],
45
- "homepage": "https://github.com/oyinlola-tech/zudo#readme",
45
+ "homepage": "https://zudojs.oyinlola.site/docs/packages-types",
46
46
  "bugs": {
47
47
  "url": "https://github.com/oyinlola-tech/zudo/issues"
48
48
  },