3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 06:35:44 +01:00

Ship htmlToAdf: read back exactly the HTML adfToHtml writes, a carry element from its data-adf alone, any other HTML refused

This commit is contained in:
2026-10-26 21:47:30 +01:00
committed by Lillem4n
parent 905b039866
commit 51e37f68df
26 changed files with 880 additions and 74 deletions
+14
View File
@@ -0,0 +1,14 @@
import { failure, type Result } from './result.ts'
// Each reader's refusal of input that is no string, `format` naming what it reads.
export function notAString<T>(value: unknown, format: string): Result<T> {
return failure('not-a-string', `${format} is a string: found ${typeName(value)}`, [])
}
// `typeof` alone, since anything more throws on a revoked Proxy.
function typeName(value: unknown): string {
if (value === null) return 'null'
const type = typeof value
if (type === 'undefined') return type
return type === 'object' ? 'an object' : `a ${type}`
}