Improved overall structure

This commit is contained in:
squidfunk
2020-02-20 14:44:41 +01:00
parent 9b0410962d
commit 3aa251fb03
26 changed files with 241 additions and 224 deletions

View File

@@ -81,14 +81,13 @@ export function truncate(value: string, n: number): string {
/**
* Round a number for display with source facts
*
* This is a reverse engineered implementation of GitHub's weird rounding
* algorithm for stars, forks and all other numbers. While all numbers below
* `1,000` are returned as-is, bigger numbers are converted to fixed numbers
* in the following way:
* This is a reverse engineered version of GitHub's weird rounding algorithm
* for stars, forks and all other numbers. While all numbers below `1,000` are
* returned as-is, bigger numbers are converted to fixed numbers:
*
* - `1,049` => `1k`
* - `1,050` => `1,1k`
* - `1,949` => `1,9k`
* - `1,050` => `1.1k`
* - `1,949` => `1.9k`
* - `1,950` => `2k`
*
* @param value - Original value