lib/note.js
function (name) {
  var octave = null;

  name = prepareNoteName(name);

  // Extract octave number if given
  if (/\d$/.test(name)) {
    octave = parseInt(name.slice(-1));
    name = name.slice(0, -1);
  } 

  // Throw an error for an invalid note name
  if (!(/^[A-Ga-g](bb|##|[b#n])?$/).test(name)) {
    throw new Error('Invalid note name:  ' + name);
  }

  return {
    letter: name[0].toUpperCase(),
    acc: name.slice(1) || 'n',
    octave: octave
  };
}
function (name) {
  var octave = null;

  name = prepareNoteName(name);

  // Extract octave number if given
  if (/\d$/.test(name)) {
    octave = parseInt(name.slice(-1));
    name = name.slice(0, -1);
  } 

  // Throw an error for an invalid note name
  if (!(/^[A-Ga-g](bb|##|[b#n])?$/).test(name)) {
    throw new Error('Invalid note name:  ' + name);
  }

  return {
    letter: name[0].toUpperCase(),
    acc: name.slice(1) || 'n',
    octave: octave
  };
}
function ( name ) { var octave = null ; name = prepareNoteName ( name ) ; // Extract octave number if given if ( / \d$ / . test ( name ) ) { octave = parseInt ( name . slice ( - 1 ) ) ; name = name . slice ( 0 , - 1 ) ; } // Throw an error for an invalid note name if ( ! ( / ^[A-Ga-g](bb|##|[b#n])?$ / ) . test ( name ) ) { throw new Error ( 'Invalid note name:  ' + name ) ; } return { letter : name [ 0 ] . toUpperCase ( ) , acc : name . slice ( 1 ) || 'n' , octave : octave } ; }
Parse a note name and return object with letter, accidental
Parse a note name and return object with letter accidental