Permalink
Browse files

Add isThird

  • Loading branch information...
duivvv committed Dec 26, 2018
1 parent e7d199c commit b7b7b517ad528b6b7ca577a23b743d38827d4804
Showing with 63 additions and 0 deletions.
  1. +17 −0 README.md
  2. +15 −0 src/isThird/index.js
  3. +31 −0 src/isThird/test.js
@@ -598,6 +598,23 @@ console.log(isTone(getIntervals(['C3', 'D3'])[0]));
// > true;
```

#### + `isThird(interval):boolean`

Returns `true` if the interval is a third (diminished, minor, major or augmented) `(2, 3, 4, 5)`.

```js
import { getIntervals, isThird } from 'music-fns';
console.log(isThird(getIntervals(['C4', 'E4'])[0]));
// > true;
console.log(isThird(getIntervals(['A4', 'C4'])[0]));
// > true;
console.log(isThird(getIntervals(['C4', 'E#4'])[0]));
// > true;
```

#### + `isFifth(interval):boolean`

Returns `true` if the interval is a fifth (diminished, perfect or augmented) `(6, 7, 8)`.
@@ -0,0 +1,15 @@
import { MINOR_THIRD, MAJOR_THIRD } from '../constants/Interval/MinorMajor';
import {
AUGMENTED_THIRD,
DIMINISHED_THIRD
} from '../constants/Interval/AugmentedDiminished';

// @flow

const isThird = (interval: Interval) =>
interval === DIMINISHED_THIRD ||
interval === MINOR_THIRD ||
interval === MAJOR_THIRD ||
interval === AUGMENTED_THIRD;

export default isThird;
@@ -0,0 +1,31 @@
import isThird from './';

describe('isThird', () => {
it('should return true when interval is a diminished third', () => {
expect(isThird(2)).toBe(true);
});

it('should return true when interval is a minor third', () => {
expect(isThird(3)).toBe(true);
});

it('should return true when interval is a major third', () => {
expect(isThird(4)).toBe(true);
});

it('should return true when interval is a augmented third', () => {
expect(isThird(5)).toBe(true);
});

it('should return false when interval is not a third', () => {
expect(isThird(7)).toBe(false);
});

it('should return false when interval is not a third', () => {
expect(isThird(1)).toBe(false);
});

it('should return false on no input', () => {
expect(isThird()).toBe(false);
});
});

0 comments on commit b7b7b51

Please sign in to comment.