Compatibility-first text section replacement with corrected marker metadata and first-party types.
Documentation | npm | Issues | Repository
Current package version: 1.0.3
Compatibility-first replacement of generated text sections. The package keeps
the callable update-section@0.3.3 API, has no runtime dependencies, supports
CommonJS and ESM, and includes first-party TypeScript declarations.
| Item | Value |
|---|---|
| Package | @stackline/update-section@1.0.3 |
| Node.js runtime | >=12 |
| CommonJS / primary entry | ./index.js |
| ES module entry | ./index.mjs |
| Type declarations | ./index.d.ts |
npm install @stackline/update-sectionconst updateSection = require('@stackline/update-section')
const result = updateSection(
'title\n<!-- START -->\nold\n<!-- END -->',
'<!-- START -->\ncurrent\n<!-- END -->',
(line) => line === '<!-- START -->',
(line) => line === '<!-- END -->'
)The default export has this signature:
updateSection(content, section, matchesStart, matchesEnd, top?): stringIt replaces the first start marker through the first following end marker. A
start without an end is replaced through EOF. If no start exists, the section
is appended with exactly two LF characters; pass true as top to prepend it
with the same separator.
updateSection.parse(lines, matchesStart, matchesEnd) returns hasStart,
hasEnd, startIdx, and endIdx. Indexes are inclusive. A missing end has
hasEnd: false and uses the final line as endIdx; end markers before the
selected start are ignored.
ESM provides default updateSection plus named updateSection and parse
exports. The historical update-section.js deep entry remains available.
Legacy consumers can migrate without changing their import key:
npm install update-section@npm:@stackline/update-sectionSupported Node.js versions are 12 through 24. Input continues to split and join on LF exactly, so CR characters in CRLF content remain visible to marker callbacks. The package is an independent continuation and is not affiliated with the original author.
Review inputs and the package-specific compatibility limits before processing untrusted data. Report suspected vulnerabilities as described in the security policy.
git clone https://github.com/alexandroit/stackline-update-section.git
cd stackline-update-section
npm ci
npm run verifyRelease tooling uses Node.js 24.20.0 and npm 11.19.0. The consumer runtime contract remains the one documented above.
Run the repository's existing consumer/package check after installing development dependencies:
npm run test:smokeRun npm run verify and inspect the package contents before release. Publish a new version through the GitHub Actions publishing workflow, using the SHA-512 digest of the reviewed tarball. Verify the exact published version, tarball integrity, and npm provenance after the run.
MIT. See the license for the complete terms.
Original authorship and third-party attribution are preserved in NOTICE.
- Stackline Maintainers.
- Thorsten Lorenz.
- Copyright 2013 Thorsten Lorenz.
- Stackline maintenance: Alexandro Paixao Marques and Stackline contributors.
Original copyright, license notices and contributor acknowledgements remain part of this distribution. Stackline maintenance does not replace authorship of the original work.
Use this repository's issue tracker for reproducible bugs and feature requests. Join r/Stackline for examples, usage questions and release discussions.