npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@4bitlabs/codecs

v2.0.1

Published

A collection of codecs for working with SCI-engine assets

Downloads

156

Readme

@4bitlabs/codecs License NPM Version NPM Downloads

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

Supported Codecs

| Name | Decoder | Encoder | | ----------------------- | :-----: | :-----: | | Huffman | ✅ | | | Lempel–Ziv–Welch | ✅ | | | COMP3 | ✅ | |

Huffman

Example decoding bytes with Huffman:

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

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

Lempel–Ziv–Welch

Example decoding bytes with Lempel-Ziv-Welch:

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

const encodedBytes = Uint8Array.of(/* encoded data */);
const bytes = Lzw.unpack(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.unpack(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.unpack(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.unpack(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.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:

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

const encodedBytes = Uint8Array.of(/* encoded data */);
const bytes = Comp3.unpack(encodedBytes);