MCPcopy Create free account
hub / github.com/tree-sitter/tree-sitter-javascript / debounce

Function debounce

examples/text-editor-component.js:4345–4362  ·  view source on GitHub ↗
(fn, wait)

Source from the content-addressed store, hash-verified

4343}
4344
4345function debounce (fn, wait) {
4346 let timestamp, timeout
4347
4348 function later () {
4349 const last = Date.now() - timestamp
4350 if (last < wait && last >= 0) {
4351 timeout = setTimeout(later, wait - last)
4352 } else {
4353 timeout = null
4354 fn()
4355 }
4356 }
4357
4358 return function () {
4359 timestamp = Date.now()
4360 if (!timeout) timeout = setTimeout(later, wait)
4361 }
4362}
4363
4364class NodePool {
4365 constructor () {

Callers 1

constructorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…