|
Last change
on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Prototype 1.1
|
-
Property mode
set to
100644
|
|
File size:
710 bytes
|
| Line | |
|---|
| 1 | import {csvParse, dsvFormat, tsvParse} from "d3-dsv";
|
|---|
| 2 | import text from "./text.js";
|
|---|
| 3 |
|
|---|
| 4 | function dsvParse(parse) {
|
|---|
| 5 | return function(input, init, row) {
|
|---|
| 6 | if (arguments.length === 2 && typeof init === "function") row = init, init = undefined;
|
|---|
| 7 | return text(input, init).then(function(response) {
|
|---|
| 8 | return parse(response, row);
|
|---|
| 9 | });
|
|---|
| 10 | };
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | export default function dsv(delimiter, input, init, row) {
|
|---|
| 14 | if (arguments.length === 3 && typeof init === "function") row = init, init = undefined;
|
|---|
| 15 | var format = dsvFormat(delimiter);
|
|---|
| 16 | return text(input, init).then(function(response) {
|
|---|
| 17 | return format.parse(response, row);
|
|---|
| 18 | });
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | export var csv = dsvParse(csvParse);
|
|---|
| 22 | export var tsv = dsvParse(tsvParse);
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.