{"id":27139602,"url":"https://github.com/upupming/arithmetic-coding","last_synced_at":"2025-08-12T00:05:51.211Z","repository":{"id":57183693,"uuid":"178224249","full_name":"upupming/arithmetic-coding","owner":"upupming","description":":wrench: Arithmetic coding algorithm implemented in Node.js, both API and CLI support. 算术编码 npm 包，支持 API 调用和 CLI。","archived":false,"fork":false,"pushed_at":"2019-03-31T11:26:33.000Z","size":767,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T01:37:45.381Z","etag":null,"topics":["arithmetic-coding","compress","compression","lossless-compression-algorithm"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/upupming.png","metadata":{"files":{"readme":"README-zh.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-28T14:48:48.000Z","updated_at":"2024-11-16T19:20:17.000Z","dependencies_parsed_at":"2022-08-23T01:30:25.314Z","dependency_job_id":null,"html_url":"https://github.com/upupming/arithmetic-coding","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/upupming/arithmetic-coding","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upupming%2Farithmetic-coding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upupming%2Farithmetic-coding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upupming%2Farithmetic-coding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upupming%2Farithmetic-coding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/upupming","download_url":"https://codeload.github.com/upupming/arithmetic-coding/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upupming%2Farithmetic-coding/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269677721,"owners_count":24457869,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arithmetic-coding","compress","compression","lossless-compression-algorithm"],"created_at":"2025-04-08T04:58:51.582Z","updated_at":"2025-08-12T00:05:51.177Z","avatar_url":"https://github.com/upupming.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# arithmetic-coding\n\n\u003ca href=\"https://www.npmjs.com/package/arithmetic-coding\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/arithmetic-coding.svg?style=flat-square\" alt=\"npm\"\u003e\u003c/a\u003e\n\u003ca href=\"https://standardjs.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square\" alt=\"JavaScript Style Guide\"\u003e\u003c/a\u003e\n\u003ca href=\"https://coveralls.io/github/upupming/arithmetic-coding?branch=master\"\u003e\u003cimg src=\"https://img.shields.io/coveralls/github/upupming/arithmetic-coding.svg?style=flat-square\" alt=\"Coveralls\"\u003e\u003c/a\u003e\n\u003ca href=\"https://travis-ci.com/upupming/arithmetic-coding/builds\"\u003e\u003cimg src=\"https://img.shields.io/travis/com/upupming/arithmetic-coding.svg?style=popout-square\" alt=\"travis build status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/upupming/arithmetic-coding/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/mashape/apistatus.svg?style=popout-square\" alt=\"License\"\u003e\u003c/a\u003e\n\n- [英文文档](./README.md)\n- 中文文档\n\n## 安装\n\n安装为模块供 API 调用：\n\n```js\nnpm i arithmetic-coding\n```\n\n或者全局安装为命令行界面：\n\n```js\nnpm i -g arithmetic-coding\n```\n\n## API\n\n通过指定文件目录调用：\n\n```js\nconst ariCoding = require('arithmetic-coding');\n// 从文件编码\nariCoding.encode(path.resolve('/txt/long.txt'), path.resolve('/txt/long-encoded.txt'));\n// 从文件解码\nariCoding.decode(path.resolve('/txt/long-encoded.txt'), path.resolve('/txt/long-decoded.txt'));\n```\n\n通过传入 `Buffer` 调用：\n\n```js\nlet data = Buffer.from('Example data', 'utf8');\n// 从 Buffer 编码\nlet encoded = encode.encodeFromBuffer(data);\nconsole.log(`encoded = ${encoded}`);\n// 从 Buffer 解码\nlet decoded = decode.decodeFromBuffer(encoded);\nconsole.log(`decoded = ${decoded}`);\n```\n\n## 命令行界面\n\n```js\n$ ari-coding -h\nUsage: index [options] [command]\n\nOptions:\n  -v, --version              output the version number\n  -h, --help                 output usage information\n\nCommands:\n  encode|e [options] \u003cfile\u003e  encode a file\n  decode|d [options] \u003cfile\u003e  decode a file\n\n$ ari-coding encode -h\nUsage: encode|e [options] \u003cfile\u003e\n\nencode a file\n\nOptions:\n  -o, --output \u003cfile\u003e  output file path\n  -h, --help           output usage information\n```\n\n## 性能\n\n您可以查看 [travis 测试日志](https://travis-ci.com/upupming/arithmetic-coding) 得知最新版本的运行时间。\n\n一些运行测试结果如下：\n\n| 文件大小 (字节) | 总运行时间 | 编码时间 | 解码时间 |\n| --------------- | ---------- | -------- | -------- |\n| 60640           | 110ms      | 极小     | 110ms    |\n| 2130640         | 2940ms     | 426ms    | 2514ms   |\n\n## 关于算数编码算法\n\n1. [维基百科](https://en.wikipedia.org/wiki/Arithmetic_coding)\n2. [编码/解码的实际可用的实现](http://www.drdobbs.com/cpp/data-compression-with-arithmetic-encodin/240169251)\n3. [GitHub 上 Reference-arithmetic-coding 的源代码](https://github.com/nayuki/Reference-arithmetic-coding)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupupming%2Farithmetic-coding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fupupming%2Farithmetic-coding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupupming%2Farithmetic-coding/lists"}