Prototype

This commit is contained in:
zenoamaro committed 2019-06-26 03:04:23 +02:00
commit 49591cbea3
9 files changed
+338

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
export function nextId() {
// @ts-ignore
const id = nextId.id || 0;
// @ts-ignore
nextId.id = id + 1;
return id;
}
export function splitWords(text) {
let words = [''];
for (let char of text) {
if ([' ', '\n'].includes(char)) words.push(char, '');
else words[words.length-1] += char;
}
if (words[words.length-1] === '') words = words.slice(0, words.length-1);
return words;
}