https://github.com/ruzicka/string-insert-multi
Make multiple inserts into a string at once
https://github.com/ruzicka/string-insert-multi
insert multiple string strings-manipulation
Last synced: 5 months ago
JSON representation
Make multiple inserts into a string at once
- Host: GitHub
- URL: https://github.com/ruzicka/string-insert-multi
- Owner: ruzicka
- License: mit
- Created: 2019-01-15T14:51:44.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T15:59:31.000Z (almost 3 years ago)
- Last Synced: 2025-02-25T22:47:37.659Z (10 months ago)
- Topics: insert, multiple, string, strings-manipulation
- Language: TypeScript
- Homepage:
- Size: 570 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/ruzicka/string-insert-multi)
[](https://coveralls.io/github/ruzicka/string-insert-multi?branch=master)
# string-insert-multi
Allows you to make multiple inserts into a string in just one call.
All indices you need to use are relative to original string.
Package includes typescript declarations
## Install
```
npm install string-insert-multi --save
```
## Example
```typescript
import insert from 'string-insert-multi'
const str = 'aabbcc'
insert('aabbcc', [
{ at: 2, text: '11' },
{ at: 4, text: '22' },
])
// return 'aa11bb22cc'
// negative offset
insert('aabbcc', [
{ at: -2, text: '11' },
])
// return 'aabb11cc'
// offset beyond end of the string
insert('aabbcc', [
{ at: 100, text: '11' },
])
// return 'aabbcc11'
```