
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
namespace-constants
Advanced tools
Add namespace to Redux action type constants without name conflicts.
Namespacing Redux action type constant values.

npm install --save namespace-constants
import constants from 'namespace-constants';
export const {
ADD_TODO,
REMOVE_TODO,
TOGGLE_TODO
} = constants([
'ADD_TODO',
'REMOVE_TODO',
'TOGGLE_TODO'
]);
// {
// 'ADD_TODO': 'ADD_TODO',
// 'REMOVE_TODO': 'REMOVE_TODO'
// 'TOGGLE_TODO': 'TOGGLE_TODO'
// }
import constants from 'namespace-constants';
export const {
ADD_TODO,
REMOVE_TODO,
TOGGLE_TODO
} = constants('ns', [
'ADD_TODO',
'REMOVE_TODO',
'TOGGLE_TODO'
]);
// {
// 'ADD_TODO': 'ns:ADD_TODO',
// 'REMOVE_TODO': 'ns:REMOVE_TODO'
// 'TOGGLE_TODO': 'ns:TOGGLE_TODO'
// }
export const {
ADD_TODO,
REMOVE_TODO,
TOGGLE_TODO
} = constants('ns', [
'ADD_TODO',
'REMOVE_TODO',
'TOGGLE_TODO'
], { separator: '/' });
// {
// 'ADD_TODO': 'ns/ADD_TODO',
// 'REMOVE_TODO': 'ns/REMOVE_TODO'
// 'TOGGLE_TODO': 'ns/TOGGLE_TODO'
// }
export const {
ADD_TODO,
REMOVE_TODO,
TOGGLE_TODO,
SHOW_ALL,
SHOW_COMPLETED,
SHOW_ACTIVE,
FETCH,
EXPORT
} = constants('ns', [
'ADD_TODO',
'REMOVE_TODO',
'TOGGLE_TODO',
['SHOW_ALL', 'SHOW_COMPLETED', 'SHOW_ACTIVE'],
{
'FETCH': ['REQUEST', 'SUCCESS', 'FAILURE'],
'EXPORT': 'EXPORT'
}
]);
// {
// 'ADD_TODO': 'ns:ADD_TODO',
// 'REMOVE_TODO': 'ns:REMOVE_TODO',
// 'TOGGLE_TODO': 'ns:TOGGLE_TODO',
// 'SHOW_ALL': 'ns:SHOW_ALL',
// 'SHOW_COMPLETED': 'ns:SHOW_COMPLETED',
// 'SHOW_ACTIVE': 'ns:SHOW_ACTIVE',
// 'FETCH': {
// 'REQUEST': 'ns:FETCH.REQUEST',
// 'SUCCESS': 'ns:FETCH.SUCCESS',
// 'FAILURE': 'ns:FETCH.FAILURE'
// },
// 'EXPORT': 'ns:EXPORT'
// }
export const {
ADD_TODO,
REMOVE_TODO,
TOGGLE_TODO,
SHOW_ALL,
SHOW_COMPLETED,
SHOW_ACTIVE,
FETCH,
EXPORT
} = constants('ns', {
'ADD_TODO': 'ADD_TODO',
'REMOVE_TODO': 'REMOVE_TODO',
'TOGGLE_TODO': 'TOGGLE_TODO',
'SHOW_ALL': 'SHOW_ALL',
'SHOW_COMPLETED': 'SHOW_COMPLETED',
'SHOW_ACTIVE': 'SHOW_ACTIVE',
'FETCH': ['REQUEST', 'SUCCESS', 'FAILURE'],
'EXPORT': 'EXPORT'
});
// {
// 'ADD_TODO': 'ns:ADD_TODO',
// 'REMOVE_TODO': 'ns:REMOVE_TODO',
// 'TOGGLE_TODO': 'ns:TOGGLE_TODO',
// 'SHOW_ALL': 'ns:SHOW_ALL',
// 'SHOW_COMPLETED': 'ns:SHOW_COMPLETED',
// 'SHOW_ACTIVE': 'ns:SHOW_ACTIVE',
// 'FETCH': {
// 'REQUEST': 'ns:FETCH.REQUEST',
// 'SUCCESS': 'ns:FETCH.SUCCESS',
// 'FAILURE': 'ns:FETCH.FAILURE'
// },
// 'EXPORT': 'ns:EXPORT'
// }
MIT
FAQs
Add namespace to Redux action type constants without name conflicts.
We found that namespace-constants demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.