Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
num = parseMappedArray[0].length;
// tsvParseRows(...) ============================================================================
// without row mapper -----------------------------------------------------------------------
parseRowsArray = d3Dsv.tsvParseRows(tsvTestString);
str = parseRowsArray[0][0]; // 'Year' of first row
// date = parseRowsArray[0][0]; // fails, return value is string
// with row mapper ---------------------------------------------------------------------------
parseRowsMappedArray = d3Dsv.tsvParseRows(tsvTestString, (rawRow, index) => {
let rr: string[] = rawRow;
let i: number = index;
let pr: ParsedTestObject;
pr = {
year: new Date(+rr[0], 0, 1),
make: rr[1],
model: rr[2],
length: +rr[3]
};
return pr;
});
date = parseRowsMappedArray[0].year;
});
columns = parseMappedArray.columns;
date = parseMappedArray[0].year;
str = parseMappedArray[0].make;
str = parseMappedArray[0].model;
num = parseMappedArray[0].length;
// tsvParseRows(...) ============================================================================
// without row mapper -----------------------------------------------------------------------
parseRowsArray = d3Dsv.tsvParseRows(tsvTestString);
str = parseRowsArray[0][0]; // 'Year' of first row
// date = parseRowsArray[0][0]; // fails, return value is string
// with row mapper ---------------------------------------------------------------------------
parseRowsMappedArray = d3Dsv.tsvParseRows(tsvTestString, (rawRow, index) => {
let rr: string[] = rawRow;
let i: number = index;
let pr: ParsedTestObject;
pr = {
year: new Date(+rr[0], 0, 1),
make: rr[1],
model: rr[2],
return text(filepath, (error, chrInfoText) => {
if (error) {
// console.warn('Chromosome info not found at:', filepath);
if (success) success(null);
} else {
const data = tsvParseRows(chrInfoText);
const chromInfo = parseChromsizesRows(data);
Object.keys(chromInfo).forEach((key) => {
ret[key] = chromInfo[key];
});
if (success) success(ret);
}
});
}
return tileProxy.text(filepath, (error, chrInfoText) => {
if (error) {
// console.warn('Chromosome info not found at:', filepath);
if (success) success(null);
} else {
const data = tsvParseRows(chrInfoText);
const chromInfo = parseChromsizesRows(data);
Object.keys(chromInfo).forEach((key) => {
ret[key] = chromInfo[key];
});
if (success) success(ret);
}
}, pubSub).then(() => ret);
}
function getMessagesToImport(file) {
const content = readFileSync(file).toString();
const messages = tsvParseRows(content, ([key, value]) => {
try {
// value 的形式和 JSON 中的字符串值一致,其中的特殊字符是以转义形式存在的,
// 如换行符 \n,在 value 中占两个字符,需要转成真正的换行符。
value = JSON.parse(`"${value}"`);
} catch (e) {
throw new Error(`Illegal message: ${value}`);
}
return [key, value];
});
const rst = {};
const duplicateKeys = new Set();
messages.forEach(([key, value]) => {
if (rst.hasOwnProperty(key)) {
duplicateKeys.add(key);
}
rst[key] = value;
processTSVFile: function (content) {
var is_column_header = this.uploadPane.isColumnHeader,
parsed = false;
if (is_column_header) {
parsed = tsvParse(content, function (d) {
return d;
});
} else {
parsed = tsvParseRows(content, function (d) {
return d;
});
}
console.log("file content ", parsed, this.uploadPane.getFileType() );
return parsed;
},
parser: d => tsvParseRows(d)
};
const parseChromInfo = (text) => {
if (text.length == 0)
return null;
const tsv = tsvParseRows(text);
const cumValues = [];
const chromLengths = {};
const chrPositions = {};
let totalLength = 0;
for (let i = 0; i < tsv.length; i++) {
const length = Number(tsv[i][1]);
totalLength += length;
const newValue = {
id: i,
chr: tsv[i][0],
pos: totalLength - length,
};
d3Text(file, (error, data) => {
if (error) callback(error);
const rows = tsvParseRows(data)
.map(([id, text, count]) => ({
id,
text: cleanUrl(text),
count: +count
}));
callback(error, rows);
});
}