{"id":13670246,"url":"https://github.com/aui/pinyin-engine","last_synced_at":"2026-01-21T09:30:17.744Z","repository":{"id":50323874,"uuid":"99914701","full_name":"aui/pinyin-engine","owner":"aui","description":"JavaScript 拼音匹配引擎","archived":false,"fork":false,"pushed_at":"2021-09-06T04:14:30.000Z","size":219,"stargazers_count":460,"open_issues_count":6,"forks_count":53,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-24T18:42:11.927Z","etag":null,"topics":["pinyin"],"latest_commit_sha":null,"homepage":"https://aui.github.io/pinyin-engine/example/","language":"HTML","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/aui.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-08-10T11:12:54.000Z","updated_at":"2024-03-29T07:23:54.000Z","dependencies_parsed_at":"2022-08-28T05:11:08.025Z","dependency_job_id":null,"html_url":"https://github.com/aui/pinyin-engine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aui%2Fpinyin-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aui%2Fpinyin-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aui%2Fpinyin-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aui%2Fpinyin-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aui","download_url":"https://codeload.github.com/aui/pinyin-engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239763672,"owners_count":19692800,"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","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":["pinyin"],"created_at":"2024-08-02T09:00:36.928Z","updated_at":"2026-01-21T09:30:17.689Z","avatar_url":"https://github.com/aui.png","language":"HTML","funding_links":[],"categories":["HTML"],"sub_categories":[],"readme":"# pinyin-engine\n\n这是一款简单高效的拼音匹配引擎，它能使用拼音够快速的检索列表中的数据。\n\n1. 使用索引以及缓存机制，从而在客户端实现毫秒级的数据检索\n2. 它的字典数据格式经过压缩处理，简体中文版本仅仅 17kb 大小（Gzip）\n3. 支持多音字、支持拼音首字母匹配\n4. 简体版本覆盖 6718 个汉字，繁体中文覆盖 20846 个汉字\n\n在线演示：\u003chttps://aui.github.io/pinyin-engine/example/\u003e\n\n## 安装\n\n```shell\nnpm install pinyin-engine --save\n```\n\n## API\n\n### new PinyinEngine(list, keys)\n\n建立拼音索引。\n\n参数：\n\n1. list `{[string]|[Object]}` 被索引的目标\n2. keys `{[string]}` 可选。如果 list 为 `Object`，这里用来设置需要被索引的 key\n3. begin `{[boolean]}` 可选。如果 begin 为 `true`，将执行前模糊检索\n\n### .query(keyword)\n\n查询匹配拼音的数据。\n\n参数：\n\n1. keyword `{string}` 拼音或者关键字\n\n返回：\n\n`{[string]|{Object}}`\n\n## 繁体中文版本\n\n包含简体中文与繁体中文。\n\n```js\nconst PinyinEngine = require('pinyin-engine/tw');\n```\n\n## 使用范例\n\n列表项为字符串：\n\n```js\nconst PinyinEngine = require('pinyin-engine');\n\n// 建立数据索引\nconst pinyinEngine = new PinyinEngine([\n    '清华大学',\n    '北京大学',\n    '中央美院'\n]);\n\n// 查询\npinyinEngine.query('daxue'); // ['清华大学', '北京大学']\n```\n\n列表项为对象：\n\n```js\nconst PinyinEngine = require('pinyin-engine');\n\n// 建立数据索引\nconst pinyinEngine = new PinyinEngine([\n    { id: 0, name: '清华大学' },\n    { id: 1, name: '北京大学' },\n    { id: 3, name: '中央美院' }\n], ['name']);\n\n// 查询\npinyinEngine.query('daxue'); // ['清华大学', '北京大学']\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faui%2Fpinyin-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faui%2Fpinyin-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faui%2Fpinyin-engine/lists"}