Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add fromArrayBufferToBuffer util
- Loading branch information
1 parent
e515f5f
commit 754163a
Showing
2 changed files
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { promisify } from 'node:util' | ||
import { getConfig } from './config.js' | ||
import {fromArrayBufferToBuffer} from "./util.js"; | ||
|
||
export const gzip = async(...args) => | ||
promisify((await import(getConfig()?.zlib || 'node:zlib')).gzip)(...args).then(Buffer.from) | ||
export const gzip = async(buf) => | ||
promisify((await import(getConfig()?.zlib || 'node:zlib')).gzip)(new Uint8Array(buf)).then(fromArrayBufferToBuffer) | ||
|
||
export const gunzip = async(...args) => | ||
promisify((await import(getConfig()?.zlib || 'node:zlib')).gunzip)(...args).then(Buffer.from) | ||
export const gunzip = async(buf) => | ||
promisify((await import(getConfig()?.zlib || 'node:zlib')).gunzip)(new Uint8Array(buf)).then(fromArrayBufferToBuffer) |