# Literal table transpose v1

Swap rows and columns in a local tab-separated table. Every row is data, including
any header row. No network calls, spreadsheet access or evaluation. Save
`table-transpose.mjs` beside this file, then save this example as `transpose.mjs`:

```js
import assert from 'node:assert/strict';
import { transposeTable } from './table-transpose.mjs';

const table = 'id\tname\n001\t Alex \n002\t=SUM(A1)';
const result = transposeTable(table);
console.log(result.lines.join('\n'));
// id\t001\t002
// name\t Alex \t=SUM(A1)
assert.equal(result.lines.join('\n'), 'id\t001\t002\nname\t Alex \t=SUM(A1)');

// Use lines.join('\n') to serialize the result, including a terminal blank cell.
const blank = transposeTable('a\t');
assert.equal(blank.lines.join('\n'), 'a\n\n');
assert.equal(transposeTable(blank.lines.join('\n')).lines.join('\n'), 'a\t');
console.log(JSON.stringify(blank.lines.join('\n'))); // "a\n\n"
```

Run `node transpose.mjs`. `transposeTable(table)` returns
`{ lines, checked, issues, inputRows, inputColumns }`. `lines` contains the
transposed rows; `checked` and `inputRows` count source rows; `inputColumns`
counts source columns; `issues` is zero on success. Invalid input throws.

Cells remain literal: spaces, blanks, duplicate headers, leading zeros and
formula-like text are preserved. Uneven rows are rejected. CRLF/CR becomes LF
and one final newline is ignored. When the final transposed row is one empty
cell, `lines` includes an extra empty string so `lines.join('\n')` preserves it
through another transpose. Tabs and newlines always separate cells and rows;
quoted tabs and multiline cells are unsupported. Limits: 100,000 characters
in input and output, 500 rows and 500 columns. Nothing is written to a Sheet
or evaluated; review formula-like cells before pasting results into one.

Generated from site/lib/table-transpose.ts by scripts/build-table-transpose.mjs.
`node scripts/build-table-transpose.mjs --check` verifies exact browser-core
parity. A download is not proof of independent execution or customer demand.

## License

MIT License

Copyright (c) 2026 QuasiLife

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
