{"version":3,"sources":["jsdelivr-header.js","/npm/csv_splitter@1.0.0/app/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;ACYA,IAAI,IAAS,QAAQ,YACjB,OAAS,QAAQ,UACjB,GAAS,QAAQ,MA0CrB,SAAS,YACP,QAAQ,IAAI,4BAA4B,OACxC,QAAQ,IAAI,OAAS,OAAO,IAAI,QAAQ,KAAK,KAE7C,QAAQ,IAAI,8BAA8B,OAC1C,QAAQ,IAAI,OAAS,OAAO,IAAI,QAAQ,KAAK,IAC/C,CAOA,SAAS,aAAa,GACP,GAAV,GACD,QAAQ,IAAI,OAAO,IAAI,uDACvB,QAAQ,IAAI,OAAO,IAAI,oDACJ,GAAV,GACT,QAAQ,IAAI,OAAO,IAAI,2DAE3B,EA5DC,WACC,IAAI,EAAc,EACd,EAAc,GACd,EAAc,EAEQ,GAAvB,QAAQ,KAAK,QAKhB,YAEA,QAAQ,IAAI,oBAAoB,QAEhC,IAAI,SAAS,QAAQ,KAAK,IAAI,GAAG,QAAQ,SAAS,GAChD,IACA,EAAU,GAAe,EAEzB,QAAQ,IAAI,cAAW,OAAS,GAC7B,EAAc,SAAS,QAAQ,KAAK,KAAO,EAK9C,IAAI,YAAY,QAAQ,MAAO,aAAc,EAAa,OAAQ,EAAW,CACzE,SAAS,IAEX,GAAG,UAAU,WACX,QAAQ,IAAI,6BAA8B,EAAa,OAC1D,IATC,GAUJ,IACC,GAAG,OAAO,WACT,QAAQ,IAAI,kBAAkB,QAChC,KA3BI,aAAa,EA4BnB,CAlCA","file":"/npm/csv_splitter@1.0.0/app/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/csv_splitter@1.0.0/app/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#!/usr/bin/env node\n\n/**\n* Node CLI to split your CSV files.\n*\n* --------------------------------\n* How to use it ?\n* Open the Terminal, go to the folder in which you want to have your\n* new CSV files splitted. And put this:\n*\n*     $ csv-splitter <path-to-file> <lines-plitter>\n* @param path-to-file {string} Will represent the path to your csv file.\n* @param lines-splitter {integer} Will split every the file every number of line specified.\n*\n* For bugs or reports:\n* - maximeesilv (github)\n* - Don't forget to create issues.\n*/\nvar csv    = require('fast-csv'),\n    colors = require('colors'),\n    fs     = require('fs');\n\n(function() {\n  var pageCounter = 0,\n      dataArray   = [],\n      dataCounter = 0;\n\n  if(process.argv.length != 4) {\n      displayError(1);\n      return;\n  }\n\n  robotTalk();\n\n  console.log(\"\\t Data in file: \".yellow);\n\n  csv.fromPath(process.argv[2]).on(\"data\", function(data) {\n    dataCounter++;\n    dataArray[dataCounter] = data;\n\n    console.log(\"\\t ---> \".yellow + data);\n    if(dataCounter % parseInt(process.argv[3]) == 0) {\n      pageCounter++;\n      return;\n    }\n\n    csv.writeToPath(process.cwd()+ \"/NewSubCSV\"+ pageCounter +\".csv\", dataArray, {\n        headers: true\n      })\n     .on(\"finish\", function() {\n        console.log(\"Data written in: NewSubCSV\"+ pageCounter +\".csv\");\n     });\n  })\n  .on(\"end\", function() {\n    console.log(\"Writing data...\".magenta);\n  });\n}());\n\n/**\n*\n*\n*/\nfunction robotTalk() {\n  console.log(\"CSV SPLITTER: file path :\".green);\n  console.log(\" -> \" + colors.red(process.argv[2]));\n\n  console.log(\"CSV SPLITTER: split every :\".green);\n  console.log(\" -> \" + colors.red(process.argv[3]));\n}\n\n/**\n*\n*\n*\n*/\nfunction displayError(number) {\n  if(number == 1) {\n    console.log(colors.red(\"Error, the number of argument is wrong. Must be 2.\"));\n    console.log(colors.red(\"Check this: csv-splitter <path> <numberOfLine>\"));\n  } else if (number == 2) {\n    console.log(colors.red(\"Error, Please provide a number for the parameter lines.\"));\n  }\n}\n"]}