brunobar79 / J-I-C

J I C is a Javascript Image Compressor using HTML5 Canvas & File API that allows you to compress your jpeg & png images before uploading to the server (100% client-side and no extra libraries required!)
http://makeitsolutions.com/labs/jic/
MIT License
857 stars 196 forks source link

Code refactor and send() change #58

Closed Walt-H closed 4 years ago

Walt-H commented 6 years ago

Hey guys!

The true difference in the code is this specific block:

// ADD polyfill for sendAsBinary, since it is a non-standard, deprecated function
        if (XMLHttpRequest.prototype.sendAsBinary === undefined) {
            XMLHttpRequest.prototype.sendAsBinary = function (string) {
                var bytes = Array.prototype.map.call(string, function (c) {
                    return c.charCodeAt(0) & 0xff;
                });

                // send ArrayBufferView to suppress Chrome warning message
                this.send(new Uint8Array(bytes));
            };
        }

We went from this.send(new Uint8Array(bytes.buffer)); to this.send(new Uint8Array(bytes)); in order to take care of a Chrome warning.

Lastly, I just reformatted the code using WebStorm to pretty it up :)

Thank you so much for the excellent library!

Walt-H commented 6 years ago

I just realized how messy that diff file was.

Would you like me to break this into two separate commits?