https://github.com/jaid/prepend-to-lines
Adds given string to each line of text of another string.
https://github.com/jaid/prepend-to-lines
lib library lines prepend string strings text util utility
Last synced: 10 months ago
JSON representation
Adds given string to each line of text of another string.
- Host: GitHub
- URL: https://github.com/jaid/prepend-to-lines
- Owner: Jaid
- License: mit
- Created: 2019-06-17T17:41:14.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2023-03-03T18:16:46.000Z (over 3 years ago)
- Last Synced: 2025-04-18T04:48:14.087Z (about 1 year ago)
- Topics: lib, library, lines, prepend, string, strings, text, util, utility
- Language: JavaScript
- Homepage: https://github.com/Jaid/prepend-to-lines
- Size: 2.25 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license.txt
Awesome Lists containing this project
README
# prepend-to-lines
**Prepends a string to each line of another string.**
## Installation
```bash
npm install --save prepend-to-lines@^1.0.2
```
```bash
yarn add prepend-to-lines@^1.0.2
```
(if [configured properly](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-npm-for-use-with-github-packages))
```bash
npm install --save @jaid/prepend-to-lines@^1.0.2
```
## Example
```javascript
import prependToLines from "prepend-to-lines"
const text = "I\nwant\nto\nbe\na\nMarkdown\nlist"
const result = prependToLines(text, "- ")
const linesArray = ["Hello", "world"]
const result2 = prependToLines(linesArray, "x")
const result3 = prependToLines("Without linebreaks", "* ")
```
Variable `result` will be:
```javascript
"- I\n- want\n- to\n- be\n- a\n- Markdown\n- list"
```
Variable `result2` will be:
```javascript
"xHello\nxworld"
```
Variable `result3` will be:
```javascript
"* Without linebreaks"
```
## Development
Setting up:
```bash
git clone git@github.com:jaid/prepend-to-lines.git
cd prepend-to-lines
npm install
```
Testing:
```bash
npm run test:dev
```
Testing in production environment:
```bash
npm run test
```
## License
[MIT License](https://raw.githubusercontent.com/jaid/prepend-to-lines/master/license.txt)
Copyright © 2020, Jaid \ (https://github.com/jaid)