{"library":"seek-bzip","title":"Seekable Bzip2 Decoder","description":"seek-bzip is a pure-JavaScript Node.js module (version 2.0.0, last published over 6 years ago) designed for random-access decoding of bzip2 data. Its primary differentiator is the ability to seek to and decompress individual blocks within a bzip2 file, provided an external index. It mainly operates synchronously, decoding buffers into other buffers. While it offers experimental support for Node.js streams, this functionality relies on the `fibers` package, which is deprecated and largely incompatible with modern Node.js versions (v16+), severely limiting its utility in current environments. The package also includes a `seek-bzip-table` tool for generating the necessary block indices.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install seek-bzip"],"cli":null},"imports":["const Bunzip = require('seek-bzip');","const Bunzip = require('seek-bzip');\nconst decodedData = Bunzip.decode(compressedBuffer);","const Bunzip = require('seek-bzip');\nconst blockData = Bunzip.decodeBlock(compressedBuffer, 123456);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const Bunzip = require('seek-bzip');\nconst fs = require('fs');\nconst path = require('path');\n\n// IMPORTANT: This package decodes bzip2. To truly test, you would need\n// a valid `example.bz2` file created by a bzip2 compressor (e.g., `bzip2 -c original.txt > example.bz2`).\n// For demonstration, we'll create a dummy file, but Bunzip.decode will fail if it's not actual bzip2.\n\nconst dummyCompressedPath = path.join(__dirname, 'dummy_example.bz2');\nconst dummyOriginalData = Buffer.from('BZ2h1A&SY99999999999', 'ascii'); // Not actual bzip2 data\nfs.writeFileSync(dummyCompressedPath, dummyOriginalData);\n\nconst decompressedOutputPath = path.join(__dirname, 'decompressed_output.txt');\n\ntry {\n  console.log(`Attempting to read dummy bzip2 data from: ${dummyCompressedPath}`);\n  const compressedData = fs.readFileSync(dummyCompressedPath);\n\n  console.log('Attempting to decode...');\n  // This will likely throw an error because dummyOriginalData is not valid bzip2\n  const data = Bunzip.decode(compressedData);\n\n  fs.writeFileSync(decompressedOutputPath, data);\n  console.log(`Successfully (or not) decompressed data to: ${decompressedOutputPath}`);\n  console.log(`Decoded data length: ${data.length}`);\n} catch (error) {\n  console.error('Error during decompression:', error.message);\n  console.warn('\\nNOTE: The `dummy_example.bz2` created in this quickstart is NOT a real bzip2 file.');\n  console.warn('`seek-bzip` requires actual bzip2 compressed data for successful decoding.');\n  console.warn('To test properly, manually create `example.bz2` using a bzip2 compressor, then replace `dummyCompressedPath` with `path.join(__dirname, 'example.bz2')`.');\n} finally {\n  if (fs.existsSync(dummyCompressedPath)) {\n    fs.unlinkSync(dummyCompressedPath);\n  }\n  // You might want to keep decompressed_output.txt for inspection if it ever succeeds.\n  // if (fs.existsSync(decompressedOutputPath)) {\n  //   fs.unlinkSync(decompressedOutputPath);\n  // }\n}\n","lang":"javascript","description":"Demonstrates basic synchronous buffer-to-buffer decompression using `Bunzip.decode`. It includes a warning that a real bzip2 file (not the dummy one created in the example) is required for successful operation.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}