diff --git a/index.d.ts b/index.d.ts index c5fdb78..ec82718 100644 --- a/index.d.ts +++ b/index.d.ts @@ -5,8 +5,8 @@ Trim from the start and end of a string. ```js import trimNewlines from 'trim-newlines'; -trimNewlines('\nš¦\r\n'); -//=> 'š¦' +trimNewlines('\nš¦\nš¦\r\n'); +//=> 'š¦\nš¦' ``` */ export function trimNewlines(string: string): string; diff --git a/readme.md b/readme.md index 2b8561b..0fb6ea3 100644 --- a/readme.md +++ b/readme.md @@ -2,6 +2,8 @@ > Trim [newlines](https://en.wikipedia.org/wiki/Newline) from the start and/or end of a string +Looking to trim all whitespace, not just newlines? Use `String#trim()`, `String#trimStart()`, or `String#trimEnd()`. + ## Install ``` @@ -11,15 +13,15 @@ $ npm install trim-newlines ## Usage ```js -import trimNewlines from 'trim-newlines'; +import {trimNewlines, trimNewlinesStart, trimNewlinesEnd} from 'trim-newlines'; -trimNewlines('\nš¦\r\n'); -//=> 'š¦' +trimNewlines('\nš¦\nš¦\r\n'); +//=> 'š¦\nš¦' -trimNewlines.start('\nš¦\r\n'); +trimNewlinesStart('\nš¦\r\n'); //=> 'š¦\r\n' -trimNewlines.end('\nš¦\r\n'); +trimNewlinesEnd('\nš¦\r\n'); //=> '\nš¦' ``` @@ -29,19 +31,14 @@ trimNewlines.end('\nš¦\r\n'); Trim from the start and end of a string. -### trimNewlines.start(string) +### trimNewlinesStart(string) Trim from the start of a string. -### trimNewlines.end(string) +### trimNewlinesEnd(string) Trim from the end of a string. -## Related - -- [trim-left](https://github.com/sindresorhus/trim-left) - Similar to `String#trim()` but removes only whitespace on the left -- [trim-right](https://github.com/sindresorhus/trim-right) - Similar to `String#trim()` but removes only whitespace on the right. - ---