Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
work in modern browsers too
Browse files Browse the repository at this point in the history
  • Loading branch information
max-mapper committed Apr 9, 2012
1 parent 310d329 commit ce43382
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ exports.parse = function (path) {
stream.readable = true
stream.writable = true
stream.write = function (chunk) {
if('string' === typeof chunk)
chunk = new Buffer(chunk)
if('string' === typeof chunk) {
if ('undefined' === typeof Buffer) {
var buf = new Array(chunk.length)
for (var i = 0; i < chunk.length; i++) buf[i] = chunk.charCodeAt(i)
chunk = new Int32Array(buf)
} else {
chunk = new Buffer(chunk)
}
}
parser.write(chunk)
}
stream.end = function (data) {
Expand Down

0 comments on commit ce43382

Please sign in to comment.