Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ------------------------------------------------------------------------------------------
// tsvParse(...) ============================================================================
// without row mapper -----------------------------------------------------------------------
parseArray = d3Dsv.tsvParse(tsvTestStringWithHeader);
columns = parseArray.columns;
str = parseArray[0]['Year'];
// date = parseArray[0]['Year']; // fails, return value is string
// with row mapper ---------------------------------------------------------------------------
parseMappedArray = d3Dsv.tsvParse(tsvTestStringWithHeader, (rawRow, index, columns) => {
let rr: d3Dsv.DSVRowString = rawRow;
let i: number = index;
let c: string[] = columns;
let pr: ParsedTestObject;
pr = {
year: new Date(+rr['Year'], 0, 1),
make: rr['Make'],
model: rr['Model'],
length: +rr['Length']
};
return pr;
});
return text(url).then(text => Promise.resolve(tsvParse(text)));
}
.then(data => tsvParse(data, parseData(parseDate)))
return promiseMSFT;
return text(url).then(text => Promise.resolve(tsvParse(text)));
}
.then(data => tsvParse(data, parseData(d => new Date(+d))));
return promiseIntraDayDiscontinuous;
.action(filename => {
const content = fs.readFileSync(resolve(filename), 'utf8');
const converted = JSON.stringify(d3Dsv.tsvParse(content), null, 2);
process.stdout.write(converted);
});
function onconcat(body) {
var data = dsv.tsvParse(String(body)).map(mapper)
fs.writeFile('index.json', JSON.stringify(data, 0, 2) + '\n', bail)
}
.then(data => tsvParse(data, d => {
d.date = new Date(parseDate(d.date).getTime());
d.open = +d.open;
d.high = +d.high;
d.low = +d.low;
d.close = +d.close;
d.volume = +d.volume;
return d;
}))
.then(data => {
.then(data => tsvParse(data, d => {
d = parseData(parseDate)(d);
d.SP500Close = +d.SP500Close;
d.AAPLClose = +d.AAPLClose;
d.GEClose = +d.GEClose;
return d;
}));
return promiseCompare;
DataSet.registerConnector('tsv', (str: string) => {
return tsvParse(str);
});