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

A collection of codecs for working with SCI-engine assets

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
decreased by-20%
Maintainers
1
Weekly downloads
 
Created
Source

@4bitlabs/codecs

A collection of decoders (and eventually encoders) for working with Sierra On-line SCI-engine assets.

Supported Codecs

NameDecoderEncoder
Huffman
Lempel–Ziv–Welch

Huffman

Decoding bytes with Huffman:

import { Huffman } from '@4bitlabs/codecs';

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

Lempel–Ziv–Welch

Decoding bytes with Lempel-Ziv-Welch:

import { Lzw } from '@4bitlabs/codecs';

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

Custom LZW Options

By default, most-significant bit ordering is used. You can change the encoded byte ordering of the decoder with the options parameter. To use least-significant bit ordering:

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

The default code-width it uses is 8, this can also be adjusted. To use a 7-bit code width:

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

Also, an entirely custom LZW dictionaries can be used for decoding:

import { Lzw } from '@4bitlabs/codecs';

const dictionary = [
  Lzw.EOF_MARKER,
  0x41, // A
  0x42, // B
  0x43, // C
  0x44, // D
];

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

Longer codings can be encoded in the dictionary by using either an array of numbers of with a Uint8Array:

import { Lzw, EOF_MARKER } from '@4bitlabs/codecs';

const dictionary = [
  Lzw.EOF_MARKER,
  Uint8Array.of(0x47, 0x41, 0x54, 0x41), // GATA
  Uint8Array.of(0x41, 0x54, 0x54, 0x41), // ATTA
  Uint8Array.of(0x43, 0x47, 0x41, 0x54), // CGAT
  Uint8Array.of(0x41, 0x43, 0x41, 0x47), // ACAG
];

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

FAQs

Package last updated on 22 Mar 2024

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

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