-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
81 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
coverage/ | ||
f-ck.js | ||
f-ck.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,41 @@ | ||
'use strict'; | ||
'use strict' | ||
|
||
var repeat = require('repeat-string'); | ||
var repeat = require('repeat-string') | ||
|
||
module.exports = vowel; | ||
module.exports = vowel | ||
|
||
vowel.vowel = vowel; | ||
vowel.inner = inner; | ||
vowel.grawlix = grawlix; | ||
vowel.vowel = vowel | ||
vowel.inner = inner | ||
vowel.grawlix = grawlix | ||
|
||
var floor = Math.floor; | ||
var floor = Math.floor | ||
|
||
var DEFAULT = '*'; | ||
var GRAWLIX = '@#$%!&?'; | ||
var VOWELS = /[aeiouy]/g; | ||
var defaultCharacter = '*' | ||
var grawlixPattern = '@#$%!&?' | ||
var vowels = /[aeiouy]/g | ||
|
||
/* `butt` > `b*tt` */ | ||
function vowel(value, character) { | ||
return value.replace(VOWELS, character || DEFAULT); | ||
return value.replace(vowels, character || defaultCharacter) | ||
} | ||
|
||
/* `butt` > `b**t` */ | ||
function inner(value, character) { | ||
if (value.length <= 2) { | ||
return value; | ||
return value | ||
} | ||
|
||
return value.charAt(0) + | ||
repeat(character || DEFAULT, value.length - 2) + | ||
value.charAt(value.length - 1); | ||
return ( | ||
value.charAt(0) + | ||
repeat(character || defaultCharacter, value.length - 2) + | ||
value.charAt(value.length - 1) | ||
) | ||
} | ||
|
||
/* `butt` > `@#$%` */ | ||
function grawlix(value, pattern) { | ||
var chars = pattern || GRAWLIX; | ||
var length = typeof value === 'number' ? value : value.length; | ||
var count = chars.length; | ||
return repeat(chars, floor(length / count)) + chars.slice(0, length % count); | ||
var chars = pattern || grawlixPattern | ||
var length = typeof value === 'number' ? value : value.length | ||
var count = chars.length | ||
return repeat(chars, floor(length / count)) + chars.slice(0, length % count) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
'use strict'; | ||
'use strict' | ||
|
||
var test = require('tape'); | ||
var fck = require('.'); | ||
var test = require('tape') | ||
var fck = require('.') | ||
|
||
test('fck', function (t) { | ||
t.test('.vowel', function (st) { | ||
st.equal(fck.vowel('butt'), 'b*tt'); | ||
st.equal(fck.vowel('butt', '-'), 'b-tt'); | ||
st.end(); | ||
}); | ||
test('fck', function(t) { | ||
t.test('.vowel', function(st) { | ||
st.equal(fck.vowel('butt'), 'b*tt') | ||
st.equal(fck.vowel('butt', '-'), 'b-tt') | ||
st.end() | ||
}) | ||
|
||
t.test('.inner', function (st) { | ||
st.equal(fck.inner('butt'), 'b**t'); | ||
st.equal(fck.inner('butt', '-'), 'b--t'); | ||
st.equal(fck.inner('but'), 'b*t'); | ||
st.equal(fck.inner('bu'), 'bu'); | ||
st.equal(fck.inner('b'), 'b'); | ||
st.equal(fck.inner(''), ''); | ||
st.end(); | ||
}); | ||
t.test('.inner', function(st) { | ||
st.equal(fck.inner('butt'), 'b**t') | ||
st.equal(fck.inner('butt', '-'), 'b--t') | ||
st.equal(fck.inner('but'), 'b*t') | ||
st.equal(fck.inner('bu'), 'bu') | ||
st.equal(fck.inner('b'), 'b') | ||
st.equal(fck.inner(''), '') | ||
st.end() | ||
}) | ||
|
||
t.test('.grawlix', function (st) { | ||
st.equal(fck.grawlix('butt'), '@#$%'); | ||
st.equal(fck.grawlix(4), '@#$%'); | ||
st.equal(fck.grawlix('buttb'), '@#$%!'); | ||
st.equal(fck.grawlix('buttbu'), '@#$%!&'); | ||
st.equal(fck.grawlix('buttbut'), '@#$%!&?'); | ||
st.equal(fck.grawlix('buttbutt'), '@#$%!&?@'); | ||
st.equal(fck.grawlix('buttbuttb'), '@#$%!&?@#'); | ||
st.equal(fck.grawlix('but'), '@#$'); | ||
st.equal(fck.grawlix('bu'), '@#'); | ||
st.equal(fck.grawlix('b'), '@'); | ||
st.equal(fck.grawlix(''), ''); | ||
st.equal(fck.grawlix('butt', '*'), '****'); | ||
st.equal(fck.grawlix('butt', '123'), '1231'); | ||
st.end(); | ||
}); | ||
t.test('.grawlix', function(st) { | ||
st.equal(fck.grawlix('butt'), '@#$%') | ||
st.equal(fck.grawlix(4), '@#$%') | ||
st.equal(fck.grawlix('buttb'), '@#$%!') | ||
st.equal(fck.grawlix('buttbu'), '@#$%!&') | ||
st.equal(fck.grawlix('buttbut'), '@#$%!&?') | ||
st.equal(fck.grawlix('buttbutt'), '@#$%!&?@') | ||
st.equal(fck.grawlix('buttbuttb'), '@#$%!&?@#') | ||
st.equal(fck.grawlix('but'), '@#$') | ||
st.equal(fck.grawlix('bu'), '@#') | ||
st.equal(fck.grawlix('b'), '@') | ||
st.equal(fck.grawlix(''), '') | ||
st.equal(fck.grawlix('butt', '*'), '****') | ||
st.equal(fck.grawlix('butt', '123'), '1231') | ||
st.end() | ||
}) | ||
|
||
t.end(); | ||
}); | ||
t.end() | ||
}) |