Timeouts for sync config

This commit is contained in:
Zef Hemel
2023-01-14 18:51:00 +01:00
parent d371f2f68a
commit e5276319e0
16 changed files with 225 additions and 70 deletions
-13
View File
@@ -1,7 +1,6 @@
import { SETTINGS_TEMPLATE } from "./settings_template.ts";
import { YAML } from "./deps.ts";
import { Space } from "./spaces/space.ts";
import { BuiltinSettings } from "../web/types.ts";
export function safeRun(fn: () => Promise<void>) {
fn().catch((e) => {
@@ -13,18 +12,6 @@ export function isMacLike() {
return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
}
export function throttle(func: () => void, limit: number) {
let timer: any = null;
return function () {
if (!timer) {
timer = setTimeout(() => {
func();
timer = null;
}, limit);
}
};
}
// TODO: This is naive, may be better to use a proper parser
const yamlSettingsRegex = /```yaml([^`]+)```/;