Simple monitor for displaying MIDI status for digital pianos.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

22 líneas
551 B

  1. const NATURAL_KEYS = [0, 2, 4, 5, 7, 9, 11]
  2. interface IsNaturalKey {
  3. (k: number): boolean
  4. }
  5. const isNaturalKey: IsNaturalKey = (k: number): boolean => {
  6. const type = typeof (k as unknown)
  7. if ((type as string) !== 'number') {
  8. throw TypeError(`Invalid value type passed to isNaturalKey, expected 'number', got ${type}.`)
  9. }
  10. if (isNaN(k)) {
  11. throw RangeError('Value passed is NaN.')
  12. }
  13. if (k < 0) {
  14. throw RangeError('Value must be positive.')
  15. }
  16. return NATURAL_KEYS.includes(Math.floor(k) % 12)
  17. }
  18. export default isNaturalKey