Last active
October 25, 2023 13:40
-
-
Save loggerhead/155bb3906158b229d348602a66231087 to your computer and use it in GitHub Desktop.
diff-example
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
[ | |
{ | |
"recharge": 900000 | |
}, | |
{ | |
"available": 0 | |
} | |
] |
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
world | |
a | |
c | |
} ; | |
} | |
} return tokens; | |
}; |
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
wordDiff.tokenize = function(value) { | |
const tokens = []; | |
let prevCharType = ''; | |
for (let i = 0; i < value.length; i++) { | |
const char = value[i]; | |
if (spaceRegExp.test(char)) { | |
if(prevCharType === 'space') { | |
tokens[tokens.length - 1] += ' '; | |
} else { | |
tokens.push(' '); | |
} | |
prevCharType = 'space'; | |
} else if (cannotBecomeWordRegExp.test(char)) { | |
tokens.push(char); | |
prevCharType = ''; | |
} else { | |
if(prevCharType === 'word') { | |
tokens[tokens.length - 1] += char; | |
} else { | |
tokens.push(char); | |
} | |
prevCharType = 'word'; | |
} | |
} | |
return tokens; | |
}; |
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
{ | |
"Aidan Gillen": { | |
"array": [ | |
"Game of Thrones", | |
"The Wire" | |
], | |
"string": "some string", | |
"int": "2", | |
"otherint": 4, | |
"aboolean": "true", | |
"boolean": false, | |
"null": null, | |
"a_null": 88, | |
"another_null": null, | |
"object": { | |
"foo": "bar" | |
} | |
}, | |
"Amy Ryan": [ | |
"In Treatment", | |
"The Wire" | |
], | |
"Annie Fitzgerald": [ | |
"True Blood", | |
"Big Love", | |
"The Sopranos", | |
"Oz" | |
], | |
"Anwan Glover": [ | |
"Treme", | |
"The Wire" | |
], | |
"Alexander Skarsg?rd": [ | |
"Generation Kill", | |
"True Blood" | |
], | |
"Alice Farmer": [ | |
"The Corner", | |
"Oz", | |
"The Wire" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment