Functional Weave
Code in Python

Capabilities for no framework · stable

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

encoding.hex
Bytes to lowercase hexadecimal text and back (RFC 4648 base16), strictly, identically in every language.
A group of 2: hex_encode, hex_decode
math.exp
e to the power x from + - * / only, so TypeScript, Python and Rust return the same double for the same input.
exp in Python
validation.gtin
Check an EAN-8, UPC-A, EAN-13 or GTIN-14 barcode number against the GS1 mod-10 check digit.
validate_gtin in Python
encoding.base64
Bytes to base64 and base64url text and back (RFC 4648), with strict decoding, identically in every language.
A group of 4: base64_encode, base64_decode, base64_url_encode, base64_url_decode
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: utf8_encode, utf8_decode
logistics.sscc
Build an 18-digit SSCC pallet label number from extension digit, GS1 company prefix and serial, with its check digit.
build_sscc in Python
math.clamp
Clamp an integer to an inclusive range, refusing a range whose bounds are the wrong way round.
clamp in Python
text.mask
Mask all but the last n characters of a card, account or phone number, optionally keeping separators.
mask in Python
math.basis-points
Convert a rate between percent, basis points and a plain ratio exactly, as decimal text or integer basis points.
A group of 3: convert_rate, to_basis_points, from_basis_points
math.pow
base to the power exponent from + - * / only, exact by squaring for whole exponents, identical in every language.
pow in Python
math.sin-cos
Sine and cosine of an angle in radians from + - * / only, so every language returns the same doubles.
sin_cos in Python
charts.contrast
WCAG 2.x contrast ratio between two colours, and which text colour reads best on a background.
A group of 2: contrast_ratio, readable_text_color
math.atan
Arctangent in radians from + - * / only (fdlibm's method), so every language returns the same double.
atan in Python
math.ln
Natural logarithm from + - * / only, so TypeScript, Python and Rust return the same double for the same input.
ln in Python

Level 1 generic concept

charts.scale
Map data values onto screen positions and back: linear, log, time, band and point scales, and nice domains.
A group of 7: linear_scale, invert_linear, nice_domain, log_scale, time_scale, band_scale, point_scale
fleet.emissions
Vehicle greenhouse gas emissions (grams CO2e) from fuel used or distance, using UK government DESNZ conversion factors.
fleet_emissions in Python
money.compare
Compare two amounts of one currency, refusing to compare across currencies; min, max and clamp too.
A group of 4: compare_money, min_money, max_money, clamp_money
money.parse
Parse "£1,234.50" or "1.234,50 €" into integer minor units, strictly: no guessing, no rounding.
parse_money in Python
net.ipv4
Parse, format and check dotted-quad IPv4 addresses, refusing leading zeros, octal, hex and short forms.
A group of 3: parse_ipv4, format_ipv4, is_ipv4
math.rational
Exact fraction arithmetic, always reduced, for rates and ratios that must not drift.
A group of 8: calculate_rational, rational, add_rational, subtract_rational, multiply_rational, divide_rational, compare_rational, rational_to_integer
money.sum
Total a list of monetary amounts, with an explicit currency for the empty case.
sum_money in Python
net.cidr
CIDR blocks: network, broadcast, first and last host, host count, netmask and prefix, and membership.
A group of 5: cidr_info, cidr_contains, is_cidr, prefix_to_netmask, netmask_to_prefix
net.ipv6
Parse IPv6 addresses and write them in RFC 5952 canonical form: lower-case, zeros compressed, IPv4 embedded.
A group of 3: parse_ipv6, format_ipv6, is_ipv6
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: sign_jwt, verify_jwt, decode_jwt
charts.format
Axis and label text for charts: tick numbers, SI prefixes (1.2k, 3.4M), percentages, dates and money.
A group of 5: format_tick, format_si, format_percent, format_date, format_money_tick
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: tick_step, nice_ticks, time_tick_interval, time_ticks
form.state TypeScript only
A form's state as a pure reducer: values, touched fields, validator errors and the submit, for useReducer.
Not available in Python
net.port
Check a TCP/UDP port number and name the IANA service registered on it, with its system/user/dynamic range.
A group of 2: is_port, port_service
text.slugify
Turn a title into a lowercase ASCII URL slug, transliterating common accented Latin letters.
slugify in Python

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: issue_access_token, read_access_token, confirm_access_token
charts.shape
SVG path strings for lines, areas, steps, monotone curves, bars, arcs and pie slices, identical in every language.
A group of 7: line_path, area_path, step_path, monotone_curve, bar_rects, arc_path, pie_angles
dates.uk-tax-year
The UK personal tax year containing a date: 6 April to 5 April, with HMRC's label.
uk_tax_year in Python
todo.due-label
The short English label shown next to a todo: "2 days overdue", "Due today", "Due tomorrow", "Due Fri 2 Oct".
due_label in Python
charts.axis
Axis geometry as data: tick positions, tick marks, label anchors and gridlines for number, time and category axes.
A group of 5: axis_from_ticks, number_axis, time_axis, band_axis, grid_lines
retail.oss-vat
EU distance-selling VAT: which member state's standard rate applies under OSS and the EUR 10,000 threshold, and the VAT.
oss_vat in Python
todo.due-status
Where a todo stands against its due date today: done, overdue, today, tomorrow, this week, later or no date.
due_status in Python
todo.export-csv
Write todos as a CSV file (RFC 4180) with one column per field, for backups, spreadsheets and other apps.
export_csv in Python
todo.item
The to-do item type (Todo, TodoDraft, Recurrence) and its validators, with a message per field.
A group of 2: validate_draft, validate_todo
todo.merge
Merge imported todos into a list by id: an imported todo replaces the one with its id, new ids are appended.
merge_todos in Python
todo.sort
Sort todos by manual order, due date, priority, creation time or title, stably, with sensible tie-breakers.
sort_todos in Python

Level 3 business operation