| Total Complexity | 1 |
| Complexity/F | 1 |
| Lines of Code | 26 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
| 1 | import {toLowerCase, trim, removeSpaces, replace, transliterate} from './strman'; |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Converts a value to a slug. |
||
| 5 | * @playground |
||
| 6 | * var slugify = require('strman').slugify; |
||
| 7 | * let title = "A Javascript string manipulation library."; |
||
| 8 | * let result = slugify(title); |
||
| 9 | * @param {String} value - The value to slugify |
||
| 10 | * @return {String} - The slugified value |
||
| 11 | */ |
||
| 12 | const slugify = (value) => { |
||
| 13 | |||
| 14 | let result = value; |
||
| 15 | result = toLowerCase(result); |
||
| 16 | result = trim(result); |
||
| 17 | result = removeSpaces(result, '-'); |
||
| 18 | result = replace(result, '&','-and-'); |
||
| 19 | result = transliterate(result); |
||
| 20 | result = replace(result, '[^\\w\\-]+', ''); |
||
| 21 | result = replace(result, '\-\-+','-'); |
||
| 22 | |||
| 23 | return result; |
||
| 24 | }; |
||
| 25 | |||
| 26 | export {slugify}; |
||
| 27 |