Index: lib/filterClasses.js |
=================================================================== |
--- a/lib/filterClasses.js |
+++ b/lib/filterClasses.js |
@@ -143,30 +143,34 @@ |
Filter.knownFilters.set(filter.text, filter); |
return filter; |
}; |
/** |
* Deserializes a filter |
* |
- * @param {Object} obj map of serialized properties and their values |
+ * @param {Map.<string,string>} map map of serialized properties and their |
+ * values |
* @return {Filter} filter or null if the filter couldn't be created |
*/ |
-Filter.fromObject = function(obj) |
+Filter.fromMap = function(map) |
{ |
- let filter = Filter.fromText(obj.text); |
+ let filter = Filter.fromText(map.get("text")); |
if (filter instanceof ActiveFilter) |
{ |
- if ("disabled" in obj) |
- filter._disabled = (obj.disabled == "true"); |
- if ("hitCount" in obj) |
- filter._hitCount = parseInt(obj.hitCount, 10) || 0; |
- if ("lastHit" in obj) |
- filter._lastHit = parseInt(obj.lastHit, 10) || 0; |
+ let disabled = map.get("disabled"); |
+ let hitCount = map.get("hitCount"); |
+ let lastHit = map.get("lastHit"); |
+ if (typeof disabled != "undefined") |
+ filter._disabled = (disabled == "true"); |
+ if (typeof hitCount != "undefined") |
+ filter._hitCount = parseInt(hitCount, 10) || 0; |
+ if (typeof lastHit != "undefined") |
+ filter._lastHit = parseInt(lastHit, 10) || 0; |
} |
return filter; |
}; |
/** |
* Removes unnecessary whitespaces from filter text, will only return null if |
* the input parameter is null. |
* @param {string} text |