{"_id":"@angeloevangelista/csv-parser-js","_rev":"2-89476c8a907a20344b2352afadb74e96","name":"@angeloevangelista/csv-parser-js","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@angeloevangelista/csv-parser-js","version":"1.0.0","description":"A tool to serialize csv content into JSON","main":"src/index.js","devDependencies":{"ts-loader":"^8.0.5","typescript":"^4.0.3","webpack":"^5.1.3","webpack-cli":"^4.0.0","webpack-dev-server":"^3.11.0"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1","dev":"webpack serve","build":"webpack"},"repository":{"type":"git","url":"git+https://github.com/angeloevangelista/csv-parser-js.git"},"keywords":["csv","js","json","parse","browser","open-source"],"author":{"name":"Angelo Evangelista","email":"angeloevan.ane@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/angeloevangelista/csv-parser-js/issues"},"homepage":"https://github.com/angeloevangelista/csv-parser-js#readme","gitHead":"d33f4c947aca970b4621f25fe3332fdd4758a7fc","_id":"@angeloevangelista/csv-parser-js@1.0.0","_nodeVersion":"14.15.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-mBirjqS5+KRXtiQx/+VkUiJCn4b3NeKAXJLGyeBkM8aN0RyLUky0KVyubeVj5MGL2FTkmYdXQvDeMJ9/kSL+Eg==","shasum":"17099c0496590d1ac4778a61ea40610bfd5301b2","tarball":"https://registry.npmjs.org/@angeloevangelista/csv-parser-js/-/csv-parser-js-1.0.0.tgz","fileCount":23,"unpackedSize":446074,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf4qFDCRA9TVsSAnZWagAAnY4P/iHWsXn0+CU7hg+P4QQl\ngxYsuN9YfUwOqfb3v0zKj+azUunGBqxsDOL0dOAtNqHSjWjtxSH0Tw2L4lQe\nicITw9B0DvDWiD7wOvlVNb6uOyxjGkDh0yHODMs4TwdaNZycLU1qSuyDdpm7\nInc2TKg/JWsNAcuK/rIyUZJkNMl0wnyDLfAHX9KHoFWJN4PFH71PkWbHz0YY\nQTzvkv++jcWRHGYsXjEzpFffpCwPvhNcH5JSh/F68nRE0I7lYRaFICqY+JXS\nj7NoiQlPUA65otS2CZpbvjxESqPTk4+ra/rVOC7M7hBK4Jng/nNueTJIk/AC\n2qAeXE6+MbkEqw3a24nt2T4qnUD2PNy6Il9KInCv0xvuoTlvsiTC8XBJV99A\nrf1ZP6DYh0duC9WIAea0NimNz8imQmKmyF5ySaK/xr8N+GWX6fVjpjeJtBYV\nIYpt5GkVxpL6t18Hm94pYBfj6oP/6rtBmaBeHi0iGhLY3y8wedgnpXgLvuQ2\neEcPkPO4jtFT9ng2XELZl4W6q6P40MbXjMoOtcH2qOrc7KjzcTbQMdOas6oF\nYkNmN2aooT3YWJRSPVVx0F2CZZ/+SN/CTsI9nLxy3qJQtmB1w3oxQoHAsMVr\n2pEfNWHOin7EaOesBDhWcSHx7K4/ZN47QE/opzb9n2JrJJ9YvRytpx7q0QvO\nrPLA\r\n=+IRM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEYob28FpNgX/9XQaaK+T+6SL6iscJbxI5J44w2nRWmQAiEA6XrA1d4huekUlxTP/kANfxQO25zWNzn8QnkrKHzweUc="}]},"_npmUser":{"name":"angeloevangelista","email":"angeloevan.ane@gmail.com"},"directories":{},"maintainers":[{"name":"angeloevangelista","email":"angeloevan.ane@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/csv-parser-js_1.0.0_1608687939252_0.5300415946862747"},"_hasShrinkwrap":false}},"time":{"created":"2020-12-23T01:45:39.188Z","1.0.0":"2020-12-23T01:45:39.490Z","modified":"2022-08-31T17:06:50.093Z"},"maintainers":[{"email":"angeloevan.ane@gmail.com","name":"angeloevan.ane"}],"description":"A tool to serialize csv content into JSON","homepage":"https://github.com/angeloevangelista/csv-parser-js#readme","keywords":["csv","js","json","parse","browser","open-source"],"repository":{"type":"git","url":"git+https://github.com/angeloevangelista/csv-parser-js.git"},"author":{"name":"Angelo Evangelista","email":"angeloevan.ane@gmail.com"},"bugs":{"url":"https://github.com/angeloevangelista/csv-parser-js/issues"},"license":"MIT","readme":"<p align=\"center\">\n  <a href=\"https://github.com/github_username/repo_name\">\n    <img src=\"./.github/images/csv-parser-logo.png\" alt=\"CSV Parser Js\" width=\"80\">\n  </a>\n\n  <h3 align=\"center\">CSV Parser Js</h3>\n\n  <p align=\"center\">\n    A lib to serialize CSV files into JSON objects.\n  </p>\n</p>\n\n# Overview\n\n- [Usage](#usage)\n  - [handleInputChange](#handleInputChange)\n  - [loadContent](#loadContent)\n  - [toJson](#toJson)\n  - [validateFields](#validateFields)\n    <!-- - [Contribute](#contribute) -->\n    <!-- - [How to run](#how-to-run) -->\n- [License](#memo-license)\n\n# Usage\n\nImport the files, that you can find on `build/`, in your page, then you will be able to invoke `CSV`. It contains three methods you can use to handle your CSV files on browser\n\n## **handleInputChange**\n\nIt's basically what you need to add on change event of your input element and it will return you the serialized file, it's not necessary to check if the input have files, but if you do not do it, the promise will be reject, so just treat the exception.\n\n**Parameters**\n\n```typescript\ninterface IParams {\n  inputElement: HTMLInputElement;\n  separator?: string; // default = ','\n}\n```\n\n**Return type**\n\n🕒 Promise\n\nIf the file is in blank, You will receive `undefined`, but if the file has a valid content you will receive an object in the following format:\n\n```typescript\ninterface IResponse {\n  filename: string;\n  content: object[]; // the properties will follow the header found in this CSV file\n}\n```\n\n## **loadContent**\n\nThis function and the other one 'toJson' are just exported in case you wish to validate by yourself the content or anything else before serialize.\n\n**Parameters**\n\n```typescript\ninterface IParams {\n  csvFile: Blob | File;\n}\n```\n\n**Return type**\n\n🕒 Promise\n\nThis function returns the raw content as a string.\n\n## **toJson**\n\nThis function and the other one 'toJson' are just exported in case you wish to validate by yourself the content or anything else before serialize.\n\n**Parameters**\n\n**csvContent**: The raw content of a CSV file.\n\n```typescript\ninterface IParams {\n  csvContent: string;\n  separator?: string; // default = ','\n}\n```\n\n**Return type**\n\nThis function returns an object with the serialized CSV and also the next function, witch gives You the possibility to check the columns of the collection.\n\n```typescript\ninterface IResponse {\n  serializedData: Array<{\n    [key: string]: string | number;\n  }>;\n  validateFields: (\n    expectedColumns: string[],\n  ) => ValidateFields.IValidateFieldsResponse;\n}\n\n/* e.g:\n\nCorrect:\n  [\n    { id: 0, name: \"Jhon Doe\" },\n    { id: 1, name: \"Jhon Roe\" }\n  ]\n\nX Incorrect:\n  [\n    { 9001 : \"value\" }\n  ]\n*/\n```\n\n## **validateFields**\n\nThis function validates if the serialized content has the specified fields.\n\n**Parameters**\n\n**csvContent**: The raw content of a CSV file.\n\n```typescript\ninterface IParams {\n  expectedColumns: string[];\n  data: Array<{\n    [key: string]: string | number;\n  }>;\n}\n```\n\n**Return type**\n\nThis function returns an object with the serialized CSV as the following:\n\n```typescript\ninterface IResponse {\n  isValid: boolean;\n  error: Error | null;\n  data: Array<{\n    [key: string]: string | number;\n  }>;\n}\n```\n\n<!-- # How to run -->\n\n## :memo: License\n\nThis project is under license MIT. See the file [LICENSE](LICENSE) for more details.\n","readmeFilename":"README.md"}