@neocodemirror/svelte
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -217,21 +217,22 @@ import { defaultKeymap, indentWithTab } from '@codemirror/commands'; | ||
function throttle(func, threshold) { | ||
let lastArgs; | ||
let shouldWait = false; | ||
function timeoutFunction(self) { | ||
if (lastArgs) { | ||
func.apply(self, lastArgs); | ||
setTimeout(timeoutFunction, threshold, self); | ||
let last_args; | ||
let should_wait = false; | ||
function timeout_function(self) { | ||
if (last_args) { | ||
func.apply(self, last_args); | ||
setTimeout(timeout_function, threshold, self); | ||
last_args = null; | ||
return; | ||
} | ||
shouldWait = false; | ||
should_wait = false; | ||
} | ||
return function throttled(...args) { | ||
const self = this; | ||
if (shouldWait) { | ||
lastArgs = args; | ||
if (should_wait) { | ||
last_args = args; | ||
return; | ||
} | ||
func.apply(self, args); | ||
shouldWait = true; | ||
setTimeout(timeoutFunction, threshold, self); | ||
should_wait = true; | ||
setTimeout(timeout_function, threshold, self); | ||
}; | ||
@@ -238,0 +239,0 @@ } |
@@ -217,21 +217,22 @@ import { defaultKeymap, indentWithTab } from '@codemirror/commands'; | ||
function throttle(func, threshold) { | ||
let lastArgs; | ||
let shouldWait = false; | ||
function timeoutFunction(self) { | ||
if (lastArgs) { | ||
func.apply(self, lastArgs); | ||
setTimeout(timeoutFunction, threshold, self); | ||
let last_args; | ||
let should_wait = false; | ||
function timeout_function(self) { | ||
if (last_args) { | ||
func.apply(self, last_args); | ||
setTimeout(timeout_function, threshold, self); | ||
last_args = null; | ||
return; | ||
} | ||
shouldWait = false; | ||
should_wait = false; | ||
} | ||
return function throttled(...args) { | ||
const self = this; | ||
if (shouldWait) { | ||
lastArgs = args; | ||
if (should_wait) { | ||
last_args = args; | ||
return; | ||
} | ||
func.apply(self, args); | ||
shouldWait = true; | ||
setTimeout(timeoutFunction, threshold, self); | ||
should_wait = true; | ||
setTimeout(timeout_function, threshold, self); | ||
}; | ||
@@ -238,0 +239,0 @@ } |
{ | ||
"name": "@neocodemirror/svelte", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "Svelte Action to add codemirro to your apps 😉", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32227
873