{"id":15854262,"url":"https://github.com/afeiship/next-switch-value","last_synced_at":"2026-05-02T03:32:38.431Z","repository":{"id":57122824,"uuid":"295898946","full_name":"afeiship/next-switch-value","owner":"afeiship","description":"Get value for switch/case condition or default.","archived":false,"fork":false,"pushed_at":"2020-11-22T04:06:21.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-02T16:09:07.620Z","etag":null,"topics":["case","default","hook","next","selector","switch","value"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/afeiship.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-16T02:11:07.000Z","updated_at":"2020-11-22T04:06:23.000Z","dependencies_parsed_at":"2022-08-24T14:59:32.184Z","dependency_job_id":null,"html_url":"https://github.com/afeiship/next-switch-value","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/afeiship/next-switch-value","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fnext-switch-value","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fnext-switch-value/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fnext-switch-value/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fnext-switch-value/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afeiship","download_url":"https://codeload.github.com/afeiship/next-switch-value/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fnext-switch-value/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32522245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["case","default","hook","next","selector","switch","value"],"created_at":"2024-10-05T19:41:20.145Z","updated_at":"2026-05-02T03:32:38.413Z","avatar_url":"https://github.com/afeiship.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# next-switch-value\n\u003e Get value for switch/case condition or default.\n\n[![version][version-image]][version-url]\n[![license][license-image]][license-url]\n[![size][size-image]][size-url]\n[![download][download-image]][download-url]\n\n## installation\n```bash\nnpm install -S @jswork/next-switch-value\n```\n\n## apis\n| api | params | description            |\n| --- | ------ | ---------------------- |\n| get | -      | get the value in hooks |\n\n## usage\n```js\nimport NxSwitchValue from '@jswork/next-switch-value';\n\nconst svalue = new NxSwitchValue({\n  2: '参数错误',\n  3: '未知错误',\n  '-1': '用户取消',\n  '*': '服务端接口返回的错误',\n  'circle|rect|use|path': 'svg',\n  'div|span|ul|li': 'html',\n});\n\n// one2one\nsvalue.get('2') //参数错误\nsvalue.get('3') //未知错误\nsvalue.get('-1') //用户取消\n\n\n// one2many\nsvalue.get('circle') // svg\nsvalue.get('rect') // svg\nsvalue.get('use') // svg\nsvalue.get('path') // svg\n\nsvalue.get('div') // html\nsvalue.get('span') // html\nsvalue.get('ul') // html\nsvalue.get('li') // html\n\n\n// defautls\nsvalue.get(null) //服务端接口返回的错误\nsvalue.get(100) //服务端接口返回的错误\n```\n\n## license\nCode released under [the MIT license](https://github.com/afeiship/next-switch-value/blob/master/LICENSE.txt).\n\n[version-image]: https://img.shields.io/npm/v/@jswork/next-switch-value\n[version-url]: https://npmjs.org/package/@jswork/next-switch-value\n\n[license-image]: https://img.shields.io/npm/l/@jswork/next-switch-value\n[license-url]: https://github.com/afeiship/next-switch-value/blob/master/LICENSE.txt\n\n[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-switch-value\n[size-url]: https://github.com/afeiship/next-switch-value/blob/master/dist/next-switch-value.min.js\n\n[download-image]: https://img.shields.io/npm/dm/@jswork/next-switch-value\n[download-url]: https://www.npmjs.com/package/@jswork/next-switch-value\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafeiship%2Fnext-switch-value","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafeiship%2Fnext-switch-value","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafeiship%2Fnext-switch-value/lists"}