Line-oriented generated content
@stackline/update-section
Replace the first marker-delimited range, append or prepend a missing section, and inspect inclusive marker metadata through the familiar synchronous API.
npm install @stackline/update-section
Real package execution
Section-replacement workbench
The documentation build bundles the package's real ESM entry. Every edit below calls that bundle; this is not a reimplementation of its marker algorithm.
Updated content
parse() metadata
Inclusive indexes
Small synchronous API
Callable replacement plus parse metadata.
Matchers receive each line, including a trailing carriage return when the input uses CRLF. Truthy results match and thrown values propagate.
| API | Behavior | Status |
|---|---|---|
updateSection(content, section, start, end, top?) | Replace the first start-through-end range, or insert when no start exists. | Preserved |
updateSection.parse(lines, start, end) | Return hasStart, hasEnd, and inclusive indexes. | Preserved and corrected |
parse(...) | Named ESM export for the same function. | Additive |
update-section.js | Historical CommonJS deep entry. | Preserved |
Narrow compatibility corrections
Metadata tells the truth.
Normal upstream output remains unchanged. The maintained package corrects the documented parser defects and one scale failure.
- Inclusive end index.
endIdxalways identifies the last replaced input line. - Truthful end flag.
hasEndis true only when the end matcher succeeds. - Ordered markers. End markers before the selected start are observed by callbacks but do not form crossed ranges.
- Large sections. Insertion avoids argument-count limits from
Function.apply.
Release proof
Small code, explicit boundary matrix.
The published release passed upstream behavior, intentional-difference, public-entry, clean-consumer, package, audit, and documentation gates.
- 7
- Node major lines from 12 through 24
- 3
- operating systems in CI
- 0
- runtime, optional, and peer dependencies
- 2
- TypeScript generations checked
- LF/CRLF
- line values and separator behavior characterized
- Browser
- real bundle exercised by tests and this workbench
Drop-in adoption
Keep the historical package key.
The published npm alias lets existing require('update-section') calls resolve to the scoped package.
npm install update-section@npm:@stackline/update-section
Project resources