oficina / mapa Public

Clone
git clone https://amadan.net/oficina/mapa

Plain git — no account needed to clone.

Download

Download this file

1// The editor's port reads every line in time linear in its length
2// (Fable round 3, L8, and round 2's M1): the shapes that made it
3// quadratic each read in well under the bound here.
4import { test } from 'node:test'
5import assert from 'node:assert/strict'
6import { spans } from './markup.mjs'
7
8const shapes = {
9 'image openers': '![a'.repeat(40000) + '](z)',
10 'shared link address': '[x]('.repeat(25000) + 'a)',
11 'shared web address': '[x](http://e.com/'.repeat(25000) + 'a)'
12}
13
14for (const [name, text] of Object.entries(shapes)) {
15 test(`a line of ${name} reads in linear time`, () => {
16 const started = performance.now()
17 spans(text)
18 const took = performance.now() - started
19 assert.ok(took < 2000, `${name} took ${Math.round(took)} ms`)
20 })
21}
22