Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function generateActionNames(namespace, baseUrl) {
- const stages = ["REQUEST", "SUCCESS", "FAILURE"];
- const methods = ["GET", "ADD", "UPDATE", "DELETE"];
- const actionNames = doMagic(namespace, methods, method =>
- doMagic(method, stages, stage => stage)
- );
- return actionNames;
- }
- function doMagic(prefix, keys, makeValue) {
- return keys.reduce(
- (result, key) => ({
- ...result,
- [key.toLowerCase()]: makeValue(`${prefix}_${key}`)
- }),
- {}
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement