Prototype
This commit is contained in:
commit
49591cbea3
9 files changed
+338
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user