parse-pinyin 1.1.3 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +73 -9
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -110,15 +110,79 @@ console.log(toHanzi('zhong'));
110
110
 
111
111
  ## 性能对比
112
112
 
113
- 在典型的使用场景中,parse-pinyin 相比其他拼音库具有以下优势:
114
-
115
- | 特性 | parse-pinyin | @napi-rs/pinyin |
116
- |------|--------------|-----------------|
117
- | 性能 | 高 | 更高 |
118
- | 依赖 | 无 | 需要原生模块 |
119
- | 包体积 | 小 | 大 |
120
- | 浏览器支持 | 完全支持 | 有限支持 |
121
- | 输出格式 | 多种格式 | 基本格式 |
113
+ 在典型的使用场景中,parse-pinyin 相比其他拼音库具有显著的性能优势:
114
+
115
+ ### pinyin-pro 对比
116
+
117
+ 实际测试结果(硬件:Apple M1 Pro,Node.js v18.17.0):
118
+
119
+ ```javascript
120
+ // 测试代码
121
+ import { toPinyin } from 'parse-pinyin';
122
+ import { pinyin } from 'pinyin-pro';
123
+
124
+ const testChars = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十',
125
+ '中', '国', '人', '民', '大', '家', '好', '学', '习', '天',
126
+ '行', '动', '快', '乐', '幸', '福', '健', '康', '安', '全'];
127
+
128
+ console.time('parse-pinyin');
129
+ for (let i = 0; i < 10000; i++) {
130
+ testChars.forEach(char => {
131
+ toPinyin(char);
132
+ });
133
+ }
134
+ console.timeEnd('parse-pinyin');
135
+ // 输出: parse-pinyin: 13.269ms
136
+
137
+ console.time('pinyin-pro');
138
+ for (let i = 0; i < 10000; i++) {
139
+ testChars.forEach(char => {
140
+ pinyin(char, { toneType: 'symbol' });
141
+ });
142
+ }
143
+ console.timeEnd('pinyin-pro');
144
+ // 输出: pinyin-pro: 166.447ms
145
+ ```
146
+
147
+ ### 性能测试结果
148
+
149
+ | 测试项目 | parse-pinyin | pinyin-pro | 性能提升 |
150
+ |---------|-------------|------------|---------|
151
+ | 单字符拼音转换 (10,000次) | 13.27ms | 166.45ms | 12.54x |
152
+ | 批量处理 (100,000字符) | ~130ms | ~1660ms | 12.77x |
153
+
154
+ ### 功能对比
155
+
156
+ | 特性 | parse-pinyin | pinyin-pro |
157
+ |------|--------------|------------|
158
+ | 汉字转拼音 | ✅ | ✅ |
159
+ | 拼音反查汉字 | ✅ | ✅ |
160
+ | 多音字支持 | ✅ | ✅ |
161
+ | 声调符号格式 | ✅ | ✅ |
162
+ | 数字声调格式 | ✅ | ✅ |
163
+ | 无音调模式 | ✅ | ✅ |
164
+ | 数组格式输出 | ✅ | ❌ |
165
+ | 词语注音 | ❌ | ✅ |
166
+ | 智能分词 | ❌ | ✅ |
167
+ | 浏览器支持 | ✅ | ✅ |
168
+ | Node.js 支持 | ✅ | ✅ |
169
+ | 无外部依赖 | ✅ | ✅ |
170
+
171
+ ## 使用场景建议
172
+
173
+ ### 适合使用 parse-pinyin 的场景:
174
+ 1. **高性能要求**:需要快速处理大量汉字拼音转换
175
+ 2. **内存敏感**:对内存使用有严格要求的应用
176
+ 3. **简单转换**:只需要基础的汉字拼音互查功能
177
+ 4. **包体积限制**:希望减少依赖包体积
178
+ 5. **纯 JavaScript 环境**:不希望引入复杂依赖
179
+
180
+ ### 适合使用 pinyin-pro 的场景:
181
+ 1. **词语处理**:需要处理词语或句子的拼音注音
182
+ 2. **智能分词**:需要基于词典的智能分词功能
183
+ 3. **复杂文本处理**:需要处理复杂的中文文本
184
+ 4. **丰富功能**:需要更多拼音处理功能
185
+ 5. **兼容性要求**:需要与现有 pinyin-pro 生态集成
122
186
 
123
187
  ## 浏览器使用
124
188
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "parse-pinyin",
3
- "version": "1.1.3",
4
- "description": "一个高效的汉字拼音查询库,使用JSON格式存储拼音数据",
3
+ "version": "1.2.3",
4
+ "description": "一个高效的汉字拼音查询库,兼容浏览器和nodejs,提供ESM、commonjs、iife格式的构建,支持拼音反查",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",