Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function(text) {
this.cacheable();
var query = loaderUtils.parseQuery(this.query),
key = query.key,
rows = tsv.parseRows(text),
data = {
header: rows[0],
rows: rows.slice(1)
};
if (key) {
var indices = _.map(key, _.partial(indexOfOrThrow, data.header)),
allKeys = _.map(data.rows, _.partial(keyValue, indices));
if (allKeys.length !== _.uniq(allKeys).length) {
throw new Error("Duplicate primary keys in tsv file. See webpack.config.js.");
}
}
return JSON.stringify(data);
};