3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-20 23:25:43 +01:00

Answer stability round 1: the guard's comment holds at both its call sites, and a giving-way list's items keep the list's path

This commit is contained in:
2026-10-13 01:09:32 +02:00
committed by Lillem4n
parent 7caa8237f0
commit 4657796d4d
5 changed files with 16 additions and 25 deletions
+2 -3
View File
@@ -8,14 +8,13 @@ const pastLongestString = ['InternalError: allocation size overflow', 'RangeErro
const pastEngineLimit = ['RangeError: Invalid array length', 'RangeError: Out of memory']
export function tooLong<T>(): Result<T> {
return failure('unsupported-node-shape', `spelled as markdown, this would be longer than ${longestMarkdown} characters, the longest string V8 holds`, [])
return failure('unsupported-node-shape', `spelled as markdown, this would be longer than ${longestMarkdown} characters, the longest markdown this library writes`, [])
}
export function withinLongest(text: string): Result<string> {
return text.length > longestMarkdown ? tooLong() : success(text)
}
// Joins the pieces as they come, so a spelling that grows far past its input stops at the bound unbuilt.
export function joinedWithin(pieces: Iterable<string>): Result<string> {
const kept: string[] = []
let length = 0
@@ -27,7 +26,7 @@ export function joinedWithin(pieces: Iterable<string>): Result<string> {
return success(kept.join(''))
}
// Any concatenation can pass an engine's longest string or array, so this wraps a whole conversion.
// Any concatenation can pass an engine's longest string or array; wrap every call that builds one.
export function withinEngineLimits<T>(convert: () => Result<T>): Result<T> {
try {
return convert()