s => // s = input string
s.replace( // replace in the input string s ...
/[a-z]/gi, c => // ... each letter c (case insensitive)
( //
s + // if the previous letter was a vowel (or this
// (or this is the first1st iteration and s is still a string)
g( // or the current letter
i = // whose ASCII code - 1 is loaded in i
B(c)[0] - 1 //
) ? // is a vowel:
"" // append nothing
: // else:
"ei" // append "ei"
) + ( //
h = j => // h is a recursive function looking for the
// replacement letter
g(i) ^ // if the type of the current letter
g( // does not match the type of
j = -~j % 26 // the next letter in the alphabet
// obtained by incrementing j modulo 26
) ? // then:
h(j) // keep advancing by doing a recursive call
: // else:
B([ // output the letter
j + 1 | // whose ASCII code is j + 1
i & 96 // with bits #5 and #6 taken from i
]) //
)(i & 31), // initial call to h with j = i mod 32
B = Buffer, // define B for Buffer
g = i => // g is a helper function taking an integer
s = 1065233 // representing an ASCII code minus 1,
>> i & 1 // and returning 0 for consonant / 1 for vowel,
// and also saving the result in s
) // end of replace()
s => // s = input string
s.replace( // replace in s ...
/[a-z]/gi, c => // ... each letter c (case insensitive)
( //
s + // if the previous letter was a vowel
// (or this is the first iteration)
g( // or the current letter
i = // whose ASCII code - 1 is loaded in i
B(c)[0] - 1 //
) ? // is a vowel:
"" // append nothing
: // else:
"ei" // append "ei"
) + ( //
h = j => // h is a recursive function looking for the
// replacement letter
g(i) ^ // if the type of the current letter
g( // does not match the type of
j = -~j % 26 // the next letter in the alphabet
// obtained by incrementing j modulo 26
) ? // then:
h(j) // keep advancing by doing a recursive call
: // else:
B([ // output the letter
j + 1 | // whose ASCII code is j + 1
i & 96 // with bits #5 and #6 taken from i
]) //
)(i & 31), // initial call to h with j = i mod 32
B = Buffer, // define B for Buffer
g = i => // g is a helper function taking an integer
s = 1065233 // representing an ASCII code minus 1
>> i & 1 // and returning 0 for consonant / 1 for vowel
) // end of replace()
s => s.replace( // replace in the input string s ...
/[a-z]/gi, c => // ... each letter c (case insensitive)
( //
s + // if the previous letter was a vowel (or this
// is the 1st iteration and s is still a string)
g( // or the current letter
i = // whose ASCII code - 1 is loaded in i
B(c)[0] - 1 //
) ? // is a vowel:
"" // append nothing
: // else:
"ei" // append "ei"
) + ( //
h = j => // h is a recursive function looking for the
// replacement letter
g(i) ^ // if the type of the current letter
g( // does not match the type of
j = -~j % 26 // the next letter in the alphabet
// obtained by incrementing j modulo 26
) ? // then:
h(j) // keep advancing by doing a recursive call
: // else:
B([ // output the letter
j + 1 | // whose ASCII code is j + 1
i & 96 // with bits #5 and #6 taken from i
]) //
)(i & 31), // initial call to h with j = i mod 32
B = Buffer, // define B for Buffer
g = i => // g is a helper function taking an integer
s = 1065233 // representing an ASCII code minus 1,
>> i & 1 // returning 0 for consonant / 1 for vowel,
// and also saving the result in s
) // end of replace()
s => // s = input string
s.replace( // replace in s ...
/[a-z]/gi, c => // ... each letter c (case insensitive)
( //
s + // if the previous letter was a vowel
// (or this is the first iteration)
g( // or the current letter
i = // whose ASCII code - 1 is loaded in i
B(c)[0] - 1 // loaded in i
) ? // is a vowel:
"" // append nothing
: // else:
"ei" // append "ei"
) + ( //
h = j => // h is a recursive function looking for the
// replacement letter
g(i) ^ // if the type of the current letter
g( // is not equaldoes tonot match the type of
j = -~j % 26 // the next letter in the alphabet (wrapping) // obtained by incrementing j modulo 26
) ? // then:
h(j) // do keep advancing by doing a recursive call
: // else:
B([ // output the letter
j + 1 | // whose ASCII code is j + 1
i & 96 // with bits #5 and #6 taken from i
]) //
)(i & 31), // initial call to h with j = i mod 32
B = Buffer, // define B for Buffer
g = i => // g is a helper function taking an integer
s = 1065233 // representing an ASCII code minus 1
>> i & 1 // and returning 0 for consonant / 1 for vowel
) // end of replace()
s => // s = input string
s.replace( // replace in s
/[a-z]/gi, c => // each letter c (case insensitive)
( //
s + // if the previous letter was a vowel
// (or this is the first iteration)
g( // or the current letter
i = // whose ASCII code - 1 is
B(c)[0] - 1 // loaded in i
) ? // is a vowel:
"" // append nothing
: // else:
"ei" // append "ei"
) + ( //
h = j => // h is a recursive function
g(i) ^ // if the type of the current letter
g( // is not equal to the type of
j = -~j % 26 // the next letter in the alphabet (wrapping)
) ? // then:
h(j) // do a recursive call
: // else:
B([ // output the letter
j + 1 | // whose ASCII code is j + 1
i & 96 // with bits #5 and #6 taken from i
]) //
)(i & 31), // initial call to h with i mod 32
B = Buffer, // define B for Buffer
g = i => // g is a helper function taking an integer
s = 1065233 // representing an ASCII code minus 1
>> i & 1 // and returning 0 for consonant / 1 for vowel
) //
s => // s = input string
s.replace( // replace in s ...
/[a-z]/gi, c => // ... each letter c (case insensitive)
( //
s + // if the previous letter was a vowel
// (or this is the first iteration)
g( // or the current letter
i = // whose ASCII code - 1 is loaded in i
B(c)[0] - 1 //
) ? // is a vowel:
"" // append nothing
: // else:
"ei" // append "ei"
) + ( //
h = j => // h is a recursive function looking for the
// replacement letter
g(i) ^ // if the type of the current letter
g( // does not match the type of
j = -~j % 26 // the next letter in the alphabet // obtained by incrementing j modulo 26
) ? // then:
h(j) // keep advancing by doing a recursive call
: // else:
B([ // output the letter
j + 1 | // whose ASCII code is j + 1
i & 96 // with bits #5 and #6 taken from i
]) //
)(i & 31), // initial call to h with j = i mod 32
B = Buffer, // define B for Buffer
g = i => // g is a helper function taking an integer
s = 1065233 // representing an ASCII code minus 1
>> i & 1 // and returning 0 for consonant / 1 for vowel
) // end of replace()
Commented
s => // s = input string
s.replace( // replace in s
/[a-z]/gi, c => // each letter c (case insensitive)
( //
s + // if the previous letter was a vowel
// (or this is the first iteration)
g( // or the current letter
i = // whose ASCII code - 1 is
B(c)[0] - 1 // loaded in i
) ? // is a vowel:
"" // append nothing
: // else:
"ei" // append "ei"
) + ( //
h = j => // h is a recursive function
g(i) ^ // if the type of the current letter
g( // is not equal to the type of
j = -~j % 26 // the next letter in the alphabet (wrapping)
) ? // then:
h(j) // do a recursive call
: // else:
B([ // output the letter
j + 1 | // whose ASCII code is j + 1
i & 96 // with bits #5 and #6 taken from i
]) //
)(i & 31), // initial call to h with i mod 32
B = Buffer, // define B for Buffer
g = i => // g is a helper function taking an integer
s = 1065233 // representing an ASCII code minus 1
>> i & 1 // and returning 0 for consonant / 1 for vowel
) //
Commented
s => // s = input string
s.replace( // replace in s
/[a-z]/gi, c => // each letter c (case insensitive)
( //
s + // if the previous letter was a vowel
// (or this is the first iteration)
g( // or the current letter
i = // whose ASCII code - 1 is
B(c)[0] - 1 // loaded in i
) ? // is a vowel:
"" // append nothing
: // else:
"ei" // append "ei"
) + ( //
h = j => // h is a recursive function
g(i) ^ // if the type of the current letter
g( // is not equal to the type of
j = -~j % 26 // the next letter in the alphabet (wrapping)
) ? // then:
h(j) // do a recursive call
: // else:
B([ // output the letter
j + 1 | // whose ASCII code is j + 1
i & 96 // with bits #5 and #6 taken from i
]) //
)(i & 31), // initial call to h with i mod 32
B = Buffer, // define B for Buffer
g = i => // g is a helper function taking an integer
s = 1065233 // representing an ASCII code minus 1
>> i & 1 // and returning 0 for consonant / 1 for vowel
) //