# Literal column-join preview v1

Save `column-join.mjs` beside `join-example.mjs`; run in Node 18+ or modern
JavaScript. No runtime dependencies.

```js
import assert from 'node:assert/strict';
import { joinColumns } from './column-join.mjs';
const result = joinColumns('id\tfirst\tlast\n001\tAlex\tLee\n002\tJo\t', '2,3', 'present', ' ');
assert.deepEqual(result.lines, ['id\tfirst\tlast\tfirst last', '001\tAlex\tLee\tAlex Lee', '002\tJo\t\tJo ']);
assert.deepEqual(result.sourceRows, [{ row: 2 }, { row: 3 }]);
assert.deepEqual(result.selectedColumns, [2, 3]);
assert.equal(result.outputColumns, 4);
console.log(result.lines.join('\n'));
```

Run `node join-example.mjs`. Arguments: literal TSV input, ordered comma-separated
1-based column numbers, header handling (`present` or `none`), literal separator.
All are required. Selection tokens may have surrounding whitespace; numeric
syntax must be positive whole numbers without leading zeros. Duplicates fail.
An empty separator concatenates directly. Separators accept up to 100 UTF-16
code units, without tabs or newlines; multiple characters and spaces are literal.

Append combined text to every row, keeping source cells and row order unchanged.
With `present`, join selected header names using the same separator, excluding
the header from `checked` and `sourceRows`. Header-only input checks zero data
rows. Empty values and blank headers remain literal. Quotes do not escape tabs
or newlines; formulas are text. No regex, formatting or inference.

`sourceRows` lists original 1-based data-row positions. `selectedColumns` keeps
selection order. `inputColumns` and `outputColumns` describe dimensions; `issues`
is zero on valid input. `lines.join('\n')` contains only TSV, without position
annotations. CRLF/bare CR become LF and exactly one final newline is ignored.
Other blank rows are data; appending a column preserves them with a tab.

Limits: 100,000 UTF-16 code units each for input/output, 500 rows including any
header, 499 input columns/500 output columns, and 2,000 selection characters.
Empty/ragged input or an exceeded limit throws without partial output. No network,
telemetry, formula evaluation or Sheet writes. Native spreadsheet concatenation
is an alternative. This does not certify import safety, independent execution,
time savings or customer use.

Generate with `node scripts/build-column-join.mjs`; verify browser-core bytes
with `node scripts/build-column-join.mjs --check`.

## 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.
