How to use the node-persist.getItemSync function in node-persist

To help you get started, we’ve selected a few node-persist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inbasic / turbo-download-manager / src / lib / electron / starter.js View on Github external
});
    mainWindow = new BrowserWindow({
      width: state.width,
      height: state.height,
      x: state.x,
      y: state.y,
      webPreferences: {
        // disable the same-origin policy
        webSecurity: false,
        // For security purpose, webview can only be used in BrowserWindows that have nodeIntegration enabled.
        nodeIntegration: true,
        preload: path.join(__dirname, 'preload.js')
      }
    });
    let props = {};
    let userAgent = storage.getItemSync('pref.electron.user-agent');
    if (userAgent) {
      props.userAgent = userAgent;
    }
    mainWindow.loadURL('file://' + __dirname + '/background.html', props);
    mainWindow.on('closed', () => mainWindow = null);
    state.manage(mainWindow);
  }
}
github komplexb / notifyer-electron / app / electron.js View on Github external
function scheduleRandomNote (scheduleVal = storeSettings.getItemSync('schedule')) {
  let rule

  if (scheduleVal === '*/5 * * * *') {
    rule = '*/5 * * * *' // every 5 minutes
  } else {
    rule = new schedule.RecurrenceRule()
    rule.dayOfWeek = [0, new schedule.Range(0, 7)]
    rule.hour = scheduleVal
    rule.minute = 0

    // it's impt to understand we're only logging time, not actually setting it
    // since the event doesn't do this for us the first time
    // we need an accurate value to determine missed schedules
    let thisScheduledVal = defineSchedule(scheduleVal)
    storeSettings.setItemSync('scheduledRuntime', thisScheduledVal)
    storeSettings.setItemSync('scheduledRuntimeLocal', thisScheduledVal.format(momentFormat))
github komplexb / notifyer-electron / app / electron.js View on Github external
electron.powerMonitor.on('resume', () => {
    // user should get notification if he wakes computer after schedule has passed
    let nextRuntime = storeSettings.getItemSync('scheduledRuntime')
    if (moment().isSameOrAfter(nextRuntime, 'hour')) {
      // schedule missed run now
      log.info(`missed schedule: ${nextRuntime}`)
      log.info(`run now: ${moment()}`)
      mainWindow.webContents.send('trigger-random-note')
    }

    // always refresh schedule
    log.info(`computer awake: refresh schedule for ${scheduledFor}`)
    rescheduleRandomNote(scheduledFor)
  })
})
github NP-compete / Alternate-Authentication / Home / OnPrem / onPremise.js View on Github external
function getAccounts(accountName,masterPassword){
    var encryptedAccounts = storage.getItemSync(accountName);
    var accounts = [];
    if(typeof encryptedAccounts !== 'undefined'){
        try{
            // let cipher = crypto.createDecipher('aes-256-cbc', masterPassword);
            // let decryptedAccounts = cipher.update(encryptedAccounts, 'hex', 'utf8') + cipher.final('utf8');
            // accounts = JSON.parse(decryptedAccounts);
            accounts = JSON.parse(encryptedAccounts);
        }catch(exception){
            throw exception;
        }
    }
    return accounts;
}
github covcom / 304CEM / labs / 2015 07 NodeJS Testing / 01 Unit Testing / weather / modules / weather.js View on Github external
function getData(city) {
	var data;
	if (storage.getItemSync(city)) {
		// CACHE FOUND
		data = storage.getItemSync(city);
		if (data.date < dayStr()) {
			// CACHE OUT OF DATE
			data = getLiveData(city);
			return saveData(city, data);
		} else {
			// CACHE UP TO DATE
			return storage.getItemSync(city);
		}
	} else {
		// NO CACHE
		data = getLiveData(city);
		return saveData(city, data);
	}
}
github slackapi / oauth-tutorial / index.js View on Github external
const getUserFullname = (team, user) => new Promise((resolve, reject) => {
  let oauthToken = storage.getItemSync(team);
  console.log(oauthToken);
  request.post('https://slack.com/api/users.info', {form: {token: oauthToken, user: user}}, function (error, response, body) {
    if (!error && response.statusCode == 200) {
      console.log(body);
      return resolve(JSON.parse(body).user.real_name);
    } else {
      return resolve('The user');
    }
  });
});
github bcongdon / github-label-notify / utils / watch_list.js View on Github external
exports.data = function() {
  storage.initSync();
  if (!storage.getItem('watch_list')){
    storage.setItem('watch_list', []);
  }
  return storage.getItemSync('watch_list');
}
github komplexb / notifyer-electron / app / electron.js View on Github external
function setGlobalShortcuts (shortcutKey = storeSettings.getItemSync('shortcutKey')) {
  globalShortcut.unregisterAll()

  globalShortcut.register(shortcutKey, () => {
    mainWindow.webContents.send('trigger-random-note')
  })
}
github originallyus / node-red-contrib-alexa-local / index.js View on Github external
function getLightStateForLightId(lightId) 
    {
        if (storage === null || storage === undefined) {
            RED.log.warn("storage is null in getLightStateForLightId");
            return null;
        }
        if (lightId === null || lightId === undefined) {
            RED.log.warn("lightId is null");
            return null;
        }

        var key = formatUUID(lightId) + "_state";
        var value = storage.getItemSync(key);
        if (value === null || value === undefined || value < 0 || value >= 65536) {
            //RED.log.warn("light state is null in storage");
            return null;
        }

        return value;
    }