echolist-csv2hpt
Advanced tools
Comparing version
28
api.js
var fs = require('fs'); | ||
var path = require('path'); | ||
var iconv = require('iconv-lite'); | ||
require('array.prototype.find'); | ||
require('iconv-lite').extendNodeEncodings(); | ||
var clog = console.log; | ||
@@ -12,3 +10,3 @@ | ||
try { | ||
return fs.readFileSync(filename, {encoding: encoding}); | ||
return iconv.decode( fs.readFileSync(filename), encoding ); | ||
} catch(err) { | ||
@@ -28,3 +26,3 @@ clog(''); | ||
try { | ||
fs.writeFileSync(filename, content, {encoding: encoding}); | ||
fs.writeFileSync(filename, iconv.encode(content, encoding)); | ||
} catch(err) { | ||
@@ -44,16 +42,14 @@ clog(''); | ||
return contentCSV.map(function(fileCSV){ | ||
var foundElement = fileCSV.find(function(elementCSV){ | ||
return elementCSV.lcEchotag === lcEchotag; | ||
}); | ||
var foundElement = fileCSV.find( | ||
elementCSV => elementCSV.lcEchotag === lcEchotag | ||
); | ||
if( typeof foundElement === 'undefined' ) return null; | ||
return foundElement; | ||
}).filter(function(nextElement){ | ||
return nextElement !== null; | ||
})[0]; | ||
}).filter( nextElement => nextElement !== null )[0]; | ||
}; | ||
module.exports = function(filenamesCSV, filenameHPT, options){ | ||
filenamesCSV = filenamesCSV.map(function(nextFilename){ | ||
return path.resolve(__dirname, nextFilename); | ||
}); | ||
filenamesCSV = filenamesCSV.map( | ||
nextFilename => path.resolve(__dirname, nextFilename) | ||
); | ||
filenameHPT = path.resolve(__dirname, filenameHPT); | ||
@@ -90,5 +86,3 @@ | ||
}; | ||
}).filter(function(nextLine){ | ||
return nextLine !== null; | ||
}); | ||
}).filter( nextLine => nextLine !== null ); | ||
}); | ||
@@ -95,0 +89,0 @@ |
@@ -6,3 +6,3 @@ { | ||
"preferGlobal": true, | ||
"version": "0.2.1", | ||
"version": "1.0.1", | ||
"description": "Copies Fidonet echomail area descriptions from a CSV echolist to an HPT areas file.", | ||
@@ -17,4 +17,3 @@ "keywords": ["Fidonet", "echomail", "echolist", "HPT", "area", "areas", "echoes"], | ||
"dependencies": { | ||
"array.prototype.find": "~1.0.0", | ||
"iconv-lite": "0.4.11" | ||
"iconv-lite": "~0.4.13" | ||
}, | ||
@@ -21,0 +20,0 @@ "scripts": { |
@@ -6,2 +6,4 @@ [](https://npmjs.org/package/echolist-csv2hpt) | ||
It requires [Node.js](http://nodejs.org/) to run and [npm](https://www.npmjs.org/) to be installed. | ||
* Starting from v1.0.0, this module requires Node.js version 4.0.0 or newer. | ||
* You may run older versions of this module in Node.js version 0.10.x or 0.12.x. These older versions, however, had to contain an additional dependency ([`array.prototype.find`](https://www.npmjs.com/package/array.prototype.find)) as a polyfill for a missing [ECMAScript 2015 (ES6) feature](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) which is now a part of Node.js. | ||
@@ -8,0 +10,0 @@ ## Installing echolist-csv2hpt |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
17428
2.12%1
-50%1
-50%52
4%269
-1.82%+ Added
+ Added
- Removed
- Removed
- Removed
Updated