text-encode
Advanced tools
+4
| var TextEncode = require('.') | ||
| new TextEncode().readTextAsync('D:/svn.txt', function(err, text){ | ||
| console.log(text) | ||
| }); |
+2
-2
| { | ||
| "name": "text-encode", | ||
| "version": "1.0.2", | ||
| "version": "1.0.3", | ||
| "description": "自动识别文本文件的编码及BOM处理,读取实际文件内容,并支持以相同格式保存回去", | ||
| "main": "textEncode.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| "test": "node test.js" | ||
| }, | ||
@@ -9,0 +9,0 @@ "repository": { |
+12
-2
@@ -17,6 +17,14 @@ var iconv = require('iconv-lite'); | ||
| }, | ||
| readTextAsync: function (fileName, cb) { | ||
| var it = this; | ||
| fs.readFile(fileName, function (err, bytes) { | ||
| cb(err, it.readBytes(bytes)) | ||
| }); | ||
| }, | ||
| readText: function (fileName) { | ||
| var bytes = fs.readFileSync(fileName); | ||
| return this.readBytes(bytes); | ||
| }, | ||
| readBytes: function (bytes) { | ||
| var encoding = null; | ||
| var bytes = fs.readFileSync(fileName); | ||
| var bomLen = 0; | ||
@@ -112,1 +120,3 @@ if (bytes.length > 1) { | ||
| } | ||
| module.exports = TextEncode |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
4971
8.25%4
33.33%115
12.75%0
-100%