JavaScript implementation of the sed command-line tool for text substitution. Current stable version 1.1.0 compiles sed expressions to functions, supporting flags like g (global) and custom delimiters. The library is lightweight, has no dependencies, and ships TypeScript declarations. It differs from alternatives like xregexp by focusing on sed syntax compatibility, enabling use in Node.js and browsers.
npm install sed-liteNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: compile sed substitution, global flag, custom delimiter, and chaining expressions.
Use only 's' command. For extended functionality, consider other libraries like xregexp or manual RegExp.
Use JavaScript regex syntax: e.g., 's/(\w+)/$1/' — note the double escaping in string literal.
To mimic 'i' flag, modify regex pattern manually: e.g., 's/pattern/replacement/i' in string but sed-lite does not interpret 'i'. Instead use native RegExp: str.replace(/pattern/i, 'replacement').
Use import { sed } from 'sed-lite' instead of import sed from 'sed-lite'.Ensure the sed string is correctly formatted: e.g., 's/foo/bar/' — use valid JavaScript RegExp patterns. If using custom delimiter, use a character not appearing in the pattern or replacement, e.g., 's#foo#bar#'.
Use import { sed } from 'sed-lite' (named) or import sed from 'sed-lite' (default), depending on how you want to call it.Call sed(expression)(input) or store the compiled function in a variable.
No dependency data recorded yet.