tauri-settings
Version:
A user settings manager for Tauri inspired by electron-settings.
56 lines (55 loc) • 2.51 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { invoke } from '@tauri-apps/api';
export function add_config(config, defaultSettings) {
return __awaiter(this, void 0, void 0, function* () {
return yield invoke('plugin:settings|add_config', { config: Object.assign(Object.assign({}, config), { file_name: `${config.file_name}.json` }), defaultSettings });
});
}
export function has(key, configId) {
return __awaiter(this, void 0, void 0, function* () {
return yield invoke('plugin:settings|has', { key, configId });
});
}
export function has_cache(key, configId) {
return __awaiter(this, void 0, void 0, function* () {
return yield invoke('plugin:settings|has_cache', { key, configId });
});
}
export function get(key, configId) {
return __awaiter(this, void 0, void 0, function* () {
return yield invoke('plugin:settings|get', { key, configId });
});
}
export function get_cache(key, configId) {
return __awaiter(this, void 0, void 0, function* () {
return yield invoke('plugin:settings|get_cache', { key, configId });
});
}
export function set(key, value, configId) {
return __awaiter(this, void 0, void 0, function* () {
return yield invoke('plugin:settings|set', { key, value, configId });
});
}
export function set_cache(key, value, configId) {
return __awaiter(this, void 0, void 0, function* () {
return yield invoke('plugin:settings|set_cache', { key, value, configId });
});
}
export function cache_to_file(configId) {
return __awaiter(this, void 0, void 0, function* () {
return yield invoke('plugin:settings|cache_to_file', { configId });
});
}
export function file_to_cache(configId) {
return __awaiter(this, void 0, void 0, function* () {
return yield invoke('plugin:settings|file_to_cache', { configId });
});
}