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

@lhlyu/zipson

v0.0.1

Published

A compact JSON-compatible serializer with compression and streaming support. 一个紧凑的 JSON 兼容序列化工具,支持压缩与流式处理。

Readme

zipson

npm Last Commit

Zipson 是 JSON.parse / JSON.stringify 的可替代方案,提供压缩与流式解析能力。

本仓库基于原作者 @jgranstrom/zipson 的实现进行维护与改进。

安装

npm install @lhlyu/zipson

快速开始

import { stringify, parse } from '@lhlyu/zipson'

const data = { hello: 'world', list: [1, 2, 3] }
const encoded = stringify(data)
const decoded = parse(encoded)

API

stringify(data, options?)

将数据序列化为 zipson 字符串。

stringifyTo(data, writer, options?)

将数据序列化到指定的 zipson 写入器。

import { stringifyTo, ZipsonStringWriter } from '@lhlyu/zipson'

const writer = new ZipsonStringWriter()
stringifyTo([1, 2, 3], writer)
const encoded = writer.value

parse(string)

解析 zipson 字符串。

parseIncremental()

分片增量解析 zipson 字符串。传入 null 表示结束并返回解析结果。

import { parseIncremental } from '@lhlyu/zipson'

const increment = parseIncremental()
increment(chunk1)
increment(chunk2)
const result = increment(null)

选项

| 选项 | 类型 | 默认值 | 说明 | | --------------------- | ------- | ------- | --------------------------------------------------------- | | detectUtcTimestamps | boolean | false | 检测 2018-01-01T00:00:00Z 这类 UTC 时间戳并按日期压缩。 | | fullPrecisionFloats | boolean | false | 保留完整浮点精度,默认精度约为 10^-3。 |

注意事项

  • 不支持循环引用对象,请仅传入 JSON 安全的数据结构。
  • 部分小数(例如 822.26702880859375)会出现精度损失。

Writer

压缩输出统一通过写入器接口输出,便于扩展不同目标。自定义写入器需要实现:

abstract class ZipsonWriter {
    abstract write(data: string): void
    abstract end(): void
}

自定义写入器示例

import { ZipsonWriter, stringifyTo } from '@lhlyu/zipson'

class ArrayWriter extends ZipsonWriter {
    chunks: string[] = []
    write(data: string) {
        this.chunks.push(data)
    }
    end() {}
}

const writer = new ArrayWriter()
stringifyTo({ a: 1 }, writer)
const encoded = writer.chunks.join('')

输出与类型声明

本分支默认输出:

  • ESM 包:dist/index.mjs
  • CJS 包:dist/index.cjs
  • 类型声明:types/(与 src/ 目录结构一致)

构建

JS 包由 rolldown 生成,类型声明由 tsc 生成:

npm run build

版权与致谢

本项目基于 Jonas Granstrom 的 zipson 原始实现进行修改与改进。 原仓库地址:https://github.com/jgranstrom/zipson

许可证

MIT,详见 LICENSE