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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@abasb75/charls

v2.4.2-p12

Published

charls for js (jls file codec)

Downloads

129

Readme

@abasb75/charls

A JavaScript/TypeScript package built on top of the CharLS reference implementation, providing full client-side JPEG-LS encoding and decoding capabilities using WebAssembly (charls 2.4.2).

Perfect for web applications that need lossless or near-lossless image compression (e.g., DICOM viewers, medical imaging tools, or any project dealing with high-fidelity image data).

Demo

Installation Bash

npm install @abasb75/charls

How to use

Your project must support ES modules (e.g., Vite, Webpack, Next.js, etc.). The bundler should correctly handle WASM files (using ?url import is required). Usage Required Imports


import CharLSDecoder from "@abasb75/charls/decode";
import CharLSEncoder from "@abasb75/charls/encode";
import decoderUrl from "@abasb75/charls/jls_decoder.wasm?url";
import encoderUrl from "@abasb75/charls/jls_encoder.wasm?url";

let decoderInstance: any = null;
let encoderInstance: any = null;
let decodeFn: any = null;
let encodeFn: any = null;
    
async function decodeAndReencode(pixelData: DataView): Promiseuint8array {
    // Load decoder if not already loaded
    if (!decoderInstance) {
        decoderInstance = await CharLSDecoder({
            locateFile: () => new URL(decoderUrl, import.meta.url).href
        });
        decodeFn = decoderInstance.decode;
    }

    // Load encoder if not already loaded
    if (!encoderInstance) {
        encoderInstance = await CharLSEncoder({
            locateFile: () => new URL(encoderUrl, import.meta.url).href
        });
        encodeFn = encoderInstance.encode;
    }

    const buffer = new Uint8Array(pixelData.buffer, pixelData.byteOffset, pixelData.byteLength);

    // Decode
    const decoded = await decodeFn(buffer);

    // Re-encode (useful for validation)
    const encoded = await encodeFn(
        decoded.data,
        decoded.width,
        decoded.height,
        decoded.components,
        decoded.bitsPerSample,
        decoded.interleave_mode,
        decoded.nearLossless || 0
    );

    // Decode again to get final pixel data
    const final = await decodeFn(encoded.data);

    return final.data;
}

Javascript

  <script src="./dist/jls_decoder.js"></script>
  <script src="./dist/jls_encoder.js"></script>
  <script type="module">

    let decode = null;
    let encode = null;

    async function init() {
      const decoderModule = await CharLSDecoder();
      const encoderModule = await CharLSEncoder();
      decode = decoderModule.decode;
      encode = encoderModule.encode;
    }

    await init();
</script>