1.0.0 • Published 3 years ago

@jswork/next-switch-value v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

next-switch-value

Get value for switch/case condition or default.

version license size download

installation

npm install -S @jswork/next-switch-value

apis

apiparamsdescription
get-get the value in hooks

usage

import NxSwitchValue from '@feizheng/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.