spongemock
v0.0.8
Published
sPonGeBoB MoCKiNg mEmE TeXt TRansFoRmEr
Downloads
247
Readme
Spongemock
This library provides resources for working with text to transform it into Spongebob mocking meme text.
Algorithm
At first, I thought that the letters started with lowercase and just alternated.
aT fIrSt, I tHoUgHt...
However, after reviewing quite a few uses of the meme, I found that there is an element of randomness to it.
This library will inspect the text and transform letters to uppercase or lowercase according to the following algorithm:
- If a non-ASCII or non-letter is encountered, it is ignored
- The first letter encountered has a 50% chance of being upper or lowercase
- If the next letter encountered is a different case, it has
a 15% chance of being transformed (85% chance of staying a
different case). This means that
an
orAN
arrangements should appear infrequently, but occassionally.An
oraN
arrangements will appear often.
- If the next letter encountered is the same case, it thus has a 85% chance of being transformed.
- If a letter is the same case as two previous letters,
it has a 98% chance of being transformed. Arrangements of
three of the same case as in
ana
orANA
are rare, but I have seen them occur in these memes.
Usage
import { spongeMock } from 'spongeMock';
spongeMock("This is a test string.");
// 'tHiS iS a TeSt StRiNg.'
Simple as that.
CLI
You can yarn global add spongemock
to add a cli tool that
allows you to spongemockify strings and files. You can give
it a list of files to mock or else it will read from stdin.
spongemock README.md
git log | spongemock
spongemock -e "works on strings with -e argument"