Socket
Socket
Sign inDemoInstall

csv-to-js-parser

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv-to-js-parser - npm Package Compare versions

Comparing version 2.3.5 to 2.3.6

doc/-_anonymous_-__webpack_modules__.345-Pool.html

36

app.js
/*
The MIT License (MIT)
Copyright (c) Aleksandr Meniailo (Александр Меняйло), Mendeo 2020 (deorathemen@gmail.com)
Copyright (c) Aleksandr Meniailo (Александр Меняйло), Mendeo 2024 (deorathemen@gmail.com)

@@ -26,2 +26,13 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

'use strict';
/**
* Converting csv data to an array of JavaScript objects.
* The delimeter and description parameters can be set in a different order: first description, then delimeter.
* @param {string} data - csv table as a string
* @param {string} [param1=','] - input data column delimeter
* @param {object} [param2={columnName1 : { type: 'string', 'group': 1 }, columnName2 : { type: 'string', 'group': 1 }, ...}] - description
* @param {...object} param2.columnName - the name of this property must match the column header in the input data.
* @param {string} param2.columnName.type - describes the type of column values. Three options are supported: "number", "string" and "boolean".
* @param {number} param2.columnName.group - the order of grouping. Have to be set only for the columns that need to be grouped. There must be at least one such column. The values of this property indicate the order in which the columns should be grouped. For example columns with "group: 1" are grouped first, then columns with "group: 2" are grouped inside the first grouping and so on. You can perceive the group property in the same way as a "Group By" construct in SQL.
* @returns {Array.<object>}
*/
module.exports.csvToObj = function(data, param1, param2)

@@ -453,2 +464,9 @@ {

/**
* Reverse convert an array of objects from csvToObj to CSV text format.
* @param {Array.<object>} obj - input array of objects (the format must match the one returned by csvToObj).
* @param {string} [delimiter=','] - column delimiter in the output table. If not specified, then the default is comma ",".
* @param {string} [rowDelimiter='\n'] - rows separator. If not specified, then the default is "LF" (\n). For windows, it is reasonable to specify the "CRLF" delimiter (\r\n).
* @returns {string}
*/
module.exports.objToCsv = function(obj, delimiter, rowDelimiter)

@@ -544,2 +562,10 @@ {

/**
* In the objects that the csvToObj function returns, the properties that are responsible for non-grouped columns contain arrays of the same length. Using the combineArrays function, you can convert these arrays to a single array of objects, which in some cases may be a more natural representation of data in JavaScript.
* @param {Array.<object>} obj - input object (usually from csvToObj)
* @param {string} newKey - the name of the property in which the arrays will be combined
* @param {Array.<string>} arrayKeys - the names of the properties in the input object that are arrays
* @param {Array.<string>} [newArrayKeys] - if specified: the names of properties that override properties from arrayKeys, i.e. the output object will have newArrayKeys properties instead of arrayKeys properties
* @returns {Array.<object>}
*/
module.exports.combineArrays = function(obj, newKey, arrayKeys, newArrayKeys)

@@ -580,2 +606,10 @@ {

/**
* Reverse conversion result from combineArrays to an object with separate arrays
* @param {Array.<object>} obj - input object (usually from combineArrays)
* @param {string} objArrayKey - name of the property where the arrays are combined
* @param {string} arrayKeys - names of properties in the input object to convert it to separate arrays
* @param {Array.<string>} [newArrayKeys] - if specified, the names of properties that override properties from arrayKeys, i.e. the output object will have newArrayKeys properties instead of arrayKeys properties
* @returns {Array.<object>}
*/
module.exports.separateArrays = function(obj, objArrayKey, arrayKeys, newArrayKeys)

@@ -582,0 +616,0 @@ {

13

package.json
{
"name": "csv-to-js-parser",
"version": "2.3.5",
"version": "2.3.6",
"description": "Converting csv data into array of JavaScript objects. This module can group input data.",

@@ -17,7 +17,14 @@ "main": "app.js",

],
"author": "Mendeo",
"author": {
"name": "Aleksandr Menyaylo",
"email": "deorathemen@gmail.com",
"url": "https://mendeo.ru"
},
"license": "MIT",
"devDependencies": {
"mocha": "^10.1.0"
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.5.0",
"globals": "^15.6.0",
"mocha": "^10.4.0"
}
}

@@ -1,13 +0,1 @@

## Version 2.3. What's new?
In the new version, the correct handling of double quotes (") has been added in accordance with [rfc4180](https://datatracker.ietf.org/doc/html/rfc4180).
* Values in fields can now be enclosed by double quotes, for example
"aaa","bbb"
* Now you can use separator character or even line breaks inside double quotes:
"aaa,aa","bbb
bb"
* Also, the field can contain the symbol (") itself, but it must be escaped:
"aaa""aa","bbb""aaa""bb"
* Fields that are not enclosed by double quotes, but containing this characters will also be processed correctly:
aa"aa,bb"aaa"bbb
# Convert csv data to an array of JavaScript objects

@@ -331,3 +319,3 @@

The objToCsv function accepts the following parameters:
* obj: input array of objectc (the format must match the one returned by csvToObj).
* obj: input array of objects (the format must match the one returned by csvToObj).
* delimeter [optional]: column delimiter in the output table. If not specified, then the default is comma ",".

@@ -334,0 +322,0 @@ * rowDelimeter [optional]: rows separator. If not specified, then the default is "LF" (\n). For windows, it is reasonable to specify the "CRLF" delimiter (\r\n).

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc