@kyvrixon/utils 0.0.4 → 0.0.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/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "@kyvrixon/utils",
3
3
  "main": "./src/index.ts",
4
- "version": "0.0.4",
4
+ "version": "0.0.5",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "license": "MIT",
8
8
  "files": [
9
9
  "src"
10
10
  ],
11
+ "scripts": {
12
+ "pub": "bun buildIndex.ts && bun publish --access public"
13
+ },
11
14
  "packageManager": "bun@1.3.6",
12
15
  "types": "./src/index.ts",
13
16
  "devDependencies": {
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
- export * from "./lib/logger";
2
1
  export * from "./lib/formatSeconds";
2
+ export * from "./lib/logger";
3
+ export * from "./lib/toOrdinal";
@@ -0,0 +1,16 @@
1
+ const suffixes: Record<string, string> = {
2
+ one: "st",
3
+ two: "nd",
4
+ few: "rd",
5
+ other: "th",
6
+ };
7
+
8
+ /**
9
+ * Converts a number to its ordinal value
10
+ *
11
+ * @param n Number to convert
12
+ * @returns string
13
+ */
14
+ export function toOrdinal(n: number): string {
15
+ return `${n}${suffixes[new Intl.PluralRules("en-US", { type: "ordinal" }).select(n)]}`;
16
+ }