Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const fromName = (str) => {
if (!isStr(str)) return null
var p = str.split(/\s+/)
switch (p.length) {
case 1: return isNoteStr(p[0]) ? build(p[0], 'major')
: isModeStr(p[0]) ? build(false, p[0]) : null
case 2: return build(p[0], p[1])
default: return null
}
}
var fromName = function fromName(str) {
if (!tonalPitches.isStr(str)) return null;
var p = str.split(/\s+/);
switch (p.length) {
case 1:
return tonalPitches.isNoteStr(p[0]) ? build(p[0], 'major') : isModeStr(p[0]) ? build(false, p[0]) : null;
case 2:
return build(p[0], p[1]);
default:
return null;
}
};
function build(tonic, mode) {
if (!tonalPitches.isStr(mode)) return null;
var m = mode.trim().toLowerCase();
if (!isModeStr(m)) return null;
var t = tonalNotes.pc(tonic) || false;
var n = t ? t + ' ' + m : null;
return { name: n, tonic: t, mode: m };
}
export function build (tonic, mode) {
if (!isStr(mode)) return null
var m = mode.trim().toLowerCase()
if (!isModeStr(m)) return null
var t = pc(tonic) || false
var n = t ? t + ' ' + m : null
return { name: n, tonic: t, mode: m }
}