Functional Weave
Code in TypeScript

Every capability

Ordered by level: primitives at the bottom of the graph, workflows at the top. Each one carries its own tests, at least 8 per function.

Suites — the capabilities a kind of app is built from: accounting, payroll, an online shop, a clinic…

Collection: React form elements — accessible form components for React, and the pure helpers they use.

Level 0 primitive

charts.color
Hex colours to RGB and back, and sRGB channels to linear light and back, identically in every language.
A group of 4: parseHex, toHex, srgbToLinear, linearToSrgb
charts.contrast
WCAG 2.x contrast ratio between two colours, and which text colour reads best on a background.
A group of 2: contrastRatio, readableTextColor
charts.extent
The minimum and maximum of a series as [min, max], skipping gaps (null), or null when there is no value.
extent in TypeScript
crypto.sha256
The SHA-256 digest of a byte string (FIPS 180-4), in pure code that also runs in the browser.
sha256 in TypeScript
encoding.base64
Bytes to base64 and base64url text and back (RFC 4648), with strict decoding, identically in every language.
A group of 4: base64Encode, base64Decode, base64UrlEncode, base64UrlDecode
encoding.hex
Bytes to lowercase hexadecimal text and back (RFC 4648 base16), strictly, identically in every language.
A group of 2: hexEncode, hexDecode
encoding.utf8
Text to UTF-8 bytes and strictly back (RFC 3629), so hashing and signing see the same bytes in every language.
A group of 2: utf8Encode, utf8Decode

Level 1 generic concept

auth.jwt
Sign, verify and decode HS256 JSON Web Tokens (RFC 7519): signature, algorithm and exp/nbf/iat checked with leeway.
A group of 3: signJwt, verifyJwt, decodeJwt
charts.format
Axis and label text for charts: tick numbers, SI prefixes (1.2k, 3.4M), percentages, dates and money.
A group of 5: formatTick, formatSi, formatPercent, formatDate, formatMoneyTick
charts.scale
Map data values onto screen positions and back: linear, log, time, band and point scales, and nice domains.
A group of 7: linearScale, invertLinear, niceDomain, logScale, timeScale, bandScale, pointScale
charts.ticks
Axis ticks: a round step (1, 2 or 5 x 10^k), the ticks on it, and calendar ticks from days to years.
A group of 4: tickStep, niceTicks, timeTickInterval, timeTicks
energy.gas-kwh
Convert gas meter units (cubic metres or hundreds of cubic feet) to kWh with the calorific value and 1.02264 correction.
gasKwh in TypeScript
fleet.emissions
Vehicle greenhouse gas emissions (grams CO2e) from fuel used or distance, using UK government DESNZ conversion factors.
fleetEmissions in TypeScript
form.state TypeScript only
A form's state as a pure reducer: values, touched fields, validator errors and the submit, for useReducer.
A group of 3: initialFormState, formReducer, visibleErrors
health.egfr Unreviewed
eGFR in mL/min/1.73 m² by the race-free CKD-EPI 2021 creatinine equation, from creatinine in µmol/L or mg/dL.
egfrCkdEpi2021 in TypeScript

Level 2 domain function

auth.access-token
Issue an API's HS256 access token, read one from an Authorization header, and refuse revoked or superseded ones.
A group of 3: issueAccessToken, readAccessToken, confirmAccessToken
auth.password-hash
Hash a password for storage as pbkdf2_sha256$iterations$salt$hash, verify one in constant time, and spot weak hashes.
A group of 3: hashPassword, verifyPassword, passwordNeedsRehash
charts.axis
Axis geometry as data: tick positions, tick marks, label anchors and gridlines for number, time and category axes.
A group of 5: axisFromTicks, numberAxis, timeAxis, bandAxis, gridLines
charts.layout
Chart layout: the plot area inside margins, legend items wrapped into rows, and greedy label collision avoidance.
A group of 3: plotArea, legendRows, avoidCollisions
charts.shape
SVG path strings for lines, areas, steps, monotone curves, bars, arcs and pie slices, identical in every language.
A group of 7: linePath, areaPath, stepPath, monotoneCurve, barRects, arcPath, pieAngles
dates.uk-tax-year
The UK personal tax year containing a date: 6 April to 5 April, with HMRC's label.
ukTaxYear in TypeScript
finance.tax.remove-vat Unreviewed
Extract the VAT already included in a gross amount, using the rate in force on the date of supply.
removeVat in TypeScript
finance.tax.vat-rate Unreviewed
Look up the VAT rate in force for a jurisdiction, category and date.
vatRate in TypeScript

Level 3 business operation