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

fastlz-port-js

v1.0.1

Published

FastLZ lightning-fast lossless compression library — JavaScript port (C-compatible)

Readme

fastlz-port-js

FastLZ lightning-fast lossless compression library — JavaScript port.

这是 FastLZ C 库(v1.0.1,RT-Thread 变体)的 纯 JavaScript 移植,使用 Uint8Array 进行字节级 I/O,Uint32Array 作为哈希表。压缩格式与 C 版 FastLZ 完全兼容。

安装

npm install fastlz-port-js

与 npm 包 fastlz.js 的区别

| | fastlz-port-js(本包) | fastlz.js(旧包) | |---|----------------------|----------------------| | 实现 | 忠实翻译 C 源码,函数式 API | 另一套 JS 实现 | | API | fastlzCompress / fastlzDecompress 等 | FastLZDecoder 全局类 | | 运行时 | 无全局污染,适合 ESM / 严格模式 / uni-app | 依赖 self / global 挂载,严格模式下易白屏 | | TypeScript | 内置类型声明(fastlz.d.ts) | 无 | | C 互操作 | 与 RT-Thread FastLZ 二进制格式兼容 | 行为与 C 版不一致 |

若你从 fastlz.js 迁移,请改用本包的 API(见下方示例),不要继续 require('fastlz.js')

用法

ES Module

import { fastlzCompress, fastlzDecompress, outputBufferSize } from 'fastlz-port-js';

const input = new Uint8Array([/* ... */]);

const outBuf = new Uint8Array(input.length + outputBufferSize(input.length));
const { size: compressedSize } = fastlzCompress(input, input.length, outBuf);
const compressed = outBuf.slice(0, compressedSize);

const decompressed = new Uint8Array(65536);
const { size: decompressedSize } = fastlzDecompress(compressed, compressed.length, decompressed);
const result = decompressed.slice(0, decompressedSize);

CommonJS

const { fastlzCompress, fastlzDecompress } = require('fastlz-port-js');

指定压缩级别

import { fastlzCompressLevel } from 'fastlz-port-js';

const { size: size1 } = fastlzCompressLevel(1, input, input.length, output);
const { size: size2 } = fastlzCompressLevel(2, input, input.length, output);

TypeScript

本包内置类型声明(fastlz.d.ts),无需安装 @types/*,用法与 ES Module 相同:

import { fastlzCompress, fastlzDecompress, type FastLZResult } from 'fastlz-port-js';

const input = new Uint8Array([1, 2, 3]);
const { size }: FastLZResult = fastlzCompress(input);

API

fastlzCompress(input, [length], [output])

自动选择压缩级别(< 65536 字节用 level 1,否则用 level 2)。返回 { data: Uint8Array, size: number }

fastlzCompressLevel(level, input, [length], [output])

指定压缩级别(1 或 2)。

fastlzDecompress(input, [length], [output], [maxout])

自动检测压缩级别并解压。返回 { data: Uint8Array, size: number }size=0 表示错误。

outputBufferSize(inputLength)

计算所需的最小输出缓冲区大小:66 + inputLength * 5 / 100

与 C 版本的对应关系

| C 函数 | JS 函数 | |--------|---------| | fastlz_compress() | fastlzCompress() | | fastlz_compress_level() | fastlzCompressLevel() | | fastlz_decompress() | fastlzDecompress() | | FASTLZ_BUFFER_PADDING(x) | outputBufferSize(x) |

兼容性

压缩数据格式与 C 版 FastLZ 完全兼容。JS 压缩的数据可以被 C 版解压,反之亦然。

许可证

MIT License — 与原 FastLZ 库相同。详见 LICENSE

发布到 npm(维护者)

本机默认 registry 若为镜像站,请显式登录并发布到官方源:

npm login --registry https://registry.npmjs.org/
npm run publish:public

参考