New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pinyin-pro

Package Overview
Dependencies
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pinyin-pro - npm Package Compare versions

Comparing version 3.8.0 to 3.8.1-alpha.1

lib/utils.ts

3

lib/custom.ts

@@ -0,1 +1,2 @@

import { getStringLength } from './utils';
let customDict: { [key: string]: string } = {};

@@ -10,3 +11,3 @@

const keys = Object.keys(config).sort(
(key1, key2) => key2.length - key1.length
(key1, key2) => getStringLength(key2) - getStringLength(key1)
);

@@ -13,0 +14,0 @@ keys.forEach((key) => {

import INITIAL_LIST from '../data/initial';
import Surnames from '../data/surname';
import { getCustomDict } from './custom';
import DICT1 from '../data/dict1';

@@ -9,2 +8,4 @@ import DICT2 from '../data/dict2';

import DICT5 from '../data/dict5';
import { getCustomDict } from './custom';
import { getStringLength } from './utils';
const dictArr = [{}, {}, DICT2, DICT3, DICT4, DICT5];

@@ -63,3 +64,3 @@

if (length === 1) {
for (let i = 0; i < word.length; i++) {
for (let i = 0; i < getStringLength(word); i++) {
const result = getSingleWordPinyin(word[i]);

@@ -84,8 +85,8 @@ const curIsChinese = result !== word[i];

const left_pinyin = left_word
? `${getPinyin(left_word, left_word.length, { nonZh })} `
? `${getPinyin(left_word, getStringLength(left_word), { nonZh })} `
: '';
// 取出该词后右边拼音
const right_word = word.slice(index + key.length);
const right_word = word.slice(index + getStringLength(key));
const right_pinyin = right_word
? ` ${getPinyin(right_word, right_word.length, { nonZh })}`
? ` ${getPinyin(right_word, getStringLength(right_word), { nonZh })}`
: '';

@@ -123,3 +124,3 @@ // 取出的词的拼音

const left_pinyin = left_word
? `${getPinyin(left_word, left_word.length, {
? `${getPinyin(left_word, getStringLength(left_word), {
mode: 'surname',

@@ -130,5 +131,5 @@ nonZh,

// 取出该词后右边拼音
const right_word = word.slice(index + key.length);
const right_word = word.slice(index + getStringLength(key));
const right_pinyin = right_word
? ` ${getPinyin(right_word, right_word.length, {
? ` ${getPinyin(right_word, getStringLength(right_word), {
mode: 'surname',

@@ -144,3 +145,3 @@ nonZh,

// 若姓氏表中的词均为匹配成功,则使用常规匹配
return getPinyin(word, word.length, { nonZh });
return getPinyin(word, getStringLength(word), { nonZh });
};

@@ -173,3 +174,3 @@

const left_pinyin = left_word
? `${getPinyin(left_word, left_word.length, {
? `${getPinyin(left_word, getStringLength(left_word), {
mode,

@@ -181,5 +182,5 @@ useCustomConfig: true,

// 取出该词后右边拼音
const right_word = word.slice(index + key.length);
const right_word = word.slice(index + getStringLength(key));
const right_pinyin = right_word
? ` ${getPinyin(right_word, right_word.length, {
? ` ${getPinyin(right_word, getStringLength(right_word), {
mode,

@@ -195,3 +196,3 @@ useCustomConfig: true,

}
return getPinyin(word, word.length, { mode, nonZh });
return getPinyin(word, getStringLength(word), { mode, nonZh });
};

@@ -244,3 +245,3 @@

if (_pinyin.startsWith(_initial)) {
const _final = _pinyin.slice(_initial.length);
const _final = _pinyin.slice(getStringLength(_initial));
initial_arr.push(_initial);

@@ -247,0 +248,0 @@ final_arr.push(_final);

import { pinyin as _pinyin } from './pinyin';
import { getStringLength } from './utils';

@@ -12,3 +13,3 @@ /**

let currentPinyin = pinyin;
for (let i = 0; i < words.length; i++) {
for (let i = 0; i < getStringLength(words); i++) {
// 当前字的多音字拼音

@@ -41,3 +42,3 @@ const ps = _pinyin(words[i], {

let length = 0;
for (let i = 0; i < pinyin1.length; i++) {
for (let i = 0; i < getStringLength(pinyin1); i++) {
if (pinyin1[i] === pinyin2[length]) {

@@ -44,0 +45,0 @@ length++;

@@ -10,2 +10,3 @@ import {

} from './handle';
import { getStringLength } from './utils';
import { hasCustomConfig } from './custom';

@@ -73,3 +74,3 @@

let str = '';
for (let i = 0; i < word.length; i++) {
for (let i = 0; i < getStringLength(word); i++) {
const char = word[i];

@@ -89,3 +90,3 @@ let code = char.charCodeAt(0);

// 获取原始拼音
let pinyin = getPinyin(word, word.length, {
let pinyin = getPinyin(word, getStringLength(word), {
mode: options.mode || 'normal',

@@ -97,3 +98,3 @@ nonZh: options.nonZh || 'spaced',

// 对multiple进行处理
if (word.length === 1 && options.multiple) {
if (getStringLength(word) === 1 && options.multiple) {
pinyin = getMultipleTone(word);

@@ -100,0 +101,0 @@ }

{
"name": "pinyin-pro",
"version": "3.8.0",
"version": "3.8.1-alpha.1",
"description": "汉字转拼音库。获取中文拼音、韵母、声母、声调、首字母,支持拼音匹配",

@@ -5,0 +5,0 @@ "main": "./dist/index.cjs.js",

@@ -26,6 +26,6 @@ [![pinyin-pro Logo](https://i.ibb.co/26fJ5vF/pinyin-logo.png)](https://github.com/zh-lx/pinyin-pro)

当前版本: 3.7.2 -> 3.8.0
当前版本: 3.8.0 -> 3.8.1
- 新增功能
- 增加 `nonZh` 可选参数,用于配置非中文字符串的输出规则
- 修复问题
- 修复双字节 unicode 编码的文字返回默认值不正确的问题

@@ -32,0 +32,0 @@ 点击查看 [版本更新文档](./CHANGELOG.md)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc