duckfactory
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -25,3 +25,9 @@ 'use strict'; | ||
var takenActionNames = new _set2.default(); | ||
if (window) { | ||
if (!window.__takenActionNames__) { | ||
window.__takenActionNames__ = new _set2.default(); | ||
} | ||
} | ||
var takenActionNames = window ? window.__takenActionNames__ : new _set2.default(); | ||
var checkActionName = function checkActionName(actionName) { | ||
@@ -28,0 +34,0 @@ if (typeof actionName !== 'string' && typeof actionName !== 'number') { |
@@ -38,8 +38,26 @@ 'use strict'; | ||
var canLog = window && window.console; | ||
// -------------------------------------------------------------------- General helpers | ||
var buildPrefix = function buildPrefix(prefix) { | ||
if (prefix != null && typeof prefix !== 'string') { | ||
throw Error("Prefix must be null/undefined, or a string"); | ||
} | ||
if (prefix == null || prefix === "" || prefix === "/") { | ||
return ""; | ||
} | ||
if (prefix.slice(-1) === '/') { | ||
return prefix; | ||
} | ||
return prefix + "/"; | ||
}; | ||
var actionNum = 0; | ||
var getActionType = function getActionType(prefix, actionName) { | ||
return (prefix != null ? prefix : "") + (actionName == null || actionName === "" ? "" + actionNum++ : actionName); | ||
return buildPrefix(prefix) + (actionName == null || actionName === "" ? "" + actionNum++ : actionName); | ||
}; | ||
@@ -49,2 +67,3 @@ | ||
var actionArgumentNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var logBuilt = arguments[2]; | ||
return function () { | ||
@@ -59,3 +78,5 @@ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
}); | ||
console.log("New reducer action:", action); | ||
if (logBuilt) { | ||
console.log("New reducer action:", action); | ||
} | ||
return action; | ||
@@ -80,9 +101,8 @@ }; | ||
actionCreatorMap[actionName] = makeActionCreator(actionType, actionArgumentNames); | ||
actionCreatorMap[actionName] = makeActionCreator(actionType, actionArgumentNames, logBuilt); | ||
reducerMap[actionType] = reducerFunction; | ||
typeMap[actionName] = actionType; | ||
if (logBuilt && window.console) { | ||
console.log("\nActionCreator: getActionCreators()." + actionName + "(" + actionArgumentNames.join(", ") + ")"); | ||
console.log("\tType: getTypes()." + actionName + " = '" + actionType + "'"); | ||
if (logBuilt) { | ||
console.log("Reducer actionCreator: " + actionName + "(" + actionArgumentNames.join(", ") + ") " + "---> type: '" + actionType + "'"); | ||
} | ||
@@ -139,3 +159,3 @@ }); | ||
var _buildMaps = buildMaps(actionTypePrefix, actionAndReducerMap, checkAndWarn, logBuilt), | ||
var _buildMaps = buildMaps(actionTypePrefix, actionAndReducerMap, checkAndWarn, logBuilt && canLog), | ||
_buildMaps2 = (0, _slicedToArray3.default)(_buildMaps, 3), | ||
@@ -142,0 +162,0 @@ actionCreatorMap = _buildMaps2[0], |
{ | ||
"name": "duckfactory", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Factory for creating redux ducks", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13491
239