diff --git a/docs/methods.md b/docs/methods.md index 06fcbfc..81ca416 100644 --- a/docs/methods.md +++ b/docs/methods.md @@ -94,6 +94,7 @@ - [whenIsUuid](#whenisuuid) - [whenTest](#whentest) - [wordCount](#wordcount) +- [wordWrap](#wordwrap) - [words](#words) - [wrap](#wrap) - [value](#value) @@ -1006,6 +1007,17 @@ Stringable.of('Hello, world!').wordCount(); // 2 ``` +### wordWrap +The `wordWrap` method wraps a string to a given number of characters: +```js +Stringable.of('The quick brown fox jumped over the lazy dog').wordWrap(20, "
\n"); + +/* +The quick brown fox
+jumped over the lazy
+dog. +*/ +``` ### words The `words` method limits the number of words in a string. If necessary, you may specify an additional string that will be appended to the truncated string: ```js diff --git a/docs/statics.md b/docs/statics.md index 91edca7..493dcdd 100644 --- a/docs/statics.md +++ b/docs/statics.md @@ -63,9 +63,10 @@ - [ucsplit](#ucsplit) - [upper](#upper) - [wordCount](#wordcount) +- [wordWrap](#wordwrap) - [words](#words) - [wrap](#wrap) -- [preg_quote](#pregquote) +- [preg_quote](#preg_quote) - [random](#random) - [createRandomStringsUsing](#createrandomstringsusing) - [createRandomStringsUsingSequence](#createrandomstringsusingsequence) @@ -721,6 +722,17 @@ Str.wordCount('Hello, world!'); // 2 ``` +### wordWrap +The `wordWrap` function wraps a string to a given number of characters: +```js +Str.wordWrap('The quick brown fox jumped over the lazy dog', 20, "
\n"); + +/* +The quick brown fox
+jumped over the lazy
+dog. +*/ +``` ### uuid The `uuid` function generates a UUID (version 4): ```js