https://github.com/afeiship/next-switch-value
Get value for switch/case condition or default.
https://github.com/afeiship/next-switch-value
case default hook next selector switch value
Last synced: 11 months ago
JSON representation
Get value for switch/case condition or default.
- Host: GitHub
- URL: https://github.com/afeiship/next-switch-value
- Owner: afeiship
- License: mit
- Created: 2020-09-16T02:11:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-22T04:06:21.000Z (over 5 years ago)
- Last Synced: 2025-01-06T08:08:47.239Z (about 1 year ago)
- Topics: case, default, hook, next, selector, switch, value
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# next-switch-value
> Get value for switch/case condition or default.
[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]
## installation
```bash
npm install -S @jswork/next-switch-value
```
## apis
| api | params | description |
| --- | ------ | ---------------------- |
| get | - | get the value in hooks |
## usage
```js
import NxSwitchValue from '@jswork/next-switch-value';
const svalue = new NxSwitchValue({
2: '参数错误',
3: '未知错误',
'-1': '用户取消',
'*': '服务端接口返回的错误',
'circle|rect|use|path': 'svg',
'div|span|ul|li': 'html',
});
// one2one
svalue.get('2') //参数错误
svalue.get('3') //未知错误
svalue.get('-1') //用户取消
// one2many
svalue.get('circle') // svg
svalue.get('rect') // svg
svalue.get('use') // svg
svalue.get('path') // svg
svalue.get('div') // html
svalue.get('span') // html
svalue.get('ul') // html
svalue.get('li') // html
// defautls
svalue.get(null) //服务端接口返回的错误
svalue.get(100) //服务端接口返回的错误
```
## license
Code released under [the MIT license](https://github.com/afeiship/next-switch-value/blob/master/LICENSE.txt).
[version-image]: https://img.shields.io/npm/v/@jswork/next-switch-value
[version-url]: https://npmjs.org/package/@jswork/next-switch-value
[license-image]: https://img.shields.io/npm/l/@jswork/next-switch-value
[license-url]: https://github.com/afeiship/next-switch-value/blob/master/LICENSE.txt
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-switch-value
[size-url]: https://github.com/afeiship/next-switch-value/blob/master/dist/next-switch-value.min.js
[download-image]: https://img.shields.io/npm/dm/@jswork/next-switch-value
[download-url]: https://www.npmjs.com/package/@jswork/next-switch-value