An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# prepend-to-lines

License Sponsor prepend-to-lines
Build status Commits since v1.0.2 Last commit Issues
Latest version on npm Dependents Downloads

**Prepends a string to each line of another string.**

## Installation

prepend-to-lines on npm

```bash
npm install --save prepend-to-lines@^1.0.2
```

prepend-to-lines on Yarn

```bash
yarn add prepend-to-lines@^1.0.2
```

@jaid/prepend-to-lines on GitHub Packages
(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)