Skip to content

Instantly share code, notes, and snippets.

@sinedied
Last active June 5, 2022 15:29
Show Gist options
  • Save sinedied/c5021e85e61a236442ef638e40baa954 to your computer and use it in GitHub Desktop.
Save sinedied/c5021e85e61a236442ef638e40baa954 to your computer and use it in GitHub Desktop.
Fast reading experimentation
// Usage: fastRead('Lorem ipsum dolor sit amet')
function fastRead(text, left = '<b>', right = '</b>') {
return text?.replace(/[A-Za-zÀ-ÖØ-öø-ÿ0-9]+/gm, (word) => {
const split = word.length > 3 ? Math.ceil(word.length / 2) : 1;
return left + word.substring(0, split) + right + word.substring(split);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment