Skip to content

Commit

Permalink
Add alias for the old misspelled event stoped->stopped
Browse files Browse the repository at this point in the history
Also put a depreciation warning in the console.
  • Loading branch information
0x010C committed Nov 15, 2023
1 parent 673bc44 commit e466f06
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/LinguaRecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ class LinguaRecorder {
* @chainable
*/
on( event, handler ) {
// Create an alias for the old misspelled event 'stoped' -> 'stopped'
// see https://github.com/lingua-libre/LinguaRecorder/pull/4
// TODO: Remove this if statement at the next major version
if ( event === "stoped" ) {
event = "stopped";
console.warn( "[LinguaRecorder] .on('stoped',...) is deprecated. Please use .on('stopped',...) instead." );
}

// Register the event handler
if ( event in this._eventHandlers ) {
this._eventHandlers[ event ].push( handler );
}
Expand All @@ -199,6 +208,15 @@ class LinguaRecorder {
* @chainable
*/
off( event ) {
// Create an alias for the old misspelled event 'stoped' -> 'stopped'
// see https://github.com/lingua-libre/LinguaRecorder/pull/4
// TODO: Remove this if statement at the next major version
if ( event === "stoped" ) {
event = "stopped";
console.warn( "[LinguaRecorder] .off('stoped') is deprecated. Please use .off('stopped') instead." );
}

// Unregister all event handlers for this event
if ( event in this._eventHandlers ) {
this._eventHandlers[ event ] = [];
}
Expand Down

0 comments on commit e466f06

Please sign in to comment.