bench_format.ts

Formatters for the numbers the site shows. Each is pinned to one locale, so a prerendered page and its hydrated copy print the same text.

view source

Declarations
#

10 declarations

format_bytes
#

bench_format.ts view source

(bytes: number): string import {format_bytes} from '@ryanatkn/syntax-highlighter-bench/bench_format.js';

A byte count in decimal units, where 1 kB is 1,000 bytes. A negative count keeps its sign, since a difference between two sizes can be one.

bytes

type number

returns

string

format_count
#

bench_format.ts view source

(n: number): string import {format_count} from '@ryanatkn/syntax-highlighter-bench/bench_format.js';

A count with thousands separators.

n

type number

returns

string

format_date
#

bench_format.ts view source

(iso: string): string import {format_date} from '@ryanatkn/syntax-highlighter-bench/bench_format.js';

The UTC date of an ISO timestamp, as YYYY-MM-DD.

iso

type string

returns

string

format_hash
#

bench_format.ts view source

(hash: string): string import {format_hash} from '@ryanatkn/syntax-highlighter-bench/bench_format.js';

A commit or content hash shortened for display, keeping a -dirty marker.

hash

type string

returns

string

format_ms
#

bench_format.ts view source

(ms: number): string import {format_ms} from '@ryanatkn/syntax-highlighter-bench/bench_format.js';

A duration given in milliseconds.

ms

type number

returns

string

format_ns
#

bench_format.ts view source

(ns: number): string import {format_ns} from '@ryanatkn/syntax-highlighter-bench/bench_format.js';

A duration given in nanoseconds, in the unit that keeps it readable.

ns

type number

returns

string

format_percent
#

bench_format.ts view source

(fraction: number): string import {format_percent} from '@ryanatkn/syntax-highlighter-bench/bench_format.js';

A fraction as a percentage: 0.033 is 3.3%.

fraction

type number

returns

string

format_ratio
#

bench_format.ts view source

(ratio: number): string import {format_ratio} from '@ryanatkn/syntax-highlighter-bench/bench_format.js';

A ratio as a factor: 1.00×, 12.3×, 140×.

ratio

type number

returns

string

format_significant
#

bench_format.ts view source

(n: number): string import {format_significant} from '@ryanatkn/syntax-highlighter-bench/bench_format.js';

A number to about three significant digits: two decimals under 10, one under 100, and a whole count from there.

n

type number

returns

string

HASH_LABEL_LENGTH
#

bench_format.ts view source

10 import {HASH_LABEL_LENGTH} from '@ryanatkn/syntax-highlighter-bench/bench_format.js';

How many characters of a hash the site prints.

Imported by
#