Created
February 14, 2018 12:59
-
-
Save njlr/cde36e17d1a434bcf867dac51aa586e3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export const parseCsv = function * (symbols) { | |
let word = ''; | |
let line = []; | |
for (const symbol of symbols) { | |
if (symbol == '\n') { | |
line.push(word); | |
yield line; | |
word = ''; | |
line = []; | |
} else if (symbol == ',') { | |
line.push(word); | |
word = ''; | |
} else { | |
word += symbol; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment