🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

csv2file

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv2file - npm Package Compare versions

Comparing version
1.0.3
to
1.0.4
+1
-1
package.json

@@ -5,3 +5,3 @@ {

"author": "jinkwon.lee <uzmystic@gmail.com>",
"version": "1.0.3",
"version": "1.0.4",
"main": "src/index.js",

@@ -8,0 +8,0 @@ "files": [

@@ -40,3 +40,3 @@ # csv2file

```bash
csv2file -i ./example/example.csv -t ./example/template.sql
csv2file -i ./sample/sample.csv -t ./sample/sample.tmpl.sql
```

@@ -43,0 +43,0 @@

@@ -5,29 +5,32 @@ const mustache = require('mustache');

module.exports = async function csv2WTF(params, options) {
const opt = {
columns: true,
...options,
};
async function csv2file(params, options) {
return new Promise(async (resolve, reject) => {
const opt = {
columns: true,
...options,
};
try {
const input = await readFile(params.input);
const template = await readFile(params.template);
const outputStm = fs.createWriteStream(params.output);
try {
const input = await readFile(params.input);
const template = await readFile(params.template);
const outputStm = fs.createWriteStream(params.output);
const parser = parse(input, {
columns: opt.columns,
});
const parser = parse(input, {
columns: opt.columns,
});
parser.on('readable', function () {
while (1) {
const data = this.read();
if (!data) {
break;
parser.on('readable', function () {
while (1) {
const data = this.read();
if (!data) {
resolve();
break;
}
outputStm.write(render(template, data));
}
outputStm.write(render(template, data) + '\n');
}
});
} catch (err) {
throw err;
}
});
} catch (err) {
reject(err);
}
});
}

@@ -39,8 +42,6 @@

async function writeFile(path, data) {
return fs.writeFileSync(path, data)
}
function render(template, data) {
return mustache.render(template, data);
}
module.exports = csv2file;