Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 7x 7x 7x 7x | import { dsvFormat as d3Dsv } from 'd3-dsv'; import DSVArr from './dsv-arr'; /** * Parses and converts data formatted in DSV string to a manageable internal format. * * @todo Support to be given for https://tools.ietf.org/html/rfc4180. * @todo Sample implementation https://github.com/knrz/CSV.js/. * * @param {string} str - The input DSV string. * @param {Object} options - Option to control the behaviour of the parsing. * @param {boolean} [options.firstRowHeader=true] - Whether the first row of the dsv string data is header or not. * @param {string} [options.fieldSeparator=","] - The separator of two consecutive field. * @return {Array} Returns an array of headers and column major data. * @example * * // Sample input data: * const data = ` * a,b,c * 1,2,3 * 4,5,6 * 7,8,9 * ` */ function DSVStr (str, options) { const defaultOption = { firstRowHeader: true, fieldSeparator: ',' }; options = Object.assign({}, defaultOption, options); const dsv = d3Dsv(options.fieldSeparator); return DSVArr(dsv.parseRows(str), options); } export default DSVStr; |