Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ruanyl/lookup-hans-pinyin
https://github.com/ruanyl/lookup-hans-pinyin
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/ruanyl/lookup-hans-pinyin
- Owner: ruanyl
- Created: 2017-02-21T22:14:25.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-02T11:30:41.000Z (almost 6 years ago)
- Last Synced: 2024-12-05T16:48:19.631Z (about 2 months ago)
- Language: TypeScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# look up hans by pinyin
```
npm i lookup-hans-pinyin --save
``````
import hansPinyinMatcher from 'lookup-hans-pinyin'const rawData = [
'中水渔业',
'中航重机',
'滨江集团',
'中远海特',
]test('should return matched strings', t => {
const matcher = hansPinyinMatcher(rawData)
t.deepEqual(matcher.lookup('zsyy'), ['中水渔业'])
t.deepEqual(matcher.lookup('ZSYY'), ['中水渔业'])
t.deepEqual(matcher.lookup('bjjt'), ['滨江集团'])
t.deepEqual(matcher.lookup('z'), ['中水渔业', '中航重机', '中远海特'])
t.deepEqual(matcher.lookup('zh'), ['中水渔业', '中航重机', '中远海特'])
t.deepEqual(matcher.lookup('jituan'), ['滨江集团'])
})
```