-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Add typescript definitions + Apply last eslint rules + Improve …
…JSDoc + Replace coverage provider
- Loading branch information
Showing
12 changed files
with
182 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: '@bamdadsabbagh/eslint-config', | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: codeclimate--onPush | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
codeclimate--onPush: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- run: yarn | ||
- uses: paambaati/[email protected] | ||
env: | ||
CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_REPORTER_ID }} | ||
with: | ||
coverageCommand: yarn test:coverage | ||
debug: true |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,51 @@ | ||
{ | ||
"name": "speed-to-semitones", | ||
"version": "1.3.0", | ||
"description": "Calculate semitones from audio speed", | ||
"keywords": [ | ||
"audio", | ||
"pitch", | ||
"speed", | ||
"tone", | ||
"tones", | ||
"semitone", | ||
"semitones", | ||
"semi-tone", | ||
"semi-tones", | ||
"semi" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/bamdadsabbagh/speed-to-semitones.git" | ||
}, | ||
"license": "MIT", | ||
"author": { | ||
"name": "Bamdad Sabbagh", | ||
"email": "[email protected]", | ||
"url": "https://bamdadsabbagh.com" | ||
}, | ||
"type": "module", | ||
"main": "src/index.js", | ||
"module": "src/index.js", | ||
"files": [ | ||
"src" | ||
], | ||
"scripts": { | ||
"jest": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", | ||
"test": "yarn jest && codecov", | ||
"package:reinstall": "rimraf node_modules && yarn", | ||
"package:sort": "npx sort-package-json" | ||
}, | ||
"jest": { | ||
"collectCoverage": true, | ||
"coverageDirectory": "./coverage/" | ||
}, | ||
"devDependencies": { | ||
"@bamdadsabbagh/eslint-config": "^2.0.13", | ||
"codecov": "^3.8.3", | ||
"cross-env": "^7.0.3", | ||
"jest": "^27.4.7", | ||
"rimraf": "^3.0.2" | ||
} | ||
"name": "speed-to-semitones", | ||
"version": "1.3.0", | ||
"description": "Calculate semitones from audio speed", | ||
"keywords": [ | ||
"audio", | ||
"pitch", | ||
"speed", | ||
"tone", | ||
"tones", | ||
"semitone", | ||
"semitones", | ||
"semi-tone", | ||
"semi-tones", | ||
"semi" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/bamdadsabbagh/speed-to-semitones.git" | ||
}, | ||
"license": "MIT", | ||
"author": { | ||
"name": "Bamdad Sabbagh", | ||
"email": "[email protected]", | ||
"url": "https://bamdadsabbagh.com" | ||
}, | ||
"type": "module", | ||
"main": "src/index.js", | ||
"module": "src/index.js", | ||
"files": [ | ||
"src" | ||
], | ||
"scripts": { | ||
"jest": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", | ||
"test": "yarn jest", | ||
"test:coverage": "yarn jest --coverage", | ||
"package:reinstall": "rimraf node_modules && yarn", | ||
"package:sort": "npx sort-package-json" | ||
}, | ||
"jest": { | ||
"collectCoverage": true, | ||
"coverageDirectory": "./coverage/" | ||
}, | ||
"devDependencies": { | ||
"@bamdadsabbagh/eslint-config": "^2.0.13", | ||
"codecov": "^3.8.3", | ||
"cross-env": "^7.0.3", | ||
"jest": "^27.4.7", | ||
"rimraf": "^3.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = { | ||
plugins: [ | ||
'@semantic-release/commit-analyzer', | ||
'@semantic-release/release-notes-generator', | ||
['@semantic-release/changelog', { | ||
changelogFile: 'CHANGELOG.md', | ||
}], | ||
['@semantic-release/npm', { | ||
npmPublish: true, | ||
}], | ||
'@semantic-release/github', | ||
['@semantic-release/git', { | ||
assets: [ | ||
'CHANGELOG.md', | ||
'package.json', | ||
], | ||
message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}', | ||
}], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare module 'speed-to-semitones' { | ||
export default function speedToSemitones (speed: number, digits?: number): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
/** | ||
* @function | ||
* @name speedToSemitones | ||
* @description calculate semitones from audio speed, normal speed is 1 | ||
* @param {number} speed - playback speed | ||
* @param {number} [digits=0] - number of digits to appear after the decimal point | ||
* value between 0 and 20 | ||
* truncated | ||
* @returns {string} semitones | ||
* Convert the audio playback speed to a number of semitones based on the chromatic scale. | ||
* Normal playback speed is 1.0, which is a pitch of 0 semitones. | ||
* | ||
* @param {number} speed | ||
* The audio playback speed. | ||
* @param {number} [digits=0] | ||
* The number of digits to truncate the result to. | ||
* Digits can not be lower than 0 and greater than 20. | ||
* @returns {string} | ||
* The semitones. | ||
*/ | ||
export default function speedToSemitones (speed, digits = 0) { | ||
export default function speedToSemitones(speed, digits = 0) { | ||
if (typeof speed !== 'number') { | ||
throw new TypeError('speed is not a number'); | ||
} | ||
|
||
if (typeof speed !== 'number') throw new TypeError ('speed parameter should be a number') | ||
if (typeof digits !== 'number') { | ||
throw new TypeError('digits is not a number'); | ||
} | ||
|
||
if (typeof digits !== 'number') throw new TypeError ('digits parameter should be a number') | ||
if (digits < 0 || digits > 20) { | ||
throw new TypeError('digits is out of range'); | ||
} | ||
|
||
if (digits < 0 || digits > 20) throw new TypeError ('digits parameter should be between 0 and 20') | ||
const semitones = 12 * (Math.log(speed) / Math.log(2)); | ||
|
||
const semitones = 12 * (Math.log (speed) / Math.log (2)) | ||
|
||
return semitones.toFixed (digits) | ||
|
||
} | ||
return semitones.toFixed(digits); | ||
} |
Oops, something went wrong.