You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
707 B
22 lines
707 B
import {csvParse, dsvFormat, tsvParse} from "d3-dsv"; |
|
import text from "./text"; |
|
|
|
function dsvParse(parse) { |
|
return function(input, init, row) { |
|
if (arguments.length === 2 && typeof init === "function") row = init, init = undefined; |
|
return text(input, init).then(function(response) { |
|
return parse(response, row); |
|
}); |
|
}; |
|
} |
|
|
|
export default function dsv(delimiter, input, init, row) { |
|
if (arguments.length === 3 && typeof init === "function") row = init, init = undefined; |
|
var format = dsvFormat(delimiter); |
|
return text(input, init).then(function(response) { |
|
return format.parse(response, row); |
|
}); |
|
} |
|
|
|
export var csv = dsvParse(csvParse); |
|
export var tsv = dsvParse(tsvParse);
|
|
|