Last active
June 5, 2022 15:29
-
-
Save sinedied/c5021e85e61a236442ef638e40baa954 to your computer and use it in GitHub Desktop.
Fast reading experimentation
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
// 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