Last active
December 27, 2018 10:05
-
-
Save francisrstokes/54bb2941a99f8c8271f5deb6353ae9a8 to your computer and use it in GitHub Desktop.
Arcsecond Article
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
const { | |
parse, | |
char, | |
many, | |
regex, | |
anythingExcept, | |
sepBy | |
} = require('arcsecond'); | |
const joinedMany = parser => many (parser) .map(x => x.join('')); | |
const cell = joinedMany (anythingExcept (regex (/^[,\n]/))); | |
const cells = sepBy (char (',')) (cell); | |
const parser = sepBy (char ('\n')) (cells); | |
const data = ` | |
1,React JS,"A declarative efficient and flexible JavaScript library for building user interfaces" | |
2,Vue.js,"Vue.js is a progressive incrementally-adoptable JavaScript framework for building UI on the web." | |
3,Angular,"One framework. Mobile & desktop." | |
4,ember.js,"Ember.js - A JavaScript framework for creating ambitious web applications"`; | |
console.log( | |
parse (parser) (data) | |
); | |
// -> [ | |
// [ '' ], | |
// [ '1', 'React JS', '"A declarative efficient and flexible JavaScript library for building user interfaces"' ], | |
// [ '2', 'Vue.js', '"Vue.js is a progressive incrementally-adoptable JavaScript framework for building UI on the web."' ], | |
// [ '3', 'Angular', '"One framework. Mobile & desktop."' ], | |
// [ '4', 'ember.js', '"Ember.js - A JavaScript framework for creating ambitious web applications"' ], | |
// ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment