Skip to content

Commit

Permalink
added a new parameter for audio method, with that parameter, no need …
Browse files Browse the repository at this point in the history
…to re-encode if Morse string is already present.
  • Loading branch information
ozdemirburak committed Mar 6, 2020
1 parent 18d4265 commit 99a5d04
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dist/morsify.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
var AudioContext = null;
var context = null;

var audio = function audio(text, opts) {
var audio = function audio(text, opts, morseString) {
if (AudioContext === null && typeof window !== 'undefined') {
AudioContext = window.AudioContext || window.webkitAudioContext;
context = new AudioContext();
}

var options = getOptions(opts);
var morse = encode(text, opts);
var morse = morseString || encode(text, opts);
var oscillator = context.createOscillator();
var gainNode = context.createGain();
var timeout;
Expand Down
2 changes: 1 addition & 1 deletion dist/morsify.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "morsify",
"version": "2.3.0",
"version": "2.3.1",
"description": "Morse code translator, Morse encoder and decoder which can also generate audio.",
"keywords": [
"morsify",
Expand Down
4 changes: 2 additions & 2 deletions src/morsify.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@
let AudioContext = null;
let context = null;

const audio = (text, opts) => {
const audio = (text, opts, morseString) => {

if (AudioContext === null && typeof window !== 'undefined') {
AudioContext = window.AudioContext || window.webkitAudioContext;
context = new AudioContext();
}

const options = getOptions(opts);
const morse = encode(text, opts);
const morse = morseString || encode(text, opts);
const oscillator = context.createOscillator();
const gainNode = context.createGain();

Expand Down

0 comments on commit 99a5d04

Please sign in to comment.