File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,34 @@ export function dasherize(string) {
2222 }
2323 } )
2424}
25+
26+ export function debounce ( func , wait , immediate ) {
27+ var timeout , result ;
28+
29+ var later = function ( context , args ) {
30+ timeout = null ;
31+ if ( args ) result = func . apply ( context , args ) ;
32+ } ;
33+
34+ var debounced = function ( ...args ) {
35+ if ( timeout ) clearTimeout ( timeout ) ;
36+ if ( immediate ) {
37+ var callNow = ! timeout ;
38+ timeout = setTimeout ( later , wait ) ;
39+ if ( callNow ) result = func . apply ( this , args ) ;
40+ } else {
41+ timeout = setTimeout ( function ( ) {
42+ func ( ...args ) ;
43+ } , wait ) ;
44+ }
45+
46+ return result ;
47+ } ;
48+
49+ debounced . cancel = function ( ) {
50+ clearTimeout ( timeout ) ;
51+ timeout = null ;
52+ } ;
53+
54+ return debounced ;
55+ }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import config from "./config.json"
77import * as PluginManagement from "./plugin-management"
88import { treeSitterWarning } from "./performance-monitor"
99import DOMStylesReader from "./dom-styles-reader"
10- import { debounce } from "underscore-plus"
10+ import { debounce } from "./deps/ underscore-plus"
1111
1212export { default as config } from "./config.json"
1313export * from "./plugin-management"
You can’t perform that action at this time.
0 commit comments