Skip to content

Commit

Permalink
docs: Updated readme source
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaid committed Mar 27, 2020
1 parent 4515705 commit 8bc1949
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 39 deletions.
87 changes: 53 additions & 34 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# prepend-to-lines


<a href="https://raw.githubusercontent.com/jaid/prepend-to-lines/master/license.txt"><img src="https://img.shields.io/github/license/jaid/prepend-to-lines?style=flat-square" alt="License"/></a> <a href="https://github.com/sponsors/jaid"><img src="https://img.shields.io/badge/<3-Sponsor-FF45F1?style=flat-square" alt="Sponsor prepend-to-lines"/></a>
<a href="https://raw.githubusercontent.com/jaid/prepend-to-lines/master/license.txt"><img src="https://img.shields.io/github/license/jaid/prepend-to-lines?style=flat-square" alt="License"/></a> <a href="https://github.com/sponsors/jaid"><img src="https://img.shields.io/badge/<3-Sponsor-FF45F1?style=flat-square" alt="Sponsor prepend-to-lines"/></a>
<a href="https://actions-badge.atrox.dev/jaid/prepend-to-lines/goto"><img src="https://img.shields.io/endpoint.svg?style=flat-square&url=https%3A%2F%2Factions-badge.atrox.dev%2Fjaid%2Fprepend-to-lines%2Fbadge" alt="Build status"/></a> <a href="https://github.com/jaid/prepend-to-lines/commits"><img src="https://img.shields.io/github/commits-since/jaid/prepend-to-lines/v1.0.1?style=flat-square&logo=github" alt="Commits since v1.0.1"/></a> <a href="https://github.com/jaid/prepend-to-lines/commits"><img src="https://img.shields.io/github/last-commit/jaid/prepend-to-lines?style=flat-square&logo=github" alt="Last commit"/></a> <a href="https://github.com/jaid/prepend-to-lines/issues"><img src="https://img.shields.io/github/issues/jaid/prepend-to-lines?style=flat-square&logo=github" alt="Issues"/></a>
<a href="https://npmjs.com/package/prepend-to-lines"><img src="https://img.shields.io/npm/v/prepend-to-lines?style=flat-square&logo=npm&label=latest%20version" alt="Latest version on npm"/></a> <a href="https://github.com/jaid/prepend-to-lines/network/dependents"><img src="https://img.shields.io/librariesio/dependents/npm/prepend-to-lines?style=flat-square&logo=npm" alt="Dependents"/></a> <a href="https://npmjs.com/package/prepend-to-lines"><img src="https://img.shields.io/npm/dm/prepend-to-lines?style=flat-square&logo=npm" alt="Downloads"/></a>

Expand All @@ -11,28 +11,58 @@



## Installation

<a href="https://npmjs.com/package/prepend-to-lines"><img src="https://img.shields.io/badge/npm-prepend--to--lines-C23039?style=flat-square&logo=npm" alt="prepend-to-lines on npm"/></a>

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

<a href="https://yarnpkg.com/package/prepend-to-lines"><img src="https://img.shields.io/badge/Yarn-prepend--to--lines-2F8CB7?style=flat-square&logo=yarn&logoColor=white" alt="prepend-to-lines on Yarn"/></a>

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

<a href="https://github.com/jaid/prepend-to-lines/packages"><img src="https://img.shields.io/badge/GitHub Packages-@jaid/prepend--to--lines-24282e?style=flat-square&logo=github" alt="@jaid/prepend-to-lines on GitHub Packages"/></a>
(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.1
```



## Example

## Installation
<a href="https://npmjs.com/package/prepend-to-lines"><img src="https://img.shields.io/badge/npm-prepend--to--lines-C23039?style=flat-square&logo=npm" alt="prepend-to-lines on npm"/></a>
```bash
npm install --save prepend-to-lines@^1.0.1

```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", "* ")
```
<a href="https://yarnpkg.com/package/prepend-to-lines"><img src="https://img.shields.io/badge/Yarn-prepend--to--lines-2F8CB7?style=flat-square&logo=yarn&logoColor=white" alt="prepend-to-lines on Yarn"/></a>
```bash
yarn add prepend-to-lines@^1.0.1

Variable `result` will be:

```javascript
"- I\n- want\n- to\n- be\n- a\n- Markdown\n- list"
```
<a href="https://jsdelivr.com/package/npm/prepend-to-lines/"><img src="https://img.shields.io/badge/jsDelivr-prepend--to--lines-orange?style=flat-square&logo=html5&logoColor=white" alt="prepend-to-lines on jsDelivr"/></a> <a href="https://unpkg.com/browse/prepend-to-lines/"><img src="https://img.shields.io/badge/UNPKG-prepend--to--lines-orange?style=flat-square&logo=html5&logoColor=white" alt="prepend-to-lines on UNPKG"/></a>
```html
<script src="https://cdn.jsdelivr.net/npm/prepend-to-lines@1.0.1/index.js"/>
Variable `result2` will be:

```javascript
"xHello\nxworld"
```
Variable `result3` will be:

```javascript
"* Without linebreaks"
```


Expand All @@ -41,6 +71,16 @@ yarn add prepend-to-lines@^1.0.1













## Development


Expand All @@ -62,26 +102,5 @@ npm run test


## License
```text
MIT License
Copyright © 2020, Jaid <jaid.jsx@gmail.com> (github.com/jaid)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
[MIT License](https://raw.githubusercontent.com/jaid/prepend-to-lines/master/license.txt)
Copyright © 2020, Jaid \<jaid.jsx@gmail.com> (https://github.com/jaid)
9 changes: 9 additions & 0 deletions readme/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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", "* ")
1 change: 1 addition & 0 deletions readme/result.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"- I\n- want\n- to\n- be\n- a\n- Markdown\n- list"
1 change: 1 addition & 0 deletions readme/result2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"xHello\nxworld"
1 change: 1 addition & 0 deletions readme/result3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"* Without linebreaks"
6 changes: 1 addition & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ const prependToLines = (string, linePrefix = "# ") => {

/**
* Returns the given string with an additional prefix on each line
* @example
* import prependToLines from "prepend-to-lines"
* const result = prependToLines("a\nb", "# ")
* result === "# a\n# b"
* @param {*} string The string that may contain "\n" and "\r"
* @param {string} string The string that may contain "\n" and "\r"
* @param {string} linePrefix The prefix that will be added to each line of `string`
* @returns {string} New string
*/
Expand Down

0 comments on commit 8bc1949

Please sign in to comment.