-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
7 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,9 +89,10 @@ function emitDone(conv) { | |
|
||
|
||
function bufFromString(str) { | ||
var length=Buffer.byteLength(str); | ||
var buffer = Buffer.allocUnsafe | ||
? Buffer.allocUnsafe(str.length) | ||
: new Buffer(str.length); | ||
? Buffer.allocUnsafe(length) | ||
: new Buffer(length); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Keyang
Author
Owner
|
||
buffer.write(str); | ||
return buffer; | ||
} | ||
|
@@ -530,7 +531,9 @@ Converter.prototype.transf = function (func) { | |
|
||
Converter.prototype.fromString = function (csvString, cb) { | ||
if (typeof csvString !== "string") { | ||
return cb(new Error("Passed CSV Data is not a string.")); | ||
if (cb && typeof cb ==="function"){ | ||
return cb(new Error("Passed CSV Data is not a string.")); | ||
} | ||
} | ||
if (cb && typeof cb === "function") { | ||
this.wrapCallback(cb, function () { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,7 +244,7 @@ | |
"hireable": null | ||
} | ||
], | ||
"version": "1.1.8", | ||
"version": "1.1.9", | ||
"keywords": [ | ||
"csv", | ||
"csv parser", | ||
|
https://nodejs.org/docs/latest/api/buffer.html#buffer_class_method_buffer_from_string_encoding
That's a one-liner that's in Node since 5.10.0: