Skip to content

Commit 3a04130

Browse files
committed
Add example for widont
1 parent c953bd4 commit 3a04130

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ import * as journalize from 'journalize';
8484
- [Examples](#examples-8)
8585
- [widont](#widont)
8686
- [Parameters](#parameters-9)
87+
- [Examples](#examples-9)
8788
- [yesno](#yesno)
8889
- [Parameters](#parameters-10)
89-
- [Examples](#examples-9)
90+
- [Examples](#examples-10)
9091

9192
### apdate
9293

@@ -338,6 +339,18 @@ character.
338339
- `val` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
339340
- `replaceChar` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The character to replace the space with (optional, default `'\xA0'`)
340341

342+
#### Examples
343+
344+
```javascript
345+
var journalize = require('journalize');
346+
347+
journalize.widont('this is a string');
348+
// returns 'this is a string'
349+
350+
journalize.widont('this is a string', 'HELLO');
351+
// returns 'this is aHELLOstring'
352+
```
353+
341354
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
342355

343356
### yesno

src/widont.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ const widontRegex = new RegExp(/\s+([^\s]*)\s*$/);
2525
* @param {string} val
2626
* @param {string} [replaceChar='\xA0'] The character to replace the space with
2727
* @returns {string}
28+
* @example
29+
*
30+
* var journalize = require('journalize');
31+
*
32+
* journalize.widont('this is a string');
33+
* // returns 'this is a string'
34+
*
35+
* journalize.widont('this is a string', 'HELLO');
36+
* // returns 'this is aHELLOstring'
37+
*
2838
*/
2939
export default function widont(val, replaceChar = nbsp) {
3040
// if `val` is undefined or null, return an empty string

0 commit comments

Comments
 (0)