@oliversalzburg/js-utils 0.0.45-dev.8 → 0.0.45

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.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Convert counts to a human readable string: `1234` → `1.234K`.
3
+ * @param count - The count to format.
4
+ * @returns The formatted string.
5
+ * @group Formatting
6
+ */
7
+ export declare const formatCount: (count: number | bigint) => string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Convert counts to a human readable string: `1234` → `1.234K`.
3
+ * @param count - The count to format.
4
+ * @returns The formatted string.
5
+ * @group Formatting
6
+ */
7
+ export const formatCount = (count) => {
8
+ return new Intl.NumberFormat(undefined, {
9
+ compactDisplay: "short",
10
+ maximumFractionDigits: 3,
11
+ notation: "compact",
12
+ }).format(count);
13
+ };
14
+ //# sourceMappingURL=count.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"count.js","sourceRoot":"","sources":["../../source/format/count.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAsB,EAAU,EAAE;IAC5D,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE;QACtC,cAAc,EAAE,OAAO;QACvB,qBAAqB,EAAE,CAAC;QACxB,QAAQ,EAAE,SAAS;KACpB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { expect } from "chai";
2
+ import { it } from "mocha";
3
+ import { formatCount } from "./count.js";
4
+ it("formats counts as expected", () => {
5
+ expect(formatCount(-1)).to.equal("-1");
6
+ expect(formatCount(0)).to.equal("0");
7
+ expect(formatCount(1)).to.equal("1");
8
+ expect(formatCount(10)).to.equal("10");
9
+ expect(formatCount(100)).to.equal("100");
10
+ expect(formatCount(1000)).to.equal("1K");
11
+ expect(formatCount(1234)).to.equal("1.234K");
12
+ });
13
+ //# sourceMappingURL=count.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"count.test.js","sourceRoot":"","sources":["../../source/format/count.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;IACpC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
package/format/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./bytes.js";
2
+ export * from "./count.js";
2
3
  export * from "./milliseconds.js";
3
4
  export * from "./string.js";
package/format/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./bytes.js";
2
+ export * from "./count.js";
2
3
  export * from "./milliseconds.js";
3
4
  export * from "./string.js";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/format/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/format/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@oliversalzburg/js-utils",
4
- "version": "0.0.45-dev.8",
4
+ "version": "0.0.45",
5
5
  "license": "MIT",
6
6
  "author": "Oliver Salzburg <oliver.salzburg@gmail.com>",
7
7
  "repository": {
@@ -42,14 +42,14 @@
42
42
  "@types/chai": "4.3.16",
43
43
  "@types/eslint": "8.56.10",
44
44
  "@types/mocha": "10.0.6",
45
- "@types/node": "20.12.12",
45
+ "@types/node": "20.12.13",
46
46
  "@types/web": "0.0.147",
47
47
  "c8": "9.1.0",
48
48
  "chai": "5.1.1",
49
49
  "eslint": "8.57.0",
50
50
  "eslint-config-prettier": "9.1.0",
51
- "eslint-plugin-jsdoc": "48.2.6",
52
- "eslint-plugin-tsdoc": "0.2.17",
51
+ "eslint-plugin-jsdoc": "48.2.7",
52
+ "eslint-plugin-tsdoc": "0.3.0",
53
53
  "globals": "15.3.0",
54
54
  "lint-staged": "15.2.5",
55
55
  "mocha": "10.4.0",