all files / music-notation/lib/ props-to-arr.js

100% Statements 6/6
100% Branches 2/2
100% Functions 1/1
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20                          107× 107× 79×    
'use strict'
 
// map from pitch number to number of fifths and octaves
var BASES = [ [0, 0], [2, -1], [4, -2], [-1, 1], [1, 0], [3, -1], [5, -2] ]
 
/**
 * Get a pitch in array format from properties
 *
 * @name propsToArray
 * @function
 * @param {Array} prop - the pitch in property format
 * @return {Array} the pitch in array format
 * @private
 */
module.exports = function (p) {
  var base = BASES[p[0]]
  if (p.length === 2) return [base[0] + 7 * p[1]]
  return [p[3] * (base[0] + 7 * p[1]), p[3] * (p[2] + base[1] - 4 * p[1])]
}