mirror of
https://github.com/asadbek064/hyparquet-compressors.git
synced 2026-04-11 06:58:01 +00:00
Split out exports for more efficient packaging
This commit is contained in:
parent
800223441c
commit
29ee7f1178
@ -78,7 +78,7 @@ Uses [fzstd](https://github.com/101arrowz/fzstd) for Zstandard decompression.
|
||||
|
||||
| File | Size |
|
||||
| --- | --- |
|
||||
| hyparquet-compressors.min.js | 116.1kb |
|
||||
| hyparquet-compressors.min.js | 116.4kb |
|
||||
| hyparquet-compressors.min.js.gz | 75.2kb |
|
||||
|
||||
## References
|
||||
|
||||
@ -47,7 +47,7 @@ export default [
|
||||
'no-constant-condition': 'off',
|
||||
'no-extra-parens': 'error',
|
||||
'no-multi-spaces': 'error',
|
||||
'no-trailing-spaces': 'warn',
|
||||
'no-trailing-spaces': 'error',
|
||||
'no-undef': 'error',
|
||||
'no-unused-vars': 'error',
|
||||
'no-useless-concat': 'error',
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
"build": "rollup -c",
|
||||
"coverage": "vitest run --coverage",
|
||||
"lint": "eslint",
|
||||
"lint:fix": "eslint --fix",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@ -55,7 +55,7 @@ const maxDictionaryWordLength = 24
|
||||
* @param {number} outputLength
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function BROTLI(input, outputLength) {
|
||||
export function decompressBrotli(input, outputLength) {
|
||||
const output = new Uint8Array(outputLength)
|
||||
const brotliInput = new BrotliInput(input)
|
||||
const brotliOutput = new BrotliOutput(output)
|
||||
|
||||
15
src/compressors.js
Normal file
15
src/compressors.js
Normal file
@ -0,0 +1,15 @@
|
||||
import { decompress as decompressZstd } from 'fzstd'
|
||||
import { snappyUncompressor } from 'hysnappy'
|
||||
import { decompressBrotli } from './brotli.js'
|
||||
import { gunzip } from './gzip.js'
|
||||
import { decompressLz4, decompressLz4Raw } from './lz4.js'
|
||||
|
||||
/** @type {import('hyparquet').Compressors} */
|
||||
export const compressors = {
|
||||
SNAPPY: snappyUncompressor(), // loads wasm
|
||||
GZIP: (input, length) => gunzip(input, new Uint8Array(length)),
|
||||
BROTLI: decompressBrotli,
|
||||
ZSTD: input => decompressZstd(input),
|
||||
LZ4: decompressLz4,
|
||||
LZ4_RAW: decompressLz4Raw,
|
||||
}
|
||||
8
src/index.d.ts
vendored
8
src/index.d.ts
vendored
@ -13,3 +13,11 @@ export type Compressors = {
|
||||
}
|
||||
|
||||
export const compressors: Compressors
|
||||
|
||||
export function decompressBrotli(input: Uint8Array, outputLength: number): Uint8Array
|
||||
export function decompressGzip(input: Uint8Array, outputLength: number): Uint8Array
|
||||
export function decompressLz4(input: Uint8Array, outputLength: number): Uint8Array
|
||||
export function decompressLz4Raw(input: Uint8Array, outputLength: number): Uint8Array
|
||||
export function decompressSnappy(input: Uint8Array, outputLength: number): Uint8Array
|
||||
export function decompressZstd(input: Uint8Array, outputLength: number): Uint8Array
|
||||
export function gunzip(input: Uint8Array, output?: Uint8Array): Uint8Array
|
||||
|
||||
37
src/index.js
37
src/index.js
@ -1,21 +1,26 @@
|
||||
import { decompress as ZSTD } from 'fzstd'
|
||||
import { snappyUncompressor } from 'hysnappy'
|
||||
import { BROTLI } from './brotli.js'
|
||||
import { decompress as decompressZstd } from 'fzstd'
|
||||
import { snappyUncompress as decompressSnappy } from 'hysnappy'
|
||||
import { decompressBrotli } from './brotli.js'
|
||||
import { gunzip } from './gzip.js'
|
||||
import { LZ4, LZ4_RAW } from './lz4.js'
|
||||
import { decompressLz4, decompressLz4Raw } from './lz4.js'
|
||||
|
||||
export { compressors } from './compressors.js'
|
||||
|
||||
/**
|
||||
* @type {import('hyparquet').Compressors}
|
||||
* @param {Uint8Array} input
|
||||
* @param {number} outputLength
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export const compressors = {
|
||||
SNAPPY: snappyUncompressor(),
|
||||
GZIP: (input, length) => {
|
||||
const out = new Uint8Array(length)
|
||||
gunzip(input, out)
|
||||
return out
|
||||
},
|
||||
BROTLI,
|
||||
ZSTD: input => ZSTD(input),
|
||||
LZ4,
|
||||
LZ4_RAW,
|
||||
function decompressGzip(input, outputLength) {
|
||||
return gunzip(input, new Uint8Array(outputLength))
|
||||
}
|
||||
|
||||
export {
|
||||
decompressBrotli,
|
||||
decompressGzip,
|
||||
decompressLz4,
|
||||
decompressLz4Raw,
|
||||
decompressSnappy,
|
||||
decompressZstd,
|
||||
gunzip,
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* @param {number} outputLength
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function LZ4(input, outputLength) {
|
||||
export function decompressLz4(input, outputLength) {
|
||||
const output = new Uint8Array(outputLength)
|
||||
try {
|
||||
let i = 0 // input index
|
||||
@ -41,7 +41,7 @@ export function LZ4(input, outputLength) {
|
||||
* @param {number} outputLength
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function LZ4_RAW(input, outputLength) {
|
||||
export function decompressLz4Raw(input, outputLength) {
|
||||
const output = new Uint8Array(outputLength)
|
||||
lz4basic(input, output, 0)
|
||||
return output
|
||||
|
||||
Loading…
Reference in New Issue
Block a user