UNPKG

tauri-settings

Version:

A user settings manager for Tauri inspired by electron-settings.

101 lines (100 loc) 3.61 kB
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 { has as invokeHas, has_cache, get as invokeGet, get_cache, set as invokeSet, set_cache } from '../utils/handlers'; /** * Checks whether a key exists in the settings. * @param key The key for the setting. Key supports dot notation. See https://github.com/harshkhandeparkar/tauri-settings#dot-notation. */ export function has(key, configId) { return __awaiter(this, void 0, void 0, function* () { try { return yield invokeHas(key, configId); } catch (e) { throw e; } }); } /** * Checks whether a key exists in the cached settings. * @param key The key for the setting. Key supports dot notation. See https://github.com/harshkhandeparkar/tauri-settings#dot-notation. */ export function hasCache(key, configId) { return __awaiter(this, void 0, void 0, function* () { try { return yield has_cache(key, configId); } catch (e) { throw e; } }); } /** * Get the value of a particular setting. * @param key The key for the setting. Key supports dot notation. See https://github.com/harshkhandeparkar/tauri-settings#dot-notation. * @returns The value of the setting */ export function get(key, configId) { return __awaiter(this, void 0, void 0, function* () { try { return yield invokeGet(key, configId); } catch (e) { throw e; } }); } /** * Get the value of a particular setting in the cached settings. * @param key The key for the setting. Key supports dot notation. See https://github.com/harshkhandeparkar/tauri-settings#dot-notation. * @returns The value of the setting */ export function getCache(key, configId) { return __awaiter(this, void 0, void 0, function* () { try { return yield get_cache(key, configId); } catch (e) { throw e; } }); } /** * Sets the value of a particular setting. * @param key The key for the setting. Key supports dot notation. See https://github.com/harshkhandeparkar/tauri-settings#dot-notation. * @param value The new value * @returns The entire settings object */ export function set(key, value, configId) { return __awaiter(this, void 0, void 0, function* () { try { yield invokeSet(key, value, configId); } catch (e) { throw e; } }); } /** * Sets the value of a particular setting in the cached settings. * @param key The key for the setting. Key supports dot notation. See https://github.com/harshkhandeparkar/tauri-settings#dot-notation. * @param value The new value * @returns The entire settings object */ export function setCache(key, value, configId) { return __awaiter(this, void 0, void 0, function* () { try { yield set_cache(key, value, configId); } catch (e) { throw e; } }); }