-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
44 lines (41 loc) · 900 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* `butt` > `b*tt`
*
* @param {string} value
* @param {string} [character='*']
* @returns {string}
*/
export function vowel(value, character) {
return value.replace(/[aeiouy]/g, character || '*')
}
/**
* `butt` > `b**t`
*
* @param {string} value
* @param {string} [character='*']
* @returns {string}
*/
export function inner(value, character) {
if (value.length <= 2) {
return value
}
return (
value.charAt(0) +
(character || '*').repeat(value.length - 2) +
value.charAt(value.length - 1)
)
}
/**
* `butt` > `@#$%`
*
* @param {number|string} value
* @param {string} [pattern='@#$%!&?']
* @returns {string}
*/
export function grawlix(value, pattern = '@#$%!&?') {
const length = typeof value === 'number' ? value : value.length
return (
pattern.repeat(Math.floor(length / pattern.length)) +
pattern.slice(0, length % pattern.length)
)
}