@jswork/next-switch-value

1.0.0 • Public • Published

next-switch-value

Get value for switch/case condition or default.

version license size download

installation

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

apis

api params description
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.

/@jswork/next-switch-value/

    Package Sidebar

    Install

    npm i @jswork/next-switch-value

    Weekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    6.64 kB

    Total Files

    5

    Last publish

    Collaborators

    • afeiship
    • yujiao.luo