@20baht/spreadsheet 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ import { type CellRange } from './book.js';
2
+ export declare const ERRORS: readonly ["#DIV/0!", "#NAME?", "#REF!", "#VALUE!", "#CYCLE!", "#ERROR!"];
3
+ export type ErrorCode = (typeof ERRORS)[number];
4
+ /** What a formula could not work out. */
5
+ export interface FormulaError {
6
+ error: ErrorCode;
7
+ }
8
+ /** What a cell works out to; `null` is an empty cell. */
9
+ export type Scalar = number | string | boolean | null | FormulaError;
10
+ export declare const failed: (error: ErrorCode) => FormulaError;
11
+ export declare function isError(value: unknown): value is FormulaError;
12
+ type BinaryOp = '+' | '-' | '*' | '/' | '^' | '&' | '=' | '<>' | '<' | '>' | '<=' | '>=';
13
+ export type FormulaNode = {
14
+ type: 'value';
15
+ value: number | string | boolean;
16
+ } | {
17
+ type: 'cell';
18
+ sheet?: string;
19
+ row: number;
20
+ column: number;
21
+ }
22
+ /** `bottom` / `right` past the sheet's end stand for a whole column. */
23
+ | {
24
+ type: 'range';
25
+ sheet?: string;
26
+ range: CellRange;
27
+ } | {
28
+ type: 'negate';
29
+ of: FormulaNode;
30
+ } | {
31
+ type: 'percent';
32
+ of: FormulaNode;
33
+ } | {
34
+ type: 'binary';
35
+ op: BinaryOp;
36
+ left: FormulaNode;
37
+ right: FormulaNode;
38
+ } | {
39
+ type: 'call';
40
+ name: string;
41
+ args: FormulaNode[];
42
+ } | {
43
+ type: 'error';
44
+ error: ErrorCode;
45
+ };
46
+ /** A formula (without its `=`) as a tree. One that cannot be read is the error `#ERROR!`. */
47
+ export declare function parseFormula(source: string): FormulaNode;
48
+ /** What a formula reads its cells from. A sheet is named as the formula names it; unnamed is the formula's own. */
49
+ export interface FormulaScope {
50
+ /** What the cell works out to; `#REF!` when there is no such sheet. */
51
+ cell(sheet: string | undefined, row: number, column: number): Scalar;
52
+ /** How far the sheet's cells reach; `null` when there is no such sheet. */
53
+ extent(sheet: string | undefined): {
54
+ rows: number;
55
+ columns: number;
56
+ } | null;
57
+ }
58
+ /** An argument as a function gets it: one value, or a range's rows. */
59
+ type Arg = Scalar | Scalar[][];
60
+ /** The functions a formula may call, by their upper-case name. */
61
+ export declare const FUNCTIONS: Readonly<Record<string, (args: readonly Arg[]) => Scalar>>;
62
+ /** What the tree works out to. A range where one value is asked for is `#VALUE!`. */
63
+ export declare function evaluate(node: FormulaNode, scope: FormulaScope): Scalar;
64
+ export {};
@@ -0,0 +1,477 @@
1
+ import { columnIndex, MAX_COLUMNS, MAX_ROWS } from './book.js';
2
+ export const ERRORS = ['#DIV/0!', '#NAME?', '#REF!', '#VALUE!', '#CYCLE!', '#ERROR!'];
3
+ export const failed = (error) => ({ error });
4
+ export function isError(value) {
5
+ return typeof value === 'object' && value !== null && 'error' in value;
6
+ }
7
+ const NUMBER = /^\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/;
8
+ const WORD = /^[$\p{L}_][$\p{L}\p{N}_.]*/u;
9
+ const OPS = [
10
+ '<>',
11
+ '<=',
12
+ '>=',
13
+ '+',
14
+ '-',
15
+ '*',
16
+ '/',
17
+ '^',
18
+ '&',
19
+ '=',
20
+ '<',
21
+ '>',
22
+ '%',
23
+ '(',
24
+ ')',
25
+ ',',
26
+ ':',
27
+ '!',
28
+ ];
29
+ function quotedText(source, start, quote) {
30
+ let text = '';
31
+ for (let i = start; i < source.length; i++) {
32
+ if (source[i] !== quote)
33
+ text += source.charAt(i);
34
+ else if (source[i + 1] === quote)
35
+ text += source.charAt(i++);
36
+ else
37
+ return [text, i + 1];
38
+ }
39
+ return null;
40
+ }
41
+ function tokenAt(rest) {
42
+ const char = rest.charAt(0);
43
+ if (char === '"' || char === "'") {
44
+ const read = quotedText(rest, 1, char);
45
+ if (!read)
46
+ return null;
47
+ return [
48
+ char === '"'
49
+ ? { type: 'text', value: read[0] }
50
+ : { type: 'word', value: read[0], quoted: true },
51
+ read[1],
52
+ ];
53
+ }
54
+ const number = NUMBER.exec(rest);
55
+ if (number)
56
+ return [{ type: 'number', value: Number(number[0]) }, number[0].length];
57
+ const word = WORD.exec(rest);
58
+ if (word)
59
+ return [{ type: 'word', value: word[0], quoted: false }, word[0].length];
60
+ const op = OPS.find((candidate) => rest.startsWith(candidate));
61
+ return op === undefined ? null : [{ type: 'op', value: op }, op.length];
62
+ }
63
+ function tokens(source) {
64
+ const found = [];
65
+ let i = 0;
66
+ while (i < source.length) {
67
+ if (/\s/.test(source.charAt(i))) {
68
+ i++;
69
+ continue;
70
+ }
71
+ const read = tokenAt(source.slice(i));
72
+ if (!read)
73
+ return null;
74
+ found.push(read[0]);
75
+ i += read[1];
76
+ }
77
+ return found;
78
+ }
79
+ const CELL = /^\$?([A-Za-z]{1,3})\$?([1-9]\d{0,6})$/;
80
+ const COLUMN = /^\$?([A-Za-z]{1,3})$/;
81
+ class Unreadable extends Error {
82
+ }
83
+ class Reader {
84
+ #at;
85
+ constructor(list) {
86
+ this.list = list;
87
+ this.#at = 0;
88
+ this.expression = () => this.#binary(this.#joined, '=', '<>', '<=', '>=', '<', '>');
89
+ this.#joined = () => this.#binary(this.#sum, '&');
90
+ this.#sum = () => this.#binary(this.#product, '+', '-');
91
+ this.#product = () => this.#binary(this.#power, '*', '/');
92
+ this.#power = () => this.#binary(this.#signed, '^');
93
+ this.#signed = () => {
94
+ if (this.#op('-') !== null)
95
+ return { type: 'negate', of: this.#signed() };
96
+ if (this.#op('+') !== null)
97
+ return this.#signed();
98
+ let node = this.#primary();
99
+ while (this.#op('%') !== null)
100
+ node = { type: 'percent', of: node };
101
+ return node;
102
+ };
103
+ }
104
+ get done() {
105
+ return this.#at >= this.list.length;
106
+ }
107
+ #peek() {
108
+ return this.list[this.#at];
109
+ }
110
+ #op(...values) {
111
+ const token = this.#peek();
112
+ if (token?.type !== 'op' || !values.includes(token.value))
113
+ return null;
114
+ this.#at++;
115
+ return token.value;
116
+ }
117
+ #expect(value) {
118
+ if (this.#op(value) === null)
119
+ throw new Unreadable();
120
+ }
121
+ #binary(next, ...ops) {
122
+ let left = next();
123
+ for (let op = this.#op(...ops); op !== null; op = this.#op(...ops))
124
+ left = { type: 'binary', op: op, left, right: next() };
125
+ return left;
126
+ }
127
+ #joined;
128
+ #sum;
129
+ #product;
130
+ #power;
131
+ #signed;
132
+ #primary() {
133
+ const token = this.#peek();
134
+ if (!token)
135
+ throw new Unreadable();
136
+ this.#at++;
137
+ if (token.type === 'number' || token.type === 'text')
138
+ return { type: 'value', value: token.value };
139
+ if (token.type === 'op') {
140
+ if (token.value !== '(')
141
+ throw new Unreadable();
142
+ const inner = this.expression();
143
+ this.#expect(')');
144
+ return inner;
145
+ }
146
+ if (this.#op('!') !== null)
147
+ return this.#place(token.value);
148
+ if (token.quoted)
149
+ throw new Unreadable();
150
+ if (this.#op('(') !== null)
151
+ return { type: 'call', name: token.value.toUpperCase(), args: this.#args() };
152
+ const upper = token.value.toUpperCase();
153
+ if (upper === 'TRUE' || upper === 'FALSE')
154
+ return { type: 'value', value: upper === 'TRUE' };
155
+ this.#at--;
156
+ return this.#place(undefined);
157
+ }
158
+ #args() {
159
+ if (this.#op(')') !== null)
160
+ return [];
161
+ const args = [this.expression()];
162
+ while (this.#op(',') !== null)
163
+ args.push(this.expression());
164
+ this.#expect(')');
165
+ return args;
166
+ }
167
+ #place(sheet) {
168
+ const on = sheet === undefined ? {} : { sheet };
169
+ const first = this.#word();
170
+ const cell = CELL.exec(first);
171
+ if (cell) {
172
+ const from = { row: Number(cell[2]) - 1, column: columnIndex(cell[1] ?? '') };
173
+ if (this.#op(':') === null)
174
+ return this.#within({ type: 'cell', ...on, ...from });
175
+ const end = CELL.exec(this.#word());
176
+ if (!end)
177
+ throw new Unreadable();
178
+ const to = { row: Number(end[2]) - 1, column: columnIndex(end[1] ?? '') };
179
+ return this.#within({
180
+ type: 'range',
181
+ ...on,
182
+ range: {
183
+ top: Math.min(from.row, to.row),
184
+ left: Math.min(from.column, to.column),
185
+ bottom: Math.max(from.row, to.row),
186
+ right: Math.max(from.column, to.column),
187
+ },
188
+ });
189
+ }
190
+ const column = COLUMN.exec(first);
191
+ if (!column || this.#op(':') === null)
192
+ return { type: 'error', error: '#NAME?' };
193
+ const end = COLUMN.exec(this.#word());
194
+ if (!end)
195
+ throw new Unreadable();
196
+ const a = columnIndex(column[1] ?? '');
197
+ const b = columnIndex(end[1] ?? '');
198
+ return this.#within({
199
+ type: 'range',
200
+ ...on,
201
+ range: { top: 0, left: Math.min(a, b), bottom: MAX_ROWS - 1, right: Math.max(a, b) },
202
+ });
203
+ }
204
+ #word() {
205
+ const token = this.#peek();
206
+ if (token?.type !== 'word' || token.quoted)
207
+ throw new Unreadable();
208
+ this.#at++;
209
+ return token.value;
210
+ }
211
+ #within(node) {
212
+ const row = node.type === 'cell' ? node.row : node.range.bottom;
213
+ const column = node.type === 'cell' ? node.column : node.range.right;
214
+ return row < MAX_ROWS && column < MAX_COLUMNS ? node : { type: 'error', error: '#REF!' };
215
+ }
216
+ }
217
+ export function parseFormula(source) {
218
+ const list = tokens(source);
219
+ if (!list || list.length === 0)
220
+ return { type: 'error', error: '#ERROR!' };
221
+ const reader = new Reader(list);
222
+ try {
223
+ const node = reader.expression();
224
+ return reader.done ? node : { type: 'error', error: '#ERROR!' };
225
+ }
226
+ catch (thrown) {
227
+ if (thrown instanceof Unreadable)
228
+ return { type: 'error', error: '#ERROR!' };
229
+ throw thrown;
230
+ }
231
+ }
232
+ function numberOf(value) {
233
+ if (isError(value))
234
+ return value;
235
+ if (value === null)
236
+ return 0;
237
+ if (typeof value === 'number')
238
+ return value;
239
+ if (typeof value === 'boolean')
240
+ return value ? 1 : 0;
241
+ const number = value.trim() === '' ? Number.NaN : Number(value);
242
+ return Number.isNaN(number) ? failed('#VALUE!') : number;
243
+ }
244
+ function textOf(value) {
245
+ if (value === null)
246
+ return '';
247
+ if (typeof value === 'boolean')
248
+ return value ? 'TRUE' : 'FALSE';
249
+ return String(value);
250
+ }
251
+ function truthOf(value) {
252
+ if (isError(value))
253
+ return value;
254
+ if (typeof value === 'string') {
255
+ const upper = value.toUpperCase();
256
+ if (upper === 'TRUE' || upper === 'FALSE')
257
+ return upper === 'TRUE';
258
+ return failed('#VALUE!');
259
+ }
260
+ return value !== null && value !== 0 && value !== false;
261
+ }
262
+ function compare(a, b) {
263
+ const rank = (value) => typeof value === 'boolean' ? 2 : typeof value === 'string' ? 1 : 0;
264
+ const left = a ?? (typeof b === 'string' ? '' : 0);
265
+ const right = b ?? (typeof a === 'string' ? '' : 0);
266
+ if (rank(left) !== rank(right))
267
+ return rank(left) - rank(right);
268
+ if (typeof left === 'string' && typeof right === 'string')
269
+ return left.toLowerCase().localeCompare(right.toLowerCase());
270
+ return Number(left) - Number(right);
271
+ }
272
+ const COMPARISONS = {
273
+ '=': (order) => order === 0,
274
+ '<>': (order) => order !== 0,
275
+ '<': (order) => order < 0,
276
+ '>': (order) => order > 0,
277
+ '<=': (order) => order <= 0,
278
+ '>=': (order) => order >= 0,
279
+ };
280
+ const ARITHMETIC = {
281
+ '+': (a, b) => a + b,
282
+ '-': (a, b) => a - b,
283
+ '*': (a, b) => a * b,
284
+ '/': (a, b) => (b === 0 ? failed('#DIV/0!') : a / b),
285
+ '^': (a, b) => a ** b,
286
+ };
287
+ function binary(op, left, right) {
288
+ if (isError(left))
289
+ return left;
290
+ if (isError(right))
291
+ return right;
292
+ const comparison = COMPARISONS[op];
293
+ if (comparison)
294
+ return comparison(compare(left, right));
295
+ if (op === '&')
296
+ return `${textOf(left)}${textOf(right)}`;
297
+ const a = numberOf(left);
298
+ if (isError(a))
299
+ return a;
300
+ const b = numberOf(right);
301
+ if (isError(b))
302
+ return b;
303
+ const result = ARITHMETIC[op](a, b);
304
+ return typeof result === 'number' && !Number.isFinite(result) ? failed('#VALUE!') : result;
305
+ }
306
+ const flat = (args) => args.flatMap((arg) => (Array.isArray(arg) ? arg.flat() : [arg]));
307
+ function numbers(args) {
308
+ const found = [];
309
+ for (const arg of args) {
310
+ const read = Array.isArray(arg) ? rangeNumbers(arg) : writtenNumber(arg);
311
+ if (isError(read))
312
+ return read;
313
+ found.push(...read);
314
+ }
315
+ return found;
316
+ }
317
+ function rangeNumbers(rows) {
318
+ const cells = rows.flat();
319
+ return (cells.find((value) => isError(value)) ??
320
+ cells.filter((value) => typeof value === 'number'));
321
+ }
322
+ function writtenNumber(value) {
323
+ const number = numberOf(value);
324
+ if (isError(number))
325
+ return number;
326
+ return value === null ? [] : [number];
327
+ }
328
+ const over = (fold) => (args) => {
329
+ const list = numbers(args);
330
+ return isError(list) ? list : fold(list);
331
+ };
332
+ const single = (arg) => Array.isArray(arg) ? (arg[0]?.[0] ?? null) : (arg ?? null);
333
+ const CRITERION = /^(<>|<=|>=|=|<|>)?(.*)$/s;
334
+ function criterion(value) {
335
+ if (typeof value !== 'string')
336
+ return (cell) => !isError(cell) && compare(cell, value) === 0 && cell !== null;
337
+ const match = CRITERION.exec(value);
338
+ const op = match?.[1] ?? '=';
339
+ const text = match?.[2] ?? '';
340
+ const asNumber = text.trim() === '' ? Number.NaN : Number(text);
341
+ const test = COMPARISONS[op];
342
+ if (!Number.isNaN(asNumber))
343
+ return (cell) => {
344
+ const number = typeof cell === 'string' && cell.trim() !== '' ? Number(cell) : cell;
345
+ return typeof number === 'number' && !Number.isNaN(number) && test(number - asNumber);
346
+ };
347
+ if (op !== '=' && op !== '<>')
348
+ return (cell) => typeof cell === 'string' && test(compare(cell, text));
349
+ const pattern = new RegExp(`^${text
350
+ .split('*')
351
+ .map((part) => part.replace(/[.+?^${}()|[\]\\]/g, '\\$&'))
352
+ .join('.*')}$`, 'is');
353
+ return (cell) => pattern.test(isError(cell) ? cell.error : textOf(cell)) === (op === '=');
354
+ }
355
+ const rowsOf = (arg) => (Array.isArray(arg) ? arg : [[arg ?? null]]);
356
+ function sumIf(args) {
357
+ const tested = rowsOf(args[0]);
358
+ const summed = args[2] === undefined ? tested : rowsOf(args[2]);
359
+ const test = criterion(single(args[1]));
360
+ let total = 0;
361
+ tested.forEach((row, r) => {
362
+ row.forEach((cell, c) => {
363
+ const value = summed[r]?.[c];
364
+ if (test(cell) && typeof value === 'number')
365
+ total += value;
366
+ });
367
+ });
368
+ return total;
369
+ }
370
+ function round(args) {
371
+ const value = numberOf(single(args[0]));
372
+ const places = numberOf(single(args[1]));
373
+ if (isError(value))
374
+ return value;
375
+ if (isError(places))
376
+ return places;
377
+ const scale = 10 ** Math.trunc(places);
378
+ return (Math.sign(value) * Math.round(Math.abs(value) * scale)) / scale;
379
+ }
380
+ const truths = (all) => (args) => {
381
+ let result = all;
382
+ for (const value of flat(args)) {
383
+ if (value === null)
384
+ continue;
385
+ const truth = truthOf(value);
386
+ if (isError(truth))
387
+ return truth;
388
+ result = all ? result && truth : result || truth;
389
+ }
390
+ return result;
391
+ };
392
+ export const FUNCTIONS = {
393
+ SUM: over((list) => list.reduce((sum, n) => sum + n, 0)),
394
+ AVERAGE: over((list) => list.length === 0 ? failed('#DIV/0!') : list.reduce((sum, n) => sum + n, 0) / list.length),
395
+ MIN: over((list) => (list.length === 0 ? 0 : Math.min(...list))),
396
+ MAX: over((list) => (list.length === 0 ? 0 : Math.max(...list))),
397
+ COUNT: (args) => flat(args).filter((value) => typeof value === 'number').length,
398
+ COUNTA: (args) => flat(args).filter((value) => value !== null && value !== '').length,
399
+ COUNTIF: (args) => rowsOf(args[0])
400
+ .flat()
401
+ .filter(criterion(single(args[1]))).length,
402
+ SUMIF: sumIf,
403
+ ROUND: round,
404
+ ABS: (args) => {
405
+ const value = numberOf(single(args[0]));
406
+ return isError(value) ? value : Math.abs(value);
407
+ },
408
+ AND: truths(true),
409
+ OR: truths(false),
410
+ NOT: (args) => {
411
+ const truth = truthOf(single(args[0]));
412
+ return isError(truth) ? truth : !truth;
413
+ },
414
+ };
415
+ function branch(node, scope) {
416
+ const [test, then, otherwise] = node.args;
417
+ if (!test || !then)
418
+ return failed('#ERROR!');
419
+ const truth = truthOf(evaluate(test, scope));
420
+ if (isError(truth))
421
+ return truth;
422
+ if (truth)
423
+ return evaluate(then, scope);
424
+ return otherwise ? evaluate(otherwise, scope) : false;
425
+ }
426
+ function rangeValues(node, scope) {
427
+ const extent = scope.extent(node.sheet);
428
+ if (!extent)
429
+ return failed('#REF!');
430
+ const bottom = Math.min(node.range.bottom, extent.rows - 1);
431
+ const right = Math.min(node.range.right, extent.columns - 1);
432
+ const rows = [];
433
+ for (let row = node.range.top; row <= bottom; row++) {
434
+ const cells = [];
435
+ for (let column = node.range.left; column <= right; column++)
436
+ cells.push(scope.cell(node.sheet, row, column));
437
+ rows.push(cells);
438
+ }
439
+ return rows;
440
+ }
441
+ function argument(node, scope) {
442
+ return node.type === 'range' ? rangeValues(node, scope) : evaluate(node, scope);
443
+ }
444
+ function called(node, scope) {
445
+ if (node.name === 'IF')
446
+ return branch(node, scope);
447
+ const fn = FUNCTIONS[node.name];
448
+ if (!fn)
449
+ return failed('#NAME?');
450
+ const args = node.args.map((arg) => argument(arg, scope));
451
+ const broken = args.find((arg) => isError(arg));
452
+ return broken ?? fn(args);
453
+ }
454
+ export function evaluate(node, scope) {
455
+ switch (node.type) {
456
+ case 'value':
457
+ return node.value;
458
+ case 'error':
459
+ return failed(node.error);
460
+ case 'cell':
461
+ return scope.cell(node.sheet, node.row, node.column);
462
+ case 'range':
463
+ return failed('#VALUE!');
464
+ case 'negate': {
465
+ const value = numberOf(evaluate(node.of, scope));
466
+ return isError(value) ? value : -value;
467
+ }
468
+ case 'percent': {
469
+ const value = numberOf(evaluate(node.of, scope));
470
+ return isError(value) ? value : value / 100;
471
+ }
472
+ case 'binary':
473
+ return binary(node.op, evaluate(node.left, scope), evaluate(node.right, scope));
474
+ case 'call':
475
+ return called(node, scope);
476
+ }
477
+ }
@@ -0,0 +1,7 @@
1
+ export { addressOf, ALIGNS, columnIndex, columnName, DEFAULT_COLUMNS, DEFAULT_ROWS, DEFAULT_WIDTH, emptyBook, extentOf, MAX_COLUMNS, MAX_ROWS, MAX_SHEETS, mergeAt, mergesOf, NUMBER_FORMATS, parseAddress, parseRange, rangeName, rangeOf, sheetOf, type Book, type BookCell, type BookSheet, type BookSource, type CellAlign, type CellPos, type CellRange, type CellStyle, type CellValue, type NumberFormat, } from './book.js';
2
+ export { ERRORS, evaluate, FUNCTIONS, isError, parseFormula, type ErrorCode, type FormulaError, type FormulaNode, type FormulaScope, type Scalar, } from './formula.js';
3
+ export { cellInput, computeBook, displayText, inputText, type BookValues } from './compute.js';
4
+ export { parseBook, type BookIssue, type ParsedBook } from './parse.js';
5
+ export { copied, openBook, savedBook, selectionOf, shownSheet, updateBook, type BookDirection, type BookMsg, type BookState, type BookUpdate, type SourceRows, type StylePatch, } from './session.js';
6
+ export { fromTsv, toTsv } from './tsv.js';
7
+ export { bookWorkbook, type WorkbookCell, type WorkbookSheet } from './workbook.js';
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { addressOf, ALIGNS, columnIndex, columnName, DEFAULT_COLUMNS, DEFAULT_ROWS, DEFAULT_WIDTH, emptyBook, extentOf, MAX_COLUMNS, MAX_ROWS, MAX_SHEETS, mergeAt, mergesOf, NUMBER_FORMATS, parseAddress, parseRange, rangeName, rangeOf, sheetOf, } from './book.js';
2
+ export { ERRORS, evaluate, FUNCTIONS, isError, parseFormula, } from './formula.js';
3
+ export { cellInput, computeBook, displayText, inputText } from './compute.js';
4
+ export { parseBook } from './parse.js';
5
+ export { copied, openBook, savedBook, selectionOf, shownSheet, updateBook, } from './session.js';
6
+ export { fromTsv, toTsv } from './tsv.js';
7
+ export { bookWorkbook } from './workbook.js';
@@ -0,0 +1,15 @@
1
+ import { type Book } from './book.js';
2
+ export interface BookIssue {
3
+ /** Where: `sheets[1].cells.B3.style.fill`. */
4
+ path: string;
5
+ message: string;
6
+ }
7
+ export type ParsedBook = {
8
+ ok: true;
9
+ book: Book;
10
+ } | {
11
+ ok: false;
12
+ issues: BookIssue[];
13
+ };
14
+ /** A book from JSON nobody has checked: the book, or everything that is wrong with it. */
15
+ export declare function parseBook(value: unknown): ParsedBook;