Skip to content
Browse files

Parameterize delimeter.

  • Loading branch information...
1 parent abdabab commit 5041ebed57db7014f50f9c6ca08ca7cd94e0cadd @mpareja committed Mar 3, 2013
Showing with 5 additions and 5 deletions.
  1. +2 −2 index.js
  2. +3 −3 scanner.js
View
4 index.js
@@ -2,8 +2,8 @@ var scanner = require('./scanner');
var parser = require('./parser');
var combiner = require('stream-combiner');
-module.exports = function () {
- var s = scanner(),
+module.exports = function (delimiter) {
+ var s = scanner(delimiter || ','),
p = parser(),
c = combiner(s, p);
View
6 scanner.js
@@ -1,5 +1,5 @@
var through = require('through');
-module.exports = function () {
+module.exports = function (delimiter) {
var buffer = '';
var position = 0;
@@ -29,9 +29,9 @@ module.exports = function () {
function scan() {
if (c === null) { return null; }
+ if (c === delimiter) { return separator(); }
switch (c) {
case '"': return quote();
- case ',': return separator();
case '\n': return eol('\r');
case '\r': return eol('\n');
default: return unquoted();
@@ -79,7 +79,7 @@ module.exports = function () {
function unquoted() {
var literal = c;
- while (consume() && c !== ',' && c !== '\n' && c !== '\r') {
+ while (consume() && c !== delimiter && c !== '\n' && c !== '\r') {
literal += c;
}
return tokenize('literal', literal);

0 comments on commit 5041ebe

Please sign in to comment.
Something went wrong with that request. Please try again.