streaming RAR extractor jsr.io/@mary/rar
jsr
0

Configure Feed

Select the types of activity you want to include in your feed.

refactor: replace local crc32 with @mary/crc32

+26 -46
+1
deno.json
··· 22 22 "include": ["lib/", "LICENSE", "README.md", "deno.json"] 23 23 }, 24 24 "imports": { 25 + "@mary/crc32": "jsr:@mary/crc32@^0.1.0", 25 26 "@mary/ds-queue": "jsr:@mary/ds-queue@^0.1.3", 26 27 "@mary/mutex": "jsr:@mary/mutex@^0.1.0" 27 28 }
+5
deno.lock
··· 1 1 { 2 2 "version": "5", 3 3 "specifiers": { 4 + "jsr:@mary/crc32@0.1": "0.1.0", 4 5 "jsr:@mary/ds-queue@~0.1.3": "0.1.3", 5 6 "jsr:@mary/mutex@0.1": "0.1.0", 6 7 "jsr:@std/assert@1": "1.0.19", ··· 8 9 "npm:@types/node@*": "24.1.0" 9 10 }, 10 11 "jsr": { 12 + "@mary/crc32@0.1.0": { 13 + "integrity": "cadbfd1dc860a228b53dc180534f903eb0db9c0cc79eca109b9437791514a756" 14 + }, 11 15 "@mary/ds-queue@0.1.3": { 12 16 "integrity": "a743caa397b924cb08b0bbdffc526eb1ea2d3fc9e675da6edc137c437fc93c76" 13 17 }, ··· 37 41 }, 38 42 "workspace": { 39 43 "dependencies": [ 44 + "jsr:@mary/crc32@0.1", 40 45 "jsr:@mary/ds-queue@~0.1.3", 41 46 "jsr:@mary/mutex@0.1" 42 47 ]
+2 -1
lib/rar3/block.ts
··· 7 7 * type-specific payload. data follows immediately after the header bytes. 8 8 */ 9 9 10 + import { crc32 } from '@mary/crc32'; 11 + 10 12 import { 11 13 ChecksumMismatchError, 12 14 InvalidSignatureError, 13 15 MalformedArchiveError, 14 16 TruncatedArchiveError, 15 17 } from '../errors.ts'; 16 - import { crc32 } from '../utils/crc32.ts'; 17 18 import { BlockFlag, BlockType, EndArcFlag, FileFlag, MainFlag, RAR3_SIGNATURE } from './constants.ts'; 18 19 19 20 // #region cursor
+2 -1
lib/rar3/extract.ts
··· 1 + import { crc32 } from '@mary/crc32'; 2 + 1 3 import { 2 4 ChecksumMismatchError, 3 5 InvalidSignatureError, ··· 7 9 TruncatedArchiveError, 8 10 } from '../errors.ts'; 9 11 import { concat, decodeUtf8From, read } from '../utils/buffer.ts'; 10 - import { crc32 } from '../utils/crc32.ts'; 11 12 import { 12 13 crc32Verifier, 13 14 type DataSegment,
+2 -1
lib/rar3/unpack.ts
··· 12 12 * of RARLAB's unrar. 13 13 */ 14 14 15 + import { crc32 } from '@mary/crc32'; 16 + 15 17 import { ChecksumMismatchError, MalformedArchiveError, UnsupportedFeatureError } from '../errors.ts'; 16 - import { crc32 } from '../utils/crc32.ts'; 17 18 18 19 import type { StreamReader } from '../utils/stream-reader.ts'; 19 20 import { PPMD_CORRUPT, PPMD_END_OF_DATA, type PpmdByteIn, RAR3PpmdModel } from './ppmd.ts';
+2 -1
lib/rar5/block.ts
··· 1 + import { crc32 } from '@mary/crc32'; 2 + 1 3 import { ChecksumMismatchError, InvalidSignatureError } from '../errors.ts'; 2 4 import { textDecoder } from '../utils/buffer.ts'; 3 - import { crc32 } from '../utils/crc32.ts'; 4 5 5 6 import { 6 7 BlockFlag,
+2 -1
lib/rar5/extract.ts
··· 1 + import { crc32 } from '@mary/crc32'; 2 + 1 3 import { 2 4 ChecksumMismatchError, 3 5 InvalidSignatureError, ··· 7 9 UnsupportedFeatureError, 8 10 } from '../errors.ts'; 9 11 import { concat, decodeUtf8From, read } from '../utils/buffer.ts'; 10 - import { crc32 } from '../utils/crc32.ts'; 11 12 import { 12 13 crc32Verifier, 13 14 type DataSegment,
-36
lib/utils/crc32.ts
··· 1 - const TABLE = /*#__PURE__*/ (() => { 2 - const table = new Uint32Array(256); 3 - 4 - for (let idx = 0; idx < 256; idx++) { 5 - let c = idx; 6 - 7 - for (let bit = 0; bit < 8; bit++) { 8 - c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; 9 - } 10 - 11 - table[idx] = c; 12 - } 13 - 14 - return table; 15 - })(); 16 - 17 - /** 18 - * computes the CRC-32 checksum of a byte sequence, matching the algorithm RAR 19 - * uses for header and file data checksums. 20 - * 21 - * the function can be called incrementally by feeding the previous result back 22 - * as `seed`, allowing a checksum to be built up across streamed chunks. 23 - * 24 - * @param data bytes to checksum 25 - * @param seed running checksum from a previous chunk, or 0 to start fresh 26 - * @returns the unsigned 32-bit checksum 27 - */ 28 - export const crc32 = (data: Uint8Array, seed: number = 0): number => { 29 - let crc = (seed ^ 0xffffffff) >>> 0; 30 - 31 - for (let idx = 0, len = data.length; idx < len; idx++) { 32 - crc = TABLE[(crc ^ data[idx]) & 0xff] ^ (crc >>> 8); 33 - } 34 - 35 - return (crc ^ 0xffffffff) >>> 0; 36 - };
+2 -1
lib/utils/segments.ts
··· 1 + import { crc32 } from '@mary/crc32'; 2 + 1 3 import { ChecksumMismatchError } from '../errors.ts'; 2 4 import type { Reader } from '../reader/types.ts'; 3 5 4 6 import { read } from './buffer.ts'; 5 - import { crc32 } from './crc32.ts'; 6 7 7 8 /** 8 9 * @module
+2 -1
scripts/build-rar3-long-password-fixture.ts
··· 11 11 * run: `deno run -A scripts/build-rar3-long-password-fixture.ts` 12 12 */ 13 13 14 + import { crc32 } from '@mary/crc32'; 15 + 14 16 import { rar3DeriveKey } from '../lib/rar3/crypto.ts'; 15 17 import { importAesKey } from '../lib/rar5/crypto.ts'; 16 18 import { BlockFlag, BlockType, CompressMethod, FileFlag, HostOs } from '../lib/rar3/constants.ts'; 17 - import { crc32 } from '../lib/utils/crc32.ts'; 18 19 19 20 const PASSWORD = 'the-rarbug-makes-this-key-funny!'; 20 21 const SALT = new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]);
+2 -1
tests/rar3-extract.test.ts
··· 1 + import { crc32 } from '@mary/crc32'; 2 + 1 3 import { MissingPasswordError, MissingVolumeError } from '../lib/errors.ts'; 2 4 import { fromUint8Array } from '../lib/reader/common.ts'; 3 5 import { unrar3 } from '../lib/rar3/extract.ts'; 4 - import { crc32 } from '../lib/utils/crc32.ts'; 5 6 6 7 /** 7 8 * @module
+2 -1
tests/rar3-oldlzss.test.ts
··· 1 + import { crc32 } from '@mary/crc32'; 2 + 1 3 import { decodeOldLzss15, decodeOldLzss20 } from '../lib/rar3/oldlzss.ts'; 2 - import { crc32 } from '../lib/utils/crc32.ts'; 3 4 4 5 /** 5 6 * @module
+2 -1
tests/rar5-extract.test.ts
··· 1 + import { crc32 } from '@mary/crc32'; 2 + 1 3 import { InvalidPasswordError, MissingPasswordError, MissingVolumeError } from '../lib/errors.ts'; 2 4 import { fromUint8Array } from '../lib/reader/common.ts'; 3 5 import { fromFsFile } from '../lib/reader/deno.ts'; 4 6 import { unrar5 } from '../lib/rar5/extract.ts'; 5 - import { crc32 } from '../lib/utils/crc32.ts'; 6 7 7 8 /** 8 9 * @module