New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ts-zstd

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-zstd

TypeScript functions for reading/writing from ZStandard compressed files

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

TypeScript zstd

TypeScript functions for reading/writing Zstd compressed files. Includes Zstd binaries for Linux, Windows, and Mac OSX.

Compression

The compress function takes a path to an input and output file destination. The optional third parameter specifies the compression level, between 1 and 22.

import { compress } from 'ts-zstd'

async function main() {
	await compress('/path/to/input.zstd', '/path/to/output')
	await compress('/path/to/input.zstd', '/path/to/output', 20)
}

Decompression

The decompress, streamDecompress, and decompressToStream functions provide the option to decompress an entire file into a target directory, or stream the contents of the compressed file in memory for processing.

import { decompress, streamDecompress } from 'ts-zstd'

async function main() {
	await decompress('/path/to/input.zstd', '/path/to/output')

	// Read the input
	const stream = await streamDecompress('/path/to/input.zstd')
	stream.on('data', (data: Buffer) => {
		console.log(data.toString())
	})
	stream.on('error', (error) => {
		console.error(error)
	})
	stream.on('end', () => {
		console.log('Done reading compressed file')
	})
}

Author

Keshav Saharia created this for reading Lichess PGN files.

Keywords

zstandard

FAQs

Package last updated on 17 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts