Skip to content

Commit

Permalink
fix: Redundant coalesce
Browse files Browse the repository at this point in the history
  • Loading branch information
oliversalzburg committed Dec 8, 2024
1 parent 62cf3ce commit dac7d35
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions source/format/count.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { coalesceArray, mustExist } from "../data/nil.js";
import { mustExist } from "../data/nil.js";

/**
* Convert counts to a human readable string: `1234` → `1.234K`.
Expand Down Expand Up @@ -27,10 +27,8 @@ export const parseCount = (count: string, locale?: string): number => {
notation: "compact",
});
const parts = format.formatToParts(-12345.6);
const orders = coalesceArray(
Array.from({ length: 20 }).map(
(_, i) => format.formatToParts(Math.pow(10, i)).find(d => d.type === "compact")?.value ?? "",
),
const orders = Array.from({ length: 20 }).map(
(_, i) => format.formatToParts(Math.pow(10, i)).find(d => d.type === "compact")?.value ?? "",
);
const numerals = Array.from({ length: 10 }).map((_, i) => format.format(i));
const index = new Map(numerals.map((d, i) => [d, i]));
Expand Down

0 comments on commit dac7d35

Please sign in to comment.