File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535 "prepack" : " bunchee" ,
3636 "test" : " vitest"
3737 },
38+ "dependencies" : {
39+ "lodash.debounce" : " ^4.0.8"
40+ },
3841 "devDependencies" : {
3942 "@biomejs/biome" : " 1.9.4" ,
4043 "@testing-library/react-hooks" : " 3.7.0" ,
Original file line number Diff line number Diff line change 1+ import debounce from "lodash.debounce" ;
12import { isNative } from "./NativeSpeechRecognition" ;
23import isAndroid from "./isAndroid" ;
3- import { browserSupportsPolyfills , concatTranscripts , debounce } from "./utils" ;
4+ import { browserSupportsPolyfills , concatTranscripts } from "./utils" ;
45
56export default class RecognitionManager {
67 constructor ( SpeechRecognition ) {
@@ -24,11 +25,9 @@ export default class RecognitionManager {
2425 this . setSpeechRecognition ( SpeechRecognition ) ;
2526
2627 if ( isAndroid ( ) ) {
27- this . updateFinalTranscript = debounce (
28- this . updateFinalTranscript ,
29- 250 ,
30- true ,
31- ) ;
28+ this . updateFinalTranscript = debounce ( this . updateFinalTranscript , 250 , {
29+ leading : true ,
30+ } ) ;
3231 }
3332 }
3433
Original file line number Diff line number Diff line change 1- const debounce = ( func , wait , immediate ) => {
2- let timeout ;
3- return function ( ) {
4- const context = this ;
5- const args = arguments ;
6- const later = function ( ) {
7- timeout = null ;
8- if ( ! immediate ) func . apply ( context , args ) ;
9- } ;
10- const callNow = immediate && ! timeout ;
11- clearTimeout ( timeout ) ;
12- timeout = setTimeout ( later , wait ) ;
13- if ( callNow ) func . apply ( context , args ) ;
14- } ;
15- } ;
16-
171const concatTranscripts = ( ...transcriptParts ) => {
182 return transcriptParts
193 . map ( ( t ) => t . trim ( ) )
@@ -87,7 +71,6 @@ const browserSupportsPolyfills = () => {
8771} ;
8872
8973export {
90- debounce ,
9174 concatTranscripts ,
9275 commandToRegExp ,
9376 compareTwoStringsUsingDiceCoefficient ,
Original file line number Diff line number Diff line change @@ -2128,6 +2128,13 @@ __metadata:
21282128 languageName : node
21292129 linkType : hard
21302130
2131+ " lodash.debounce@npm:^4.0.8 " :
2132+ version : 4.0.8
2133+ resolution : " lodash.debounce@npm:4.0.8"
2134+ checksum : 10c0/762998a63e095412b6099b8290903e0a8ddcb353ac6e2e0f2d7e7d03abd4275fe3c689d88960eb90b0dde4f177554d51a690f22a343932ecbc50a5d111849987
2135+ languageName : node
2136+ linkType : hard
2137+
21312138" log-symbols@npm:^6.0.0 " :
21322139 version : 6.0.0
21332140 resolution : " log-symbols@npm:6.0.0"
@@ -2619,6 +2626,7 @@ __metadata:
26192626 " @vitest/coverage-v8 " : " npm:3.0.8"
26202627 bunchee : " npm:6.4.0"
26212628 jsdom : " npm:26.0.0"
2629+ lodash.debounce : " npm:^4.0.8"
26222630 react : " npm:16.14.0"
26232631 react-dom : " npm:16.14.0"
26242632 react-test-renderer : " npm:16.14.0"
You can’t perform that action at this time.
0 commit comments