{"id":16746550,"url":"https://github.com/cheton/namespace-constants","last_synced_at":"2025-04-10T13:43:21.499Z","repository":{"id":57307654,"uuid":"60056012","full_name":"cheton/namespace-constants","owner":"cheton","description":"Namespacing Redux action type constant values.","archived":false,"fork":false,"pushed_at":"2019-08-27T11:45:06.000Z","size":18,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T00:00:14.801Z","etag":null,"topics":[],"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/cheton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":"cheton","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2016-05-31T03:39:41.000Z","updated_at":"2019-08-27T11:45:07.000Z","dependencies_parsed_at":"2022-09-09T16:30:09.585Z","dependency_job_id":null,"html_url":"https://github.com/cheton/namespace-constants","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheton%2Fnamespace-constants","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheton%2Fnamespace-constants/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheton%2Fnamespace-constants/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheton%2Fnamespace-constants/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheton","download_url":"https://codeload.github.com/cheton/namespace-constants/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248226328,"owners_count":21068183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-13T02:06:55.092Z","updated_at":"2025-04-10T13:43:21.479Z","avatar_url":"https://github.com/cheton.png","language":"JavaScript","funding_links":["https://opencollective.com/cheton"],"categories":[],"sub_categories":[],"readme":"# namespace-constants [![build status](https://travis-ci.org/cheton/namespace-constants.svg?branch=master)](https://travis-ci.org/cheton/namespace-constants) [![Coverage Status](https://coveralls.io/repos/github/cheton/namespace-constants/badge.svg?branch=master)](https://coveralls.io/github/cheton/namespace-constants?branch=master)\n\n[![NPM](https://nodei.co/npm/namespace-constants.png?downloads=true\u0026stars=true)](https://www.npmjs.com/package/namespace-constants)\n\nNamespacing Redux action type constant values.\n\n![image](https://user-images.githubusercontent.com/447801/58611444-acced780-82e1-11e9-9772-69cfaebcd679.png)\n\n## Installation\n\n```bash\nnpm install --save namespace-constants\n```\n\n## Examples\n\n### Global Constants\n\n```js\nimport constants from 'namespace-constants';\n\nexport const {\n    ADD_TODO,\n    REMOVE_TODO,\n    TOGGLE_TODO\n} = constants([\n    'ADD_TODO',\n    'REMOVE_TODO',\n    'TOGGLE_TODO'\n]);\n// {\n//   'ADD_TODO': 'ADD_TODO',\n//   'REMOVE_TODO': 'REMOVE_TODO'\n//   'TOGGLE_TODO': 'TOGGLE_TODO'\n// }\n```\n\n### Namespace Constants\n\n```js\nimport constants from 'namespace-constants';\n\nexport const {\n    ADD_TODO,\n    REMOVE_TODO,\n    TOGGLE_TODO\n} = constants('ns', [\n    'ADD_TODO',\n    'REMOVE_TODO',\n    'TOGGLE_TODO'\n]);\n// {\n//   'ADD_TODO': 'ns:ADD_TODO',\n//   'REMOVE_TODO': 'ns:REMOVE_TODO'\n//   'TOGGLE_TODO': 'ns:TOGGLE_TODO'\n// }\n```\n\n#### Use a custom separator\n\n```js\nexport const {\n    ADD_TODO,\n    REMOVE_TODO,\n    TOGGLE_TODO\n} = constants('ns', [\n    'ADD_TODO',\n    'REMOVE_TODO',\n    'TOGGLE_TODO'\n], { separator: '/' });\n// {\n//   'ADD_TODO': 'ns/ADD_TODO',\n//   'REMOVE_TODO': 'ns/REMOVE_TODO'\n//   'TOGGLE_TODO': 'ns/TOGGLE_TODO'\n// }\n```\n\n#### Pass constant values as an array of mixed types\n\n```js\nexport const {\n    ADD_TODO,\n    REMOVE_TODO,\n    TOGGLE_TODO,\n    SHOW_ALL,\n    SHOW_COMPLETED,\n    SHOW_ACTIVE,\n    FETCH,\n    EXPORT\n} = constants('ns', [\n    'ADD_TODO',\n    'REMOVE_TODO',\n    'TOGGLE_TODO',\n    ['SHOW_ALL', 'SHOW_COMPLETED', 'SHOW_ACTIVE'],\n    {\n      'FETCH': ['REQUEST', 'SUCCESS', 'FAILURE'],\n      'EXPORT': 'EXPORT'\n    }\n]);\n// {\n//   'ADD_TODO': 'ns:ADD_TODO',\n//   'REMOVE_TODO': 'ns:REMOVE_TODO',\n//   'TOGGLE_TODO': 'ns:TOGGLE_TODO',\n//   'SHOW_ALL': 'ns:SHOW_ALL',\n//   'SHOW_COMPLETED': 'ns:SHOW_COMPLETED',\n//   'SHOW_ACTIVE': 'ns:SHOW_ACTIVE',\n//   'FETCH': {\n//     'REQUEST': 'ns:FETCH.REQUEST',\n//     'SUCCESS': 'ns:FETCH.SUCCESS',\n//     'FAILURE': 'ns:FETCH.FAILURE'\n//   },\n//   'EXPORT': 'ns:EXPORT'\n// }\n```\n\n#### Pass constant values as an object of mixed types\n\n```js\nexport const {\n    ADD_TODO,\n    REMOVE_TODO,\n    TOGGLE_TODO,\n    SHOW_ALL,\n    SHOW_COMPLETED,\n    SHOW_ACTIVE,\n    FETCH,\n    EXPORT\n} = constants('ns', {\n    'ADD_TODO': 'ADD_TODO',\n    'REMOVE_TODO': 'REMOVE_TODO',\n    'TOGGLE_TODO': 'TOGGLE_TODO',\n    'SHOW_ALL': 'SHOW_ALL',\n    'SHOW_COMPLETED': 'SHOW_COMPLETED',\n    'SHOW_ACTIVE': 'SHOW_ACTIVE',\n    'FETCH': ['REQUEST', 'SUCCESS', 'FAILURE'],\n    'EXPORT': 'EXPORT'\n});\n// {\n//   'ADD_TODO': 'ns:ADD_TODO',\n//   'REMOVE_TODO': 'ns:REMOVE_TODO',\n//   'TOGGLE_TODO': 'ns:TOGGLE_TODO',\n//   'SHOW_ALL': 'ns:SHOW_ALL',\n//   'SHOW_COMPLETED': 'ns:SHOW_COMPLETED',\n//   'SHOW_ACTIVE': 'ns:SHOW_ACTIVE',\n//   'FETCH': {\n//     'REQUEST': 'ns:FETCH.REQUEST',\n//     'SUCCESS': 'ns:FETCH.SUCCESS',\n//     'FAILURE': 'ns:FETCH.FAILURE'\n//   },\n//   'EXPORT': 'ns:EXPORT'\n// }\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheton%2Fnamespace-constants","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheton%2Fnamespace-constants","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheton%2Fnamespace-constants/lists"}