@fe-free/tool 2.5.0 → 2.5.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @fe-free/tool
2
2
 
3
+ ## 2.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: pinyin
8
+
9
+ ## 2.5.1
10
+
3
11
  ## 2.5.0
4
12
 
5
13
  ## 2.4.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/tool",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
package/src/index.ts CHANGED
@@ -1,7 +1,13 @@
1
1
  export { copyToClipboard } from './copy';
2
2
  export { getDayjs } from './date';
3
3
  export { Environment } from './environment';
4
- export { pinyin, pinyinFilter, pinyinMatch, pinyinMatchWithoutFirstLetter } from './pinyin';
4
+ export {
5
+ pinyin,
6
+ pinyinFilter,
7
+ pinyinMatch,
8
+ pinyinMatchWithoutFirstLetter,
9
+ pinyinMatchWithoutFullLetter,
10
+ } from './pinyin';
5
11
  export { sleep } from './sleep';
6
12
  export { buildURL } from './url';
7
13
  export { useGlobalRequest } from './use_global_request';
@@ -1,5 +1,5 @@
1
- import { pinyin } from './pinyin';
2
1
  import { filter, isString, map } from 'lodash-es';
2
+ import { pinyin } from './pinyin';
3
3
 
4
4
  const defaultWhat = (v) => v;
5
5
  /** 字符串匹配,中文首字母拼音匹配,字母小写匹配 */
@@ -47,4 +47,17 @@ function pinyinMatchWithoutFirstLetter(value: string, filterText: string) {
47
47
  return w.indexOf(filterText) > -1 || normal.indexOf(filterText) > -1;
48
48
  }
49
49
 
50
- export { pinyinFilter, pinyinMatch, pinyinMatchWithoutFirstLetter };
50
+ function pinyinMatchWithoutFullLetter(value: string, filterText: string) {
51
+ let w = value;
52
+ // 兼容
53
+ if (!isString(w)) {
54
+ w = '';
55
+ }
56
+ w = w.toLowerCase();
57
+ // 全拼集合
58
+ const firstLetter = map(pinyin(w, 'first_letter'), (value) => value[0]).join('');
59
+
60
+ return w.indexOf(filterText) > -1 || firstLetter.indexOf(filterText) > -1;
61
+ }
62
+
63
+ export { pinyinFilter, pinyinMatch, pinyinMatchWithoutFirstLetter, pinyinMatchWithoutFullLetter };
@@ -1,2 +1,7 @@
1
+ export {
2
+ pinyinFilter,
3
+ pinyinMatch,
4
+ pinyinMatchWithoutFirstLetter,
5
+ pinyinMatchWithoutFullLetter,
6
+ } from './filter';
1
7
  export { pinyin } from './pinyin';
2
- export { pinyinFilter, pinyinMatch, pinyinMatchWithoutFirstLetter } from './filter';