UNPKG

@e-group/redux-modules

Version:

eGroup team react-redux modules that share across projects.

25 lines (21 loc) 612 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getApiInfos; /** * Parse api action type to its method and processing type. * Example, * FETCH_GET_USER -> ['get', undefined] * FETCH_GET_USER_REQUEST -> ['get', 'request'] */ function getApiInfos(api) { let apiType; const array = api.split(/(?=[A-Z])/); const apiMethod = array[1]; apiType = array[array.length - 1].toLowerCase(); if (apiType !== 'request' && apiType !== 'cancel' && apiType !== 'success' && apiType !== 'failure') { apiType = undefined; } return [apiMethod, apiType]; }