Skip to content

Commit 29ee7f1

Browse files
committed
Split out exports for more efficient packaging
1 parent 8002234 commit 29ee7f1

File tree

8 files changed

+50
-21
lines changed

8 files changed

+50
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Uses [fzstd](https://github.com/101arrowz/fzstd) for Zstandard decompression.
7878

7979
| File | Size |
8080
| --- | --- |
81-
| hyparquet-compressors.min.js | 116.1kb |
81+
| hyparquet-compressors.min.js | 116.4kb |
8282
| hyparquet-compressors.min.js.gz | 75.2kb |
8383

8484
## References

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default [
4747
'no-constant-condition': 'off',
4848
'no-extra-parens': 'error',
4949
'no-multi-spaces': 'error',
50-
'no-trailing-spaces': 'warn',
50+
'no-trailing-spaces': 'error',
5151
'no-undef': 'error',
5252
'no-unused-vars': 'error',
5353
'no-useless-concat': 'error',

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"build": "rollup -c",
3232
"coverage": "vitest run --coverage",
3333
"lint": "eslint",
34+
"lint:fix": "eslint --fix",
3435
"test": "vitest run"
3536
},
3637
"dependencies": {

src/brotli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const maxDictionaryWordLength = 24
5555
* @param {number} outputLength
5656
* @returns {Uint8Array}
5757
*/
58-
export function BROTLI(input, outputLength) {
58+
export function decompressBrotli(input, outputLength) {
5959
const output = new Uint8Array(outputLength)
6060
const brotliInput = new BrotliInput(input)
6161
const brotliOutput = new BrotliOutput(output)

src/compressors.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { decompress as decompressZstd } from 'fzstd'
2+
import { snappyUncompressor } from 'hysnappy'
3+
import { decompressBrotli } from './brotli.js'
4+
import { gunzip } from './gzip.js'
5+
import { decompressLz4, decompressLz4Raw } from './lz4.js'
6+
7+
/** @type {import('hyparquet').Compressors} */
8+
export const compressors = {
9+
SNAPPY: snappyUncompressor(), // loads wasm
10+
GZIP: (input, length) => gunzip(input, new Uint8Array(length)),
11+
BROTLI: decompressBrotli,
12+
ZSTD: input => decompressZstd(input),
13+
LZ4: decompressLz4,
14+
LZ4_RAW: decompressLz4Raw,
15+
}

src/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ export type Compressors = {
1313
}
1414

1515
export const compressors: Compressors
16+
17+
export function decompressBrotli(input: Uint8Array, outputLength: number): Uint8Array
18+
export function decompressGzip(input: Uint8Array, outputLength: number): Uint8Array
19+
export function decompressLz4(input: Uint8Array, outputLength: number): Uint8Array
20+
export function decompressLz4Raw(input: Uint8Array, outputLength: number): Uint8Array
21+
export function decompressSnappy(input: Uint8Array, outputLength: number): Uint8Array
22+
export function decompressZstd(input: Uint8Array, outputLength: number): Uint8Array
23+
export function gunzip(input: Uint8Array, output?: Uint8Array): Uint8Array

src/index.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
import { decompress as ZSTD } from 'fzstd'
2-
import { snappyUncompressor } from 'hysnappy'
3-
import { BROTLI } from './brotli.js'
1+
import { decompress as decompressZstd } from 'fzstd'
2+
import { snappyUncompress as decompressSnappy } from 'hysnappy'
3+
import { decompressBrotli } from './brotli.js'
44
import { gunzip } from './gzip.js'
5-
import { LZ4, LZ4_RAW } from './lz4.js'
5+
import { decompressLz4, decompressLz4Raw } from './lz4.js'
6+
7+
export { compressors } from './compressors.js'
68

79
/**
8-
* @type {import('hyparquet').Compressors}
10+
* @param {Uint8Array} input
11+
* @param {number} outputLength
12+
* @returns {Uint8Array}
913
*/
10-
export const compressors = {
11-
SNAPPY: snappyUncompressor(),
12-
GZIP: (input, length) => {
13-
const out = new Uint8Array(length)
14-
gunzip(input, out)
15-
return out
16-
},
17-
BROTLI,
18-
ZSTD: input => ZSTD(input),
19-
LZ4,
20-
LZ4_RAW,
14+
function decompressGzip(input, outputLength) {
15+
return gunzip(input, new Uint8Array(outputLength))
16+
}
17+
18+
export {
19+
decompressBrotli,
20+
decompressGzip,
21+
decompressLz4,
22+
decompressLz4Raw,
23+
decompressSnappy,
24+
decompressZstd,
25+
gunzip,
2126
}

src/lz4.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @param {number} outputLength
77
* @returns {Uint8Array}
88
*/
9-
export function LZ4(input, outputLength) {
9+
export function decompressLz4(input, outputLength) {
1010
const output = new Uint8Array(outputLength)
1111
try {
1212
let i = 0 // input index
@@ -41,7 +41,7 @@ export function LZ4(input, outputLength) {
4141
* @param {number} outputLength
4242
* @returns {Uint8Array}
4343
*/
44-
export function LZ4_RAW(input, outputLength) {
44+
export function decompressLz4Raw(input, outputLength) {
4545
const output = new Uint8Array(outputLength)
4646
lz4basic(input, output, 0)
4747
return output

0 commit comments

Comments
 (0)