lib/interval.js
function (interval) {
  var quality;
  var number;

  if (interval instanceof Interval) return interval;

  quality = interval.replace(/\d/g, ''); // Remove digits
  number = parseInt(interval.replace(/\D/g, ''), 10); // Remove non-digits

  if (!quality) { // No quality given, assume major or perfect
    quality = isPerfect(number) ? 'P' : 'M';
  }

  return new Interval(number, quality);
}
function (interval) {
  var quality;
  var number;

  if (interval instanceof Interval) return interval;

  quality = interval.replace(/\d/g, ''); // Remove digits
  number = parseInt(interval.replace(/\D/g, ''), 10); // Remove non-digits

  if (!quality) { // No quality given, assume major or perfect
    quality = isPerfect(number) ? 'P' : 'M';
  }

  return new Interval(number, quality);
}
function ( interval ) { var quality ; var number ; if ( interval instanceof Interval ) return interval ; quality = interval . replace ( / \d / g , '' ) ; // Remove digits number = parseInt ( interval . replace ( / \D / g , '' ) , 10 ) ; // Remove non-digits if ( ! quality ) { // No quality given, assume major or perfect quality = isPerfect ( number ) ? 'P' : 'M' ; } return new Interval ( number , quality ) ; }
Parse a string and return an interval object
Parse a string and return an interval object