B2G/gecko/image/test/unit/test_imgtools.js
/*
 * streamToArray()
 *
 * Consumes an input stream, and returns its bytes as an array.
 */
streamToArray()
Consumes an input stream, and returns its bytes as an array.
streamToArray () Consumes an input stream and returns its bytes as an array .
function streamToArray(aStream) {
    var size = aStream.available();
    var bis = Cc["@mozilla.org/binaryinputstream;1"].
              createInstance(Ci.nsIBinaryInputStream);
    bis.setInputStream(aStream);
    var bytes = bis.readByteArray(size);
    if (size != bytes.length)
        throw "Didn't read expected number of bytes";
    return bytes;
}
function streamToArray ( aStream ) { var size = aStream . available ( ) ; var bis = Cc [ "@mozilla.org/binaryinputstream;1" ] . createInstance ( Ci . nsIBinaryInputStream ) ; bis . setInputStream ( aStream ) ; var bytes = bis . readByteArray ( size ) ; if ( size != bytes . length ) throw "Didn't read expected number of bytes" ; return bytes ; }
streamToArray()
 Consumes an input stream, and returns its bytes as an array.
streamToArray () Consumes an input stream and returns its bytes as an array .
// use a binary input stream to grab the bytes.