aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorEugene Kliuchnikov <eustas.ru@gmail.com>2021-07-29 22:29:43 +0200
committerGitHub <noreply@github.com>2021-07-29 22:29:43 +0200
commit630b5084ee255549d25d6da7ec50b7a53861d95a (patch)
tree37df125945ae7eb37ae90db285de7cb9a5f2ee74 /js
parentce222e317e36aa362e83fc50c7a6226d238e03fd (diff)
downloadbrotli-630b5084ee255549d25d6da7ec50b7a53861d95a.zip
brotli-630b5084ee255549d25d6da7ec50b7a53861d95a.tar.gz
brotli-630b5084ee255549d25d6da7ec50b7a53861d95a.tar.bz2
Update (#914)
* slimmer stack frames in encoder * fix MSAN problem in hasher_composite (not dangerous, only in large_window mode) * fix JNI decoder wrapper - power-of-two payloads fail to decode sometimes * reformat polyfil.js and decode_test.js
Diffstat (limited to 'js')
-rw-r--r--js/decode_test.js19
-rw-r--r--js/polyfill.js27
2 files changed, 24 insertions, 22 deletions
diff --git a/js/decode_test.js b/js/decode_test.js
index cd1cbcf..bbeb541 100644
--- a/js/decode_test.js
+++ b/js/decode_test.js
@@ -20,22 +20,25 @@ function bytesToString(bytes) {
* @return {!Int8Array}
*/
function stringToBytes(str) {
- var out = new Int8Array(str.length);
- for (var i = 0; i < str.length; ++i) out[i] = str.charCodeAt(i);
+ let out = new Int8Array(str.length);
+ for (let i = 0; i < str.length; ++i) out[i] = str.charCodeAt(i);
return out;
}
testSuite({
testMetadata() {
- assertEquals("", bytesToString(BrotliDecode(Int8Array.from([1, 11, 0, 42, 3]))));
+ assertEquals(
+ '', bytesToString(BrotliDecode(Int8Array.from([1, 11, 0, 42, 3]))));
},
testCompoundDictionary() {
- var txt = "kot lomom kolol slona\n";
- var dictionary = stringToBytes(txt);
- var compressed = [0xa1, 0xa8, 0x00, 0xc0, 0x2f, 0x01, 0x10, 0xc4, 0x44, 0x09, 0x00];
+ const txt = 'kot lomom kolol slona\n';
+ const dictionary = stringToBytes(txt);
+ const compressed =
+ [0xa1, 0xa8, 0x00, 0xc0, 0x2f, 0x01, 0x10, 0xc4, 0x44, 0x09, 0x00];
assertEquals(txt.length, compressed.length * 2);
- var options = {"customDictionary": dictionary};
- assertEquals(txt, bytesToString(BrotliDecode(Int8Array.from(compressed), options)));
+ const options = {'customDictionary': dictionary};
+ assertEquals(
+ txt, bytesToString(BrotliDecode(Int8Array.from(compressed), options)));
}
});
diff --git a/js/polyfill.js b/js/polyfill.js
index 069b1bc..9ff59cc 100644
--- a/js/polyfill.js
+++ b/js/polyfill.js
@@ -5,8 +5,8 @@ if (!Int32Array.__proto__.from) {
if (!obj['length']) {
return new this(0);
}
- var typed_array = new this(obj.length);
- for(var i = 0; i < typed_array.length; i++) {
+ let typed_array = new this(obj.length);
+ for (let i = 0; i < typed_array.length; i++) {
typed_array[i] = obj[i];
}
return typed_array;
@@ -16,12 +16,12 @@ if (!Int32Array.__proto__.from) {
if (!Array.prototype.copyWithin) {
Array.prototype.copyWithin = function(target, start, end) {
- var O = Object(this);
- var len = O.length >>> 0;
- var to = target | 0;
- var from = start | 0;
- var count = Math.min(Math.min(end | 0, len) - from, len - to);
- var direction = 1;
+ let O = Object(this);
+ let len = O.length >>> 0;
+ let to = target | 0;
+ let from = start | 0;
+ let count = Math.min(Math.min(end | 0, len) - from, len - to);
+ let direction = 1;
if (from < to && to < (from + count)) {
direction = -1;
from += count - 1;
@@ -41,8 +41,8 @@ if (!Array.prototype.fill) {
Object.defineProperty(Array.prototype, 'fill', {
value: function(value, start, end) {
end = end | 0;
- var O = Object(this);
- var k = start | 0;
+ let O = Object(this);
+ let k = start | 0;
while (k < end) {
O[k] = value;
k++;
@@ -66,9 +66,8 @@ if (!Int32Array.prototype.fill) {
if (!Int8Array.prototype.slice) {
Object.defineProperty(Int8Array.prototype, 'slice', {
- value: function (begin, end)
- {
- return new Int8Array(Array.prototype.slice.call(this, begin, end));
- }
+ value: function(begin, end) {
+ return new Int8Array(Array.prototype.slice.call(this, begin, end));
+ }
});
}