-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession.js
More file actions
23 lines (22 loc) · 775 Bytes
/
session.js
File metadata and controls
23 lines (22 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
* Save session data to a timestamped JSON file
* @param {Object} sessionData - Session data to save
* @returns {Promise<string>} Filename of saved session
*/
export async function saveSession(sessionData) {
const fs = await import('fs/promises');
const filename = `metatron_session_${Date.now()}.json`;
await fs.writeFile(filename, JSON.stringify(sessionData, null, 2));
console.log(`💾 Session saved to ${filename}`);
return filename;
}
/**
* Load session data from a JSON file
* @param {string} filename - Path to session file
* @returns {Promise<Object>} Loaded session data
*/
export async function loadSession(filename) {
const fs = await import('fs/promises');
const data = await fs.readFile(filename, 'utf8');
return JSON.parse(data);
}