woff2-decode 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/brotli.d.ts +2 -1
- package/dist/brotli.d.ts.map +1 -1
- package/dist/buffer.d.ts +1 -0
- package/dist/buffer.d.ts.map +1 -1
- package/dist/decode.d.ts +1 -1
- package/dist/decode.d.ts.map +1 -1
- package/dist/index.browser.js +4248 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.cjs +321 -287
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +321 -287
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +4253 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,25 +17,25 @@ npm install woff2-decode
|
|
|
17
17
|
import { decode } from 'woff2-decode'
|
|
18
18
|
|
|
19
19
|
const woff2Data = await fetch('/font.woff2').then(r => r.arrayBuffer())
|
|
20
|
-
const ttfData = decode(woff2Data)
|
|
20
|
+
const ttfData = await decode(woff2Data)
|
|
21
21
|
|
|
22
22
|
// ttfData is a Uint8Array containing the decoded TTF/OTF
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Performance
|
|
26
26
|
|
|
27
|
-
Benchmarks on an
|
|
27
|
+
Benchmarks on an M2 Max, Node 22. Native Brotli is used in Node (via zlib) and browsers that support `DecompressionStream('brotli')` (Firefox 113+, Safari 16.4+). Chrome falls back to pure JS
|
|
28
28
|
|
|
29
29
|
| File | Size | Native | Pure JS |
|
|
30
30
|
|------|------|--------|---------|
|
|
31
|
-
| enc-otf.woff2 | 107 KB | 1.
|
|
32
|
-
| enc-ttf.woff2 | 98 KB | 4
|
|
33
|
-
| enc-var-ttf.woff2 | 318 KB |
|
|
31
|
+
| enc-otf.woff2 (CFF) | 107 KB | 1.6 ms | 5.3 ms |
|
|
32
|
+
| enc-ttf.woff2 | 98 KB | 2.4 ms | 5.5 ms |
|
|
33
|
+
| enc-var-ttf.woff2 | 318 KB | 5.2 ms | 14.4 ms |
|
|
34
34
|
|
|
35
35
|
## API
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
|
-
function decode(data: ArrayBuffer | Uint8Array): Uint8Array
|
|
38
|
+
function decode(data: ArrayBuffer | Uint8Array): Promise<Uint8Array>
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
MIT, maintained by [@jpt](https://github.com/jpt)
|
|
41
|
+
MIT, maintained by [@jpt](https://github.com/jpt)
|
package/dist/brotli.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export declare function decompress(data: Uint8Array): Uint8Array
|
|
1
|
+
export declare function decompress(data: Uint8Array): Promise<Uint8Array>;
|
|
2
2
|
export declare function decompressNative(data: Uint8Array): Uint8Array;
|
|
3
3
|
export declare function decompressPure(data: Uint8Array): Uint8Array;
|
|
4
4
|
export declare const hasNative: boolean;
|
|
5
|
+
export declare const hasBrowserNative: boolean;
|
|
5
6
|
//# sourceMappingURL=brotli.d.ts.map
|
package/dist/brotli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brotli.d.ts","sourceRoot":"","sources":["../src/brotli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"brotli.d.ts","sourceRoot":"","sources":["../src/brotli.ts"],"names":[],"mappings":"AAwDA,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAQtE;AAGD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAK7D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAE3D;AAED,eAAO,MAAM,SAAS,SAAwB,CAAC;AAC/C,eAAO,MAAM,gBAAgB,SAAyB,CAAC"}
|
package/dist/buffer.d.ts
CHANGED
package/dist/buffer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AACA,qBAAa,MAAM;IACjB,OAAO,CAAC,IAAI,CAAW;IACvB,OAAO,CAAC,GAAG,CAAa;gBAEZ,IAAI,EAAE,WAAW,GAAG,UAAU,EAAE,MAAM,GAAE,MAAU,EAAE,MAAM,CAAC,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AACA,qBAAa,MAAM;IACjB,OAAO,CAAC,IAAI,CAAW;IACvB,OAAO,CAAC,EAAE,CAAa;IACvB,OAAO,CAAC,GAAG,CAAa;gBAEZ,IAAI,EAAE,WAAW,GAAG,UAAU,EAAE,MAAM,GAAE,MAAU,EAAE,MAAM,CAAC,EAAE,MAAM;IAY/E,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,MAAM,IAAI,QAAQ,CAErB;IAED,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAQxB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAQ7B,MAAM,IAAI,MAAM,GAAG,IAAI;IAKvB,OAAO,IAAI,MAAM,GAAG,IAAI;IAOxB,OAAO,IAAI,MAAM,GAAG,IAAI;IAQxB,OAAO,IAAI,MAAM,GAAG,IAAI;IAWxB,OAAO,IAAI,MAAM,GAAG,IAAI;IAYxB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAOvC,MAAM,CAAC,MAAM,GAAE,MAAU,GAAG,MAAM,GAAG,IAAI;IAMzC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;CAM5D"}
|
package/dist/decode.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface DecodeOptions {
|
|
2
2
|
forcePureBrotli?: boolean;
|
|
3
3
|
}
|
|
4
|
-
export declare function decode(data: ArrayBuffer | Uint8Array, options?: DecodeOptions): Uint8Array
|
|
4
|
+
export declare function decode(data: ArrayBuffer | Uint8Array, options?: DecodeOptions): Promise<Uint8Array>;
|
|
5
5
|
//# sourceMappingURL=decode.d.ts.map
|
package/dist/decode.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../src/decode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../src/decode.ts"],"names":[],"mappings":"AAmEA,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAGD,wBAAsB,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CA8DzG"}
|