code: function forAllChars(converter, fn, origbuf, len) {
      var buf = origbuf.slice(0, len);
      for (var i = 0; i < 0x100; i++) {
          buf[len-1] = i;
          var res = undefined;
          try {
              res = converter.convert(buf);
          } catch (e) {
              if (e.code == "EILSEQ") { // Invalid character sequence.
                  // Notify that this sequence is invalid.
                  //fn(false, buf);
              }
              else if (e.code == "EINVAL") { // Partial character sequence.
                  // Recurse deeper.
                  forAllChars(converter, fn, origbuf, len+1);
              }
              else
                  throw e;
          }
  
          // buf contains correct input combination. Run fn with input and converter output.
          fn(res != null, buf, res);
      }
  }
docs: Make all valid input combinations for a given encoding and call fn with it. fn(valid, input, output)