UNPKG

homebridge-flume

Version:

Homebridge plugin to integrate Flume devices into HomeKit.

22 lines 675 B
import fs from 'fs'; export const STORAGE_FILE_NAME = 'flume.json'; function readStorage(filePath) { if (!fs.existsSync(filePath)) { return {}; } const data = fs.readFileSync(filePath, 'utf-8'); return JSON.parse(data); } function writeStorage(filePath, storage) { fs.writeFileSync(filePath, JSON.stringify(storage, null, 2)); } export function safeGetItem(filePath, key) { const storage = readStorage(filePath); return storage[key] ?? null; } export function safeSetItem(filePath, key, value) { const storage = readStorage(filePath); storage[key] = value; writeStorage(filePath, storage); } //# sourceMappingURL=storage.js.map