New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@4bitlabs/codecs

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@4bitlabs/codecs - npm Package Compare versions

Comparing version 1.0.4 to 2.0.0

dist/comp3.d.ts

2

dist/huffman.d.ts
import { ReadonlyUint8Array } from './shared';
export declare const decode: (bytes: ReadonlyUint8Array) => Uint8Array;
export declare const unpack: (bytes: ReadonlyUint8Array) => Uint8Array;
//# sourceMappingURL=huffman.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decode = void 0;
exports.unpack = void 0;
const readers_1 = require("@4bitlabs/readers");
const nextCode = (br, nodes, idx) => {
const [value, siblings] = nodes.get(idx);
const node = nodes.get(idx);
if (!node)
throw new Error(`unpack error: unexpected huffman code [${idx}]`);
const [value, siblings] = node;
if (siblings === 0)

@@ -12,3 +15,3 @@ return [value, false];

};
const decode = (bytes) => {
const unpack = (bytes) => {
const br = (0, readers_1.createBitReader)(bytes);

@@ -30,5 +33,5 @@ const nodeCount = br.read32(8);

return buffer;
}, new Uint8Array(result.length));
}, new Uint8Array(result.length)); // TODO replace with Uint8Array.from
};
exports.decode = decode;
exports.unpack = unpack;
//# sourceMappingURL=huffman.js.map
export * as Lzw from './lzw';
export * as Huffman from './huffman';
export * as Comp3 from './comp3';
//# sourceMappingURL=index.d.ts.map

@@ -26,5 +26,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Huffman = exports.Lzw = void 0;
exports.Comp3 = exports.Huffman = exports.Lzw = void 0;
exports.Lzw = __importStar(require("./lzw"));
exports.Huffman = __importStar(require("./huffman"));
exports.Comp3 = __importStar(require("./comp3"));
//# sourceMappingURL=index.js.map

@@ -15,4 +15,4 @@ import { ReadonlyUint8Array } from './shared';

type LzwDecodeOptions = CommonLzwDecodeOptions | (CommonLzwDecodeOptions & LiteralLzwDecodeOptions) | (CommonLzwDecodeOptions & CustomLzwDecodeOptions);
export declare const decode: (source: ReadonlyUint8Array, options?: LzwDecodeOptions) => Uint8Array;
export declare const unpack: (source: ReadonlyUint8Array, options?: LzwDecodeOptions) => Uint8Array;
export {};
//# sourceMappingURL=lzw.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decode = exports.RESET_MARKER = exports.EOF_MARKER = void 0;
exports.unpack = exports.RESET_MARKER = exports.EOF_MARKER = void 0;
const readers_1 = require("@4bitlabs/readers");

@@ -47,3 +47,3 @@ const concat_1 = require("./concat");

};
const decode = (source, options = {}) => {
const unpack = (source, options = {}) => {
const outputs = [];

@@ -102,3 +102,3 @@ const { order = 'lsb' } = options;

};
exports.decode = decode;
exports.unpack = unpack;
//# sourceMappingURL=lzw.js.map
{
"name": "@4bitlabs/codecs",
"version": "1.0.4",
"version": "2.0.0",
"description": "A collection of codecs for working with SCI-engine assets",

@@ -18,3 +18,4 @@ "main": "./dist/index.js",

"./lzw": "./dist/lzw.js",
"./huffman": "./dist/huffman.js"
"./huffman": "./dist/huffman.js",
"./comp3": "./dist/comp3.js"
},

@@ -21,0 +22,0 @@ "files": [

@@ -1,3 +0,8 @@

# `@4bitlabs/codecs`
# @4bitlabs/codecs [![License][license]][npm] [![NPM Version][version]][npm] [![NPM Downloads][dl]][npm]
[npm]: https://www.npmjs.com/package/@4bitlabs/codecs
[version]: https://img.shields.io/npm/v/%404bitlabs%2Fcodecs
[license]: https://img.shields.io/npm/l/%404bitlabs%2Fcodecs
[dl]: https://img.shields.io/npm/dy/%404bitlabs%2Fcodecs
A collection of decoders (and eventually encoders) for working with [Sierra On-line][sierra] [SCI-engine][sci0] assets.

@@ -11,6 +16,7 @@

| [Lempel–Ziv–Welch][lzw] | ✅ | |
| COMP3 | ✅ | |
## Huffman
Decoding bytes with [Huffman][huffman]:
Example decoding bytes with [Huffman][huffman]:

@@ -21,3 +27,3 @@ ```ts

const encodedBytes = Uint8Array.of(/* encoded data */);
const bytes = Huffman.decode(encodedBytes);
const bytes = Huffman.unpack(encodedBytes);
```

@@ -27,3 +33,3 @@

Decoding bytes with [Lempel-Ziv-Welch][lzw]:
Example decoding bytes with [Lempel-Ziv-Welch][lzw]:

@@ -34,3 +40,3 @@ ```ts

const encodedBytes = Uint8Array.of(/* encoded data */);
const bytes = Lzw.decode(encodedBytes);
const bytes = Lzw.unpack(encodedBytes);
```

@@ -44,3 +50,3 @@

```ts
const bytes = Lzw.decode(encodedBytes, { order: 'lsb' });
const bytes = Lzw.unpack(encodedBytes, { order: 'lsb' });
```

@@ -51,3 +57,3 @@

```ts
const bytes = Lzw.decode(encodedBytes, { literalWidth: 7 });
const bytes = Lzw.unpack(encodedBytes, { literalWidth: 7 });
```

@@ -68,3 +74,3 @@

const bytes = Lzw.decode(encodedBytes, { dictionary });
const bytes = Lzw.unpack(encodedBytes, { dictionary });
```

@@ -85,5 +91,18 @@

const bytes = Lzw.decode(encodedBytes, { dictionary });
const bytes = Lzw.unpack(encodedBytes, { dictionary });
```
## `SCI01`/`SCI1`-engine COMP3
`COMP3` compression is used in `SCI01`/`SCI1` engine games, it is a 9–12 bit variable length encoding.
Example decoding bytes with `COMP3` compression:
```ts
import { Comp3 } from '@4bitlabs/codecs';
const encodedBytes = Uint8Array.of(/* encoded data */);
const bytes = Comp3.unpack(encodedBytes);
```
[sierra]: https://en.wikipedia.org/wiki/Sierra_Entertainment

@@ -90,0 +109,0 @@ [huffman]: https://en.wikipedia.org/wiki/Huffman_coding

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc