UNPKG

tmemory

Version:

A terminal-based Memory card game built with React Ink. Features multiple grid sizes, AI opponent, and high scores.

32 lines (31 loc) 827 B
import Conf from 'conf'; // Initialize Conf for device settings const deviceConfig = new Conf({ projectName: 'tmemory-device', schema: { deviceId: { type: 'string', default: '', }, }, }); /** * Generates a random device ID if one doesn't exist * @returns The device ID */ export const getDeviceId = () => { let deviceId = deviceConfig.get('deviceId'); if (!deviceId) { // Generate a random device ID deviceId = `tmem-${Math.random().toString(36).substring(2, 10)}-${Date.now().toString(36)}`; deviceConfig.set('deviceId', deviceId); } return deviceId; }; /** * Checks if the device has a stored ID * @returns True if the device has an ID */ export const hasDeviceId = () => { return Boolean(deviceConfig.get('deviceId')); };