package
Make multiple changes to a block of text by providing start and end indices and replacement text
npm install patch-textGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Make multiple changes to a block of text by providing start and end indices and replacement text
$ npm install --save patch-textvar patch = require('patch-text');
var text = 'Hello guys!'
var updated = patch(text, [
{
start: 0,
end: 5,
replacement: 'Hi'
},
{
start: 7,
end: 9,
replacement: 'al'
}
])
// => 'Hi gals!'Your patches shouldn't overlap, but they can shrink or increase the character count and your patches will still apply to the right text.
patch(text, patches) -> stringRequired
Type: string
The text to patch.
Required
Type: array[object]
The patches to apply to the text, each with:
MIT © Ben Drucker