code: function variants(sequence, cb) {
          if (sequence.length === 2) {
              cb(sequence);
              cb(sequence[1] + sequence[0]);
          } else if (sequence.length > 2) {
              for(var i = 0; i < sequence.length; i++) {
                  (function(sequence, ch) {
                      variants(sequence, function(v) {
                          cb(ch + v);
                      });
                  })(sequence.substring(0, i) + sequence.substring(i+1), sequence[i]);
              }
          } else {
              cb(sequence);
          }
      }
docs: Build all possible combination of the characters set:
  "abc" ->   abc, acb, bac, bca, cab, cba
  @param  {String}   sequence character set
  @param  {Function} cb  called for every new unique characters
  sequence