/** * main storage object ... */ const windows = {}; /** * retrieve all exists window id's ... * * @returns an array of strings which represents window id's ... */ function keys() { return Object.keys(windows); } /** * retrieve all available windows ... * * @returns an array of strings which represent BrowserWindow Objects ... */ function values() { return Object.values(windows); } /** * retrieve count of available windows ... * * @returns number */ function count() { return Object.keys(windows).length; } /** * check a BrowserWindow id exists or not ... * * @param {string} key window id ... * @returns a boolean value which represent window exists or not ... */ function has(key) { // if (!key) { return false; } // return keys() .includes(key); } /** * retrieve a window by providing it's id ... * * @param {string} key window id ... * @returns an instance of Browserwindow instance ... */ function get(key) { // if (!has(key)) { return undefined; } // return windows[key]; } /** * set a window by it's id ... * * @param {string} key window id ... * @param {BrowserWindow} value specified window instance ... * @returns a boolean value ... */ function set(key, value) { // try { windows[key] = value; return true; } catch { return false; } } /** * remove a key/value from windows ... * * @param {string} key window id ... * @returns a boolean value ... */ function remove(key) { // if (!has(key)) { return false; } // try { // delete windows[key]; return true; } catch { return false; } } /** * clear all registered objects ... */ function clear() { windows = {}; } module.exports = { // windows: windows, // has: has, get: get, set: set, keys: keys, count: count, clear: clear, values: values, remove: remove, }