| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 1× 1× 19× 17× 17× | 'use strict'
var R = /^(#{1,}|b{1,}|x{1,}|)$/
/**
* Given an accidentals string returns its alteration number
*
* @param {String} accidentals - the accidentals string
* @param {boolean} skipValidation - true to skip validation
*/
module.exports = function (str, skip) {
if (!skip && !R.exec(str)) return null
var alt = str.replace(/x/g, '##').length
return str[0] === '#' ? alt : -alt
}
|