Skip to content

Commit 34df32c

Browse files
committedOct 7, 2017
Fix encoding issue in buffer
1 parent 6099161 commit 34df32c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed
 

‎libs/core/Converter.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ function emitDone(conv) {
8989

9090

9191
function bufFromString(str) {
92+
var length=Buffer.byteLength(str);
9293
var buffer = Buffer.allocUnsafe
93-
? Buffer.allocUnsafe(str.length)
94-
: new Buffer(str.length);
94+
? Buffer.allocUnsafe(length)
95+
: new Buffer(length);
9596
buffer.write(str);
9697
return buffer;
9798
}
@@ -530,7 +531,9 @@ Converter.prototype.transf = function (func) {
530531

531532
Converter.prototype.fromString = function (csvString, cb) {
532533
if (typeof csvString !== "string") {
533-
return cb(new Error("Passed CSV Data is not a string."));
534+
if (cb && typeof cb ==="function"){
535+
return cb(new Error("Passed CSV Data is not a string."));
536+
}
534537
}
535538
if (cb && typeof cb === "function") {
536539
this.wrapCallback(cb, function () {

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
"hireable": null
245245
}
246246
],
247-
"version": "1.1.8",
247+
"version": "1.1.9",
248248
"keywords": [
249249
"csv",
250250
"csv parser",

0 commit comments

Comments
 (0)
Failed to load comments.