Create mirror objects from objects, arrays or comma-separated strings with zero dependencies.
npm install keymirror-js
const keyMirror = require('keymirror-js');
const myArr = [a, b, c];
const mirrored = keyMirror(myArr); // { a: 'a', b: 'b', c: 'c' }
const actions = [
'USER_LOGIN',
'USER_LOGOUT',
'CREATE_DOCUMENT',
'EDIT_DOCUMENT',
'DELETE_DOCUMENT',
'SHARE_DOCUMENT'
];
Output
{
USER_LOGIN: 'USER_LOGIN',
USER_LOGOUT: 'USER_LOGOUT',
CREATE_DOCUMENT: 'CREATE_DOCUMENT',
EDIT_DOCUMENT: 'EDIT_DOCUMENT',
DELETE_DOCUMENT: 'DELETE_DOCUMENT',
SHARE_DOCUMENT: 'SHARE_DOCUMENT'
}
const roles = {
ADMIN: 'admin',
REGULAR: 'regular',
};
Output
{
ADMIN: 'ADMIN',
REGULAR: 'REGULAR'
}
const subscriptions = 'basic, standard, premium';
Output
{
BASIC: 'BASIC',
STANDARD: 'STANDARD',
PREMIUM: 'PREMIUM'
}