Skip to content

Instantly share code, notes, and snippets.

Daniel W. Hieber dwhieb

Block or report user

Report or block dwhieb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dwhieb
dwhieb / transliterate.js
Created Feb 1, 2018
A unidirectional transliteration function
View transliterate.js
/**
* A unidirectional transliteration algorithm which makes a set of substitutions on a string, and handles common edge cases.
* @param {String} [string=''] The String to transliterate
* @param {Object} [substitutions={}] The set of substitutions to make on the String. Each key should be the character(s) to replace, and its value should be the character(s) to replace it with.
* @return {String} Returns a new String with the substitutions made
*/
const transliterate = (string = '', substitutions = {}) => {
// save the string to a new variable for readability
let str = string;
@dwhieb
dwhieb / transliterate-sorted.js
Last active Feb 1, 2018
An intermediate transliteration function that handles substrings during substitution but not other edge cases
View transliterate-sorted.js
// An intermediate transliteration function that handles substrings
// but does not handle other edge cases
const sortedTransliterate = (string = '', substitutions = {}) => {
// save the string to a new variable for readability
let str = string;
// get the list of substitutions
Object.entries(substitutions)
@dwhieb
dwhieb / transliterate-simple.js
Last active Feb 1, 2018
A basic transliteration function that makes string replacements but does not handle common edge cases
View transliterate-simple.js
// A simple version of the transliterate method which makes replacements
// but does not handle common edge cases.
const simpleTransliterate = (string = '', substitutions = {}) => {
// save the string to a new variable for readability
let str = string;
// get the list of substitutions
Object.entries(substitutions)
You can’t perform that action at this time.