lib/main.js
function makeSubfieldPairs(subfields1, subfields2, fn_comparator) {
      
      var pairs = [];

      if (subfields1.length === subfields2.length) {

        subfields2.forEach(function(subfield2) {          
          return subfields1.some(function(subfield1) {
            if (fn_comparator(subfield1, subfield2)) {
              
              pairs.push([subfield1, subfield2]);
              return true;
              
            }
          });
        });

      } else {
        throw new Error('Number of subfields are not equal');
      }

      return pairs;
      
    }
function makeSubfieldPairs(subfields1, subfields2, fn_comparator) {
      
      var pairs = [];

      if (subfields1.length === subfields2.length) {

        subfields2.forEach(function(subfield2) {          
          return subfields1.some(function(subfield1) {
            if (fn_comparator(subfield1, subfield2)) {
              
              pairs.push([subfield1, subfield2]);
              return true;
              
            }
          });
        });

      } else {
        throw new Error('Number of subfields are not equal');
      }

      return pairs;
      
    }
function makeSubfieldPairs ( subfields1 , subfields2 , fn_comparator ) { var pairs = [ ] ; if ( subfields1 . length === subfields2 . length ) { subfields2 . forEach ( function ( subfield2 ) { return subfields1 . some ( function ( subfield1 ) { if ( fn_comparator ( subfield1 , subfield2 ) ) { pairs . push ( [ subfield1 , subfield2 ] ) ; return true ; } } ) ; } ) ; } else { throw new Error ( 'Number of subfields are not equal' ) ; } return pairs ; }
Try to make a list of equal pairs from both subfield arrays using a comparator function
Try to make a list of equal pairs from both subfield arrays using a comparator function