diff --git a/threads.js b/threads.js index 4147ac19..7405bd5b 100644 --- a/threads.js +++ b/threads.js @@ -2467,16 +2467,16 @@ Process.prototype.reportLetter = function (idx, string) { return ''; } var i = +(idx || 0), - str = (string || '').toString(); + str = isNil(string) ? '' : string.toString(); return str[i - 1] || ''; }; -Process.prototype.reportStringSize = function (string) { - if (string instanceof List) { // catch a common user error - return string.length(); +Process.prototype.reportStringSize = function (data) { + if (data instanceof List) { // catch a common user error + return data.length(); } - var str = (string || '').toString(); - return str.length; + + return isNil(data) ? 0 : data.toString().length; }; Process.prototype.reportUnicode = function (string) { @@ -2501,10 +2501,10 @@ Process.prototype.reportTextSplit = function (string, delimiter) { if (!contains(types, delType)) { throw new Error('expecting a text delimiter instead of a ' + delType); } - str = (string || '').toString(); + str = isNil(string) ? '' string.toString(); switch (this.inputOption(delimiter)) { case 'line': - // Unicode Compliant Line Splitting (Platform independent) + // Unicode compliant line splitting (platform independent) // http://www.unicode.org/reports/tr18/#Line_Boundaries del = /\r\n|[\n\v\f\r\x85\u2028\u2029]/; break; @@ -2522,7 +2522,7 @@ Process.prototype.reportTextSplit = function (string, delimiter) { del = ''; break; default: - del = (delimiter || '').toString(); + del = isNil(delimiter) ? '' : delimiter.toString(); } return new List(str.split(del)); };