Skip to content

v1.0.0

Latest

Choose a tag to compare

@cheton cheton released this 29 May 08:17
· 5 commits to master since this release
4eab324

Breaking Changes

  • Removed transform option

Enhancements

  • Adds support for mixing strings, arrays, functions, and objects in an array
const constants = require('namespace-constants');

export const {
    ADD_TODO,
    REMOVE_TODO,
    TOGGLE_TODO,
    SHOW_ALL,
    SHOW_COMPLETED,
    SHOW_ACTIVE,
    FETCH,
    EXPORT,
} = constants('ns', [
    'ADD_TODO',
    'REMOVE_TODO',
    'TOGGLE_TODO',

    // an array of strings
    ['SHOW_ALL', 'SHOW_COMPLETED', 'SHOW_ACTIVE'],

    // a function returning an array of strings
    () => (['SHOW_ALL', 'SHOW_COMPLETED', 'SHOW_ACTIVE']),

    { // Sugar syntax for declaring async constants
        FETCH: ['REQUEST', 'SUCCESS', 'FAILURE'],
        EXPORT: 'REQUEST'
    }
]);

will give you the following output:

image