How to use the node-persist.setItemSync 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 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))
    log.info(`scheduled: ${thisScheduledVal}`)
    log.info(`scheduled-settings-value: ${scheduleVal}`)
  }

  let j = schedule.scheduleJob(rule, () => {
    mainWindow.webContents.send('trigger-random-note')
  })

  j.on('scheduled', (event) => {
    storeSettings.setItemSync('scheduledRuntime', event)
    log.info(`scheduled: ${event}`)
    log.info(`scheduled-settings-value: ${scheduleVal}`)
  })

  j.on('run', (event) => {
github originallyus / node-red-contrib-alexa-local / index.js View on Github external
function setPortForLightId(lightId, value) 
    {
        var key = formatUUID(lightId);
        if (storage)
            storage.setItemSync(key, value);
    }
github komplexb / notifyer-electron / app / src / components / Settings.vue View on Github external
handleSave () {
        this.logChangedSettings()
        storeSettings.setItemSync('schedule', this.settings.schedule)
        storeSettings.setItemSync('openWith', this.settings.openWith)
        storeSettings.setItemSync('shortcutKey', this.settings.shortcutKey.join('+'))
        ipc.send('set-global-shortcuts', this.settings.shortcutKey.join('+'))
        ipc.send('reschedule-notes', this.settings.schedule)
        $('#settings').modal('hide')
      },
      logChangedSettings () {
github komplexb / notifyer-electron / app / electron.js View on Github external
function loadSettings () {
  for (const [key, value] of DEFAULT_SETTINGS) {
    if (storeSettings.getItemSync(key) === undefined || null || '') {
      storeSettings.setItemSync(key, value)
    }
  }
}
github fjn2 / one4all / server / classes / ClientsControl.js View on Github external
addAdmin(id) {
    Winston.info('ClientControls -> addAdmin', id);
    this.administrators.push(id);
    storage.setItemSync('administrators', this.administrators);
  }
  sendPlaylist({ songs, currentSong }) {
github owenconti / livecodingtv-bot / utils / Brain.js View on Github external
static set( key, value ) {
		brain.setItemSync( key, value );
	}
};
github originallyus / node-red-contrib-alexa-local / index.js View on Github external
function setLightBriForLightId(lightId, value) 
    {
        if (storage === null || storage === undefined) {
            RED.log.warn("storage is null in setLightBriForLightId");
            return null;
        }
        if (lightId === null || lightId === undefined) {
            RED.log.warn("lightId is null");
            return null;
        }

        var key = formatUUID(lightId) + "_bri";
        storage.setItemSync(key, value);
    }
github energychain / StromDAO-BusinessObject / StromDAONode.js View on Github external
setItemSync:function(key,value) {					
					return node_persist.setItemSync(key,value);
			}
		};
github NP-compete / Alternate-Authentication / Home / Gdrive / saveId.js View on Github external
function saveAccounts(accountName, accounts, masterPassword){
    try {
        var cipher = crypto.createCipher('aes-256-cbc', masterPassword);
        var encrypted = cipher.update(JSON.stringify(accounts), 'utf8', 'hex') + cipher.final('hex');
        storage.setItemSync(accountName, encrypted);
        return accounts;
    } catch (e) {
        throw new Error(e.message);
    }
}