src/slugify.js   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 26
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
cc 0
c 3
b 0
f 1
nc 1
dl 0
loc 26
rs 10
wmc 1
mnd 0
bc 1
fnc 1
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A slugify.js ➔ ??? 0 13 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