Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
The iltorb npm package is a Node.js binding for the Brotli compression algorithm, which is known for its high compression ratio and speed. It allows you to compress and decompress data using Brotli, making it useful for web applications, file storage, and data transfer.
Compression
This feature allows you to compress data using the Brotli algorithm. The code sample demonstrates how to compress a file named 'input.txt' and save the compressed output to 'output.txt.br'.
const iltorb = require('iltorb');
const fs = require('fs');
const input = fs.createReadStream('input.txt');
const output = fs.createWriteStream('output.txt.br');
input.pipe(iltorb.compressStream()).pipe(output);
Decompression
This feature allows you to decompress Brotli-compressed data. The code sample shows how to decompress a file named 'output.txt.br' and save the decompressed output to 'decompressed.txt'.
const iltorb = require('iltorb');
const fs = require('fs');
const input = fs.createReadStream('output.txt.br');
const output = fs.createWriteStream('decompressed.txt');
input.pipe(iltorb.decompressStream()).pipe(output);
Synchronous Compression
This feature provides a synchronous method to compress data. The code sample demonstrates how to read a file synchronously, compress its contents, and write the compressed data to a new file.
const iltorb = require('iltorb');
const fs = require('fs');
const input = fs.readFileSync('input.txt');
const compressed = iltorb.compressSync(input);
fs.writeFileSync('output.txt.br', compressed);
Synchronous Decompression
This feature provides a synchronous method to decompress data. The code sample shows how to read a compressed file synchronously, decompress its contents, and write the decompressed data to a new file.
const iltorb = require('iltorb');
const fs = require('fs');
const compressed = fs.readFileSync('output.txt.br');
const decompressed = iltorb.decompressSync(compressed);
fs.writeFileSync('decompressed.txt', decompressed);
The 'brotli' npm package is another implementation of the Brotli compression algorithm for Node.js. It provides similar functionality to iltorb, including both compression and decompression capabilities. However, 'brotli' is a pure JavaScript implementation, which might be slower compared to iltorb's native bindings.
The 'node-zopfli' package provides bindings for the Zopfli compression algorithm, which is known for its high compression ratio, similar to Brotli. While it offers similar compression and decompression functionalities, Zopfli is generally slower than Brotli but can achieve slightly better compression ratios.
The 'pako' package is a fast zlib port to JavaScript, providing compression and decompression using the DEFLATE algorithm. While it does not use Brotli, it offers similar functionalities for compressing and decompressing data, making it a good alternative for applications that do not specifically require Brotli.
iltorb is a Node.js package offering native bindings for the brotli compression library.
This module uses prebuild
to download a pre-compiled binary for your platform, if it exists. Otherwise, it will use node-gyp
to build the module.
npm install iltorb
The following is required to build from source or when a pre-compiled binary does not exist.
Omitting the callback argument will result in the compress and decompress methods to return a Promise.
const compress = require('iltorb').compress;
// callback style
compress(input, function(err, output) {
// ...
});
// promise style
compress(input)
.then(output => /* ... */)
.catch(err => /* ... */);
// async/await style
try {
const output = await compress(input);
} catch(err) {
// ...
}
const decompress = require('iltorb').decompress;
// callback style
decompress(input, function(err, output) {
// ...
});
// promise style
decompress(input)
.then(output => /* ... */)
.catch(err => /* ... */);
// async/await style
try {
const output = await decompress(input);
} catch(err) {
// ...
}
const compressSync = require('iltorb').compressSync;
try {
var output = compressSync(input);
} catch(err) {
// ...
}
const decompressSync = require('iltorb').decompressSync;
try {
var output = decompressSync(input);
} catch(err) {
// ...
}
const compressStream = require('iltorb').compressStream;
const fs = require('fs');
fs.createReadStream('path/to/input')
.pipe(compressStream())
.pipe(fs.createWriteStream('path/to/output'));
Call this method to flush pending data. Don't call this frivolously, premature flushes negatively impact the effectiveness of the compression algorithm.
const decompressStream = require('iltorb').decompressStream;
const fs = require('fs');
fs.createReadStream('path/to/input')
.pipe(decompressStream())
.pipe(fs.createWriteStream('path/to/output'));
The compress
, compressSync
and compressStream
methods may accept an optional brotliEncodeParams
object to define some or all of brotli's compression parameters:
const brotliEncodeParams = {
mode: 0,
quality: 11,
lgwin: 22,
lgblock: 0,
disable_literal_context_modeling: false,
size_hint: 0, // automatically set for `compress` and `compressSync`
large_window: false,
npostfix: 0,
ndirect: 0
};
I am unable to install iltorb
because the host (GitHub) that serves the binaries is blocked by my firewall.
a) By default, if the binaries could not be downloaded for any reason, the install script will attempt to compile the binaries locally on your machine. This requires having all of the build requirements fulfilled.
b) You can override the binary.host
value found in package.json
with the following methods:
npm_config_iltorb_binary_host=https://domain.tld/path
--iltorb_binary_host=https://domain.tld/path
Note: Both of these would result in downloading the binary from https://domain.tld/path/vX.X.X/iltorb-vX.X.X-node-vXX-arch.tar.gz
FAQs
Brotli compression/decompression with native bindings
We found that iltorb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.