Skip to content

Commit cf1ef99

Browse files
committed
prepare beta4
1 parent d8d68a9 commit cf1ef99

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This library is packaged as a UMD module, hence you can use it directly
2727
from JavaScript within a browser. To do so, you can simply include HdrHistogramJS file from github's release page:
2828

2929
```
30-
<script src="https://github.com/HdrHistogram/HdrHistogramJS/releases/download/v2.0.0/hdrhistogram.min.js"></script>
30+
<script src="https://github.com/HdrHistogram/HdrHistogramJS/releases/download/v2.0.0-beta4/hdrhistogram.umd.js"></script>
3131
```
3232

3333
Then you will have access to classes and functions of the APIs using "hdr" prefix.

src/JsHistogram.encoding.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,19 @@ function findDeflateFunction() {
141141
try {
142142
return eval('require("zlib").deflateSync');
143143
} catch (error) {
144-
return pako.deflate;
144+
return !!pako ? pako.deflate : () => { throw new Error('pako library is mandatory for encoding/deconding on the browser side') };
145145
}
146146
}
147147
function findInflateFunction() {
148148
try {
149149
return eval('require("zlib").inflateSync');
150150
} catch (error) {
151-
return pako.inflate;
151+
return !!pako ? pako.inflate : () => { throw new Error('pako library is mandatory for encoding/deconding on the browser side') };
152152
}
153153
}
154154

155-
const deflate = findDeflateFunction();
156-
const inflate = findInflateFunction();
155+
export const deflate = findDeflateFunction();
156+
export const inflate = findInflateFunction();
157157

158158
export function decompress(data: Uint8Array): Uint8Array {
159159
const buffer = new ByteBuffer(data);

src/encoding.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,18 @@
55
* and released to the public domain, as explained at
66
* http://creativecommons.org/publicdomain/zero/1.0/
77
*/
8-
import "./JsHistogram.encoding";
98
import { JsHistogram } from "./JsHistogram";
109
import ByteBuffer from "./ByteBuffer";
1110
import Histogram from "./Histogram";
1211
import { WasmHistogram } from "./wasm";
1312

1413
// @ts-ignore
1514
import * as base64 from "base64-js";
16-
// @ts-ignore
17-
import * as pako from "pako";
15+
import { inflate, deflate } from "./JsHistogram.encoding";
1816

1917
const V2CompressedEncodingCookieBase = 0x1c849304;
2018
const compressedEncodingCookie = V2CompressedEncodingCookieBase | 0x10; // LSBit of wordsize byte indicates TLZE Encoding
2119

22-
function findDeflateFunction() {
23-
try {
24-
return eval('require("zlib").deflateSync');
25-
} catch (error) {
26-
return pako.deflate;
27-
}
28-
}
29-
function findInflateFunction() {
30-
try {
31-
return eval('require("zlib").inflateSync');
32-
} catch (error) {
33-
return pako.inflate;
34-
}
35-
}
36-
37-
const deflate = findDeflateFunction();
38-
const inflate = findInflateFunction();
39-
4020
export function decompress(data: Uint8Array): Uint8Array {
4121
const buffer = new ByteBuffer(data);
4222
const initialTargetPosition = buffer.position;

0 commit comments

Comments
 (0)