@amoutonbrady/lz-string (英语)
现代类型脚本端口 长弦,基于 LZ 的 javaScript 字符串的压缩算法.
- 有线兼容 lz-string 1.x: 由一解压与一解压压缩的任何东西 (对照测试套间中的参考执行进行核实).
- 相同的API, 完全输入, 无害环境管理和通用JS构建, 零依赖性, 有树可动摇性.
- 大约一半的原作来源:比特读者/写作员是共享的,而不是复制版.
安装
pnpm add @amoutonbrady/lz-string
使用量
import { compressToURL, decompressFromURL } from '@amoutonbrady/lz-string';
const compressed = compressToURL('hello world'); // safe to put in a query string as-is
const original = decompressFromURL(compressed); // 'hello world'
API 密码
每个 compress* 函数返回 '' 页:1 null编号 :undefined每一个 decompress* 函数
返回时 '' 页:1 null编号 :undefined, (中文(简体) ), null 用于空入或腐败输入.
| 压缩 | 降压 | 产出 |
|---|---|---|
compress(input: string): string | decompress(input: string): string | null | 原始 UTF-16 代码单位, 最小但不能安全存储为文本 |
compressToUTF16(input: string): string | decompressFromUTF16(input: string): string | null | 有效的 UTF-16, 安全 localStorage |
compressToBase64(input: string): string | decompressFromBase64(input: string): string | null | 标准基数64 |
compressToURL(input: string): string | decompressFromURL(input: string): string | null | URL 安全字母表 (单位:千美元)+-$),无粘接,不需要编码 |
compressToUint8Array(input: string): Uint8Array | decompressFromUint8Array(input: Uint8Array): string | null | 二进制 |
compressToURL 被命名为 compressToEncodedURIComponent 在原始图书馆.
发展
pnpm install
pnpm test # node:test, runs the TypeScript sources directly
pnpm typecheck
pnpm build # tsdown: ESM + CJS + .d.ts, then publint + arethetypeswrong
发布: 击出版本, 推出 v* 标签。 这个 release.yml 工作流程的构建、测试和
通过 npm 信任的出版方式发布出处为 npm(没有可管理的迹象).
许可证
麻省理工学院