I've created a lightweight library for handling input-output mappings by just using a configuration object as the map.Here's a snippet of the README:To create a direct mapping from an exact input to an exact output, use  a key-value assignment.var map = Wyld.Map({  5: 10});map.get(5); // returns 10To map multiple inputs to a single output based on whether or not the  input satisfies a condition, use keys in quotes and include the  relevant operator.var map = Wyld.Map({  '>10': 10,  '<5': 5});map.get(50); // returns 10map.get(2); // returns 5To have an output be a calculated operation on the input, just map to  a callback function.var map = Wyld.Map({  '>5': function(num){    return num/2;  }});map.get(5); // returns 5map.get(6); // returns 3map.get(20); // returns 10Here is the library code as it exists currently:/* wyld.js */(function() {  function Map(map) {    /*    Check if string contains one or more conditions.    */    function hasCondition(str) {      if (str.indexOf(&) > -1) {        return true;      }    }    /*    When given a string that possibly contains    one or more conditions, evaluate them.    */    function evaluateCondition(input, str, output) {      // Check for universal match      if (str === '*') {        return output;      }      // Check for multiple conditions      if (str.indexOf(&) == -1 ) {        // There is only one condition        // Get operator, if it exists        var operator = str.match(/[><=]+/)        // Check if we found an operator at all        if (operator.length > 0) {          operator = operator[0];        } else {          return null;        }        var value = parseInt(str.substring(operator.length));        // Check condition based on operator        switch(operator) {          case '>':            if (input > value) return output;          break;          case '<':            if (input < value) return output;          break;          case '>=':            if (input >= value) return output;          break;          case '<=':            if (input <= value) return output;          break;        }        // If we got to this point, then the condition failed        return null;      } else {        // There are multiple conditions        var conditions = str.split(&);        // Assume all conditions are satisfied        // until one is proven false        var all_satisfied = true;        // Loop through conditions in this string        for (i=0;i<conditions.length;i++) {          var rule = conditions[i];          var operator = rule.match(/[><=]+/)[0];          var value = parseInt(rule.substring(operator.length));          // Check condition based on operator          switch(operator) {            case '>':              if (input <= value) all_satisfied = false;            break;            case '<':              if (input >= value) all_satisfied = false;            break;            case '>=':              if (input < value) all_satisfied = false;            break;            case '<=':              if (input > value) all_satisfied = false;            break;          }        }        // If all conditions in string were satisfied        if (all_satisfied) {          return output;        } else {          return null;        }      }    }    /*    Retrieve output based on input    */    function get(num) {        var result = num;      // Loop through keys and evaluate any conditions found      for (var key in map) {        condition_result = evaluateCondition(parseInt(num), key, map[key]);        // If the result is not null, then the key was a condition that evaluated to true        if (condition_result !== null) {          result = condition_result;        }      }      // Override with last found direct mapping        if (map.hasOwnProperty(num)) {        result = map[num];      }      // Do callback if result is a function      if (result instanceof Function) {        result = result(parseInt(num));      }      return result;    }    /*    Return public functions    */    return {        get: get    };  }  /*  Create global Wyld object  */  window.Wyld = {    Map: Map  };})();Does anyone have any feedback on the idea, or have any suggestions for optimizing the performance or improving the evaluation of basic conditions strings?Here is the repository
Wyld: Lightweight Javascript tool for creating input-output mappings
javascript;performance;parsing