Pull callback args into variables
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
9d898bdf47
commit
55b7c55efe
1 changed files with 4 additions and 2 deletions
|
@ -4,12 +4,14 @@ export function linkify(text, callback) {
|
|||
const matches = text.matchAll(regex);
|
||||
let curr = 0;
|
||||
for (let match of matches) {
|
||||
callback(text.slice(curr, match.index), false);
|
||||
const precedingText = text.slice(curr, match.index);
|
||||
callback(precedingText, false);
|
||||
callback(match[0], true);
|
||||
const len = match[0].length;
|
||||
curr = match.index + len;
|
||||
}
|
||||
callback(text.slice(curr), false);
|
||||
const remainingText = text.slice(curr);
|
||||
callback(remainingText, false);
|
||||
}
|
||||
|
||||
export function tests() {
|
||||
|
|
Reference in a new issue