results_filters.ts

What a reader has selected on the results page, and its form as a URL query, so a comparison is a link. The choices come from the results file, so a new library or language needs no change here.

Decoding never throws: an unknown key is ignored, an unknown id is dropped, and a parameter left with nothing valid falls back to its default.

view source

Declarations
#

17 declarations

decode_results_filters
#

results_filters.ts view source

(params: Pick<URLSearchParams, "get">, options: ResultsFilterOptions, defaults: ResultsFilters): ResultsFilters import {decode_results_filters} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

Reads a selection from a query. Ids come back in the order of options, each once.

params

the query, which may hold anything

type Pick<URLSearchParams, "get">

options

the ids each filter can hold

defaults

what a filter is when its parameter is absent or holds nothing valid

returns

ResultsFilters

DEFAULT_FORM
#

results_filters.ts view source

"bundled" import {DEFAULT_FORM} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

The form of a cold start selected by default: the chunk whose size is reported.

DEFAULT_OUTPUT_COMPRESSION
#

results_filters.ts view source

"raw" import {DEFAULT_OUTPUT_COMPRESSION} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

How the HTML's size is shown by default: raw, as the output table has always shown it.

DEFAULT_SET
#

results_filters.ts view source

"docs" import {DEFAULT_SET} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

The set summed by default, when the file has it: what a documentation site imports.

DEFAULT_SOURCE
#

results_filters.ts view source

"neutral" import {DEFAULT_SOURCE} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

The source selected by default: the primary set, which no measured library authored.

encode_results_filters
#

results_filters.ts view source

(filters: ResultsFilters, defaults: ResultsFilters): URLSearchParams import {encode_results_filters} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

The query that restores a selection. Only what differs from the defaults is written, so the default view has an empty query. A list is its ids joined by commas, and an empty list is an empty value.

filters

defaults

returns

URLSearchParams

REFERENCE_PARAM
#

results_filters.ts view source

"reference" import {REFERENCE_PARAM} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

The query parameter of the reference library.

RESULTS_CHOICE_KEYS
#

results_filters.ts view source

readonly ["unit", "bundle", "compression", "output_compression", "set"] import {RESULTS_CHOICE_KEYS} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

The filters that hold one id.

RESULTS_LIST_KEYS
#

results_filters.ts view source

readonly ["metrics", "libraries", "engines", "outputs", "langs", "sizes", "modes", "sources", "forms", "measures", "parts"] import {RESULTS_LIST_KEYS} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

The filters that hold several ids.

RESULTS_METRICS
#

results_filters.ts view source

readonly { id: ResultsMetric; label: string; }[] import {RESULTS_METRICS} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

Every section, with its label, in display order.

ResultsFilterOptions
#

results_filters.ts view source

ResultsFilterOptions

type Record<"set" | "libraries" | "langs" | "sizes" | "modes" | "sources" | "metrics" | "bundle" | "engines" | "outputs" | "forms" | "measures" | "parts" | "unit" | "compression" | "output_compression", string[]> & { set_aliases: Record<string, string>; }

import type {ResultsFilterOptions} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

The ids each filter can hold, in display order.

set

type string[]

libraries

type string[]

langs

type string[]

sizes

type string[]

modes

type string[]

sources

type string[]

metrics

type string[]

bundle

type string[]

engines

type string[]

outputs

type string[]

forms

type string[]

measures

type string[]

parts

type string[]

unit

type string[]

compression

type string[]

output_compression

type string[]

set_aliases

Other ids a link may use for a set, each mapped to the id that stands for it: a set holding the same languages as another is shown under one id.

type Record<string, string>

ResultsFilters
#

results_filters.ts view source

ResultsFilters

type Record<"libraries" | "langs" | "sizes" | "modes" | "sources" | "metrics" | "engines" | "outputs" | "forms" | "measures" | "parts", string[]> & Record<"set" | "bundle" | "unit" | "compression" | "output_compression", string> & { reference: string | null; }

import type {ResultsFilters} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

What a reader has selected on the results page.

libraries

type string[]

langs

type string[]

sizes

type string[]

modes

type string[]

sources

type string[]

metrics

type string[]

engines

type string[]

outputs

type string[]

forms

type string[]

measures

type string[]

parts

type string[]

set

type string

bundle

type string

unit

type string

compression

type string

output_compression

type string

reference

The library every ratio is taken against, or null for the best in each row.

type string | null

ResultsMetric
#

results_filters.ts view source

ResultsMetric

type "throughput" | "startup" | "output" | "bundle" | "heap"

import type {ResultsMetric} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

A section of the results page.

to_default_results_filters
#

results_filters.ts view source

(options: ResultsFilterOptions): ResultsFilters import {to_default_results_filters} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

The selection a reader starts from: everything, except the sources, where only the neutral inputs are selected, the forms of a cold start, where only the bundled one is, and the parts of a retained heap, where only the sum is. Bundle sizes start gzipped and HTML sizes raw.

options

returns

ResultsFilters

to_results_filter_options
#

to_selected_libraries
#

results_filters.ts view source

(libraries: readonly { id: string; label: string; package: string; version: string; output: "classes" | "inline_styles"; engine: "scanner" | "grammar_vm" | "regex" | "textmate"; by_maintainer: boolean; note: string | null; theme_schemes: ("light" | "dark")[]; extra_packages?: Record<...> | undefined; }[], filters: Pick<...>): { ...; }[] import {to_selected_libraries} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

The libraries a selection shows, in roster order: the selected ones whose engine kind and output shape are selected too.

libraries

type readonly BenchLibrary[]

filters

type Pick<ResultsFilters, "libraries" | "engines" | "outputs">

returns

BenchLibrary[]

to_selected_reference
#

results_filters.ts view source

(selected: readonly { id: string; label: string; package: string; version: string; output: "classes" | "inline_styles"; engine: "scanner" | "grammar_vm" | "regex" | "textmate"; by_maintainer: boolean; note: string | null; theme_schemes: ("light" | "dark")[]; extra_packages?: Record<...> | undefined; }[], filters: Pick<...>): string | null import {to_selected_reference} from '@ryanatkn/syntax-highlighter-bench/results_filters.js';

The reference library a selection's ratios are taken against, or null for the best in each row: a reference that isn't among the libraries shown is ignored.

selected

type readonly BenchLibrary[]

filters

type Pick<ResultsFilters, "reference">

returns

string | null

Depends on
#

Imported by
#