How to use the noon.save function in noon

To help you get started, we’ve selected a few noon 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 scalarwaves / iloa / bin / tools.js View on Github external
  */exports.outFile=function(path,force,tofile){var match=path.match(/\.([a-z]*)$/i);var ext=match[1];var builder=new xml2js.Builder();if(ext==='xml'){if(checkOutfile(path)){if(force){var xml=builder.buildObject(tofile);var fd=fs.openSync(path,'w+');fs.writeSync(fd,xml);fs.closeSync(fd);console.log(chalk.white('Overwrote '+path+' with data.'));}else console.log(chalk.white(path+' exists, use -f to force overwrite.'));}else{var _xml=builder.buildObject(tofile);var _fd=fs.openSync(path,'w+');fs.writeSync(_fd,_xml);fs.closeSync(_fd);console.log(chalk.white('Wrote data to '+path+'.'));}}else if(ext==='cson'||ext==='json'||ext==='noon'||ext==='plist'||ext==='yml'||ext==='yaml'){if(checkOutfile(path)){if(force){noon.save(path,tofile);console.log(chalk.white('Overwrote '+path+' with data.'));}else console.log(chalk.white(path+' exists, use -f to force overwrite.'));}else{noon.save(path,tofile);console.log(chalk.white('Wrote data to '+path+'.'));}}else if(ext!=='xml'||ext!=='cson'||ext!=='json'||ext!=='noon'||ext!=='plist'||ext!=='yml'||ext!=='yaml')throw new Error('Format '+ext+' not supported.');};
github scalarwaves / leximaven / bin / tools.js View on Github external
  */exports.outFile=function(path,force,tofile){var match=path.match(/\.([a-z]*)$/i);var ext=match[1];var builder=new xml2js.Builder();if(ext==='xml'){if(checkOutfile(path)){if(force){var xml=builder.buildObject(tofile);var fd=fs.openSync(path,'w+');fs.writeSync(fd,xml);fs.closeSync(fd);console.log(chalk.white('Overwrote '+path+' with data.'));}else console.log(chalk.white(path+' exists, use -f to force overwrite.'));}else{var _xml=builder.buildObject(tofile);var _fd=fs.openSync(path,'w+');fs.writeSync(_fd,_xml);fs.closeSync(_fd);console.log(chalk.white('Wrote data to '+path+'.'));}}else if(ext==='cson'||ext==='json'||ext==='noon'||ext==='plist'||ext==='yml'||ext==='yaml'){if(checkOutfile(path)){if(force){noon.save(path,tofile);console.log(chalk.white('Overwrote '+path+' with data.'));}else console.log(chalk.white(path+' exists, use -f to force overwrite.'));}else{noon.save(path,tofile);console.log(chalk.white('Wrote data to '+path+'.'));}}else if(ext!=='xml'||ext!=='cson'||ext!=='json'||ext!=='noon'||ext!=='plist'||ext!=='yml'||ext!=='yaml')throw new Error('Format '+ext+' not supported.');};
github scalarwaves / leximaven / src / tools.js View on Github external
} else console.log(chalk.white(`${path} exists, use -f to force overwrite.`))
    } else {
      const xml = builder.buildObject(tofile)
      const fd = fs.openSync(path, 'w+')
      fs.writeSync(fd, xml)
      fs.closeSync(fd)
      console.log(chalk.white(`Wrote data to ${path}.`))
    }
  } else if (ext === 'cson' || ext === 'json' || ext === 'noon' || ext === 'plist' || ext === 'yml' || ext === 'yaml') {
    if (checkOutfile(path)) {
      if (force) {
        noon.save(path, tofile)
        console.log(chalk.white(`Overwrote ${path} with data.`))
      } else console.log(chalk.white(`${path} exists, use -f to force overwrite.`))
    } else {
      noon.save(path, tofile)
      console.log(chalk.white(`Wrote data to ${path}.`))
    }
  } else if (ext !== 'xml' || ext !== 'cson' || ext !== 'json' || ext !== 'noon' || ext !== 'plist' || ext !== 'yml' || ext !== 'yaml') throw new Error(`Format ${ext} not supported.`)
}
github scalarwaves / iloa / src / tools.js View on Github external
} else console.log(chalk.white(`${path} exists, use -f to force overwrite.`))
    } else {
      const xml = builder.buildObject(tofile)
      const fd = fs.openSync(path, 'w+')
      fs.writeSync(fd, xml)
      fs.closeSync(fd)
      console.log(chalk.white(`Wrote data to ${path}.`))
    }
  } else if (ext === 'cson' || ext === 'json' || ext === 'noon' || ext === 'plist' || ext === 'yml' || ext === 'yaml') {
    if (checkOutfile(path)) {
      if (force) {
        noon.save(path, tofile)
        console.log(chalk.white(`Overwrote ${path} with data.`))
      } else console.log(chalk.white(`${path} exists, use -f to force overwrite.`))
    } else {
      noon.save(path, tofile)
      console.log(chalk.white(`Wrote data to ${path}.`))
    }
  } else if (ext !== 'xml' || ext !== 'cson' || ext !== 'json' || ext !== 'noon' || ext !== 'plist' || ext !== 'yml' || ext !== 'yaml') throw new Error(`Format ${ext} not supported.`)
}
github scalarwaves / iloa / bin / tools.js View on Github external
    */exports.limitWolf=function(config){var c=config;var proceed=false;var reset=false;var stamp=new Date(c.wolf.date.stamp);var days=df.differenceInCalendarDays(new Date(),stamp);if(days<31){c.wolf.date.remain--;}else if(days>=31){reset=true;c.wolf.date.stamp=new Date().toJSON();c.wolf.date.remain=c.wolf.date.limit;c.wolf.date.remain--;}c.wolf.date.remain<=0?c.wolf.date.remain=0:proceed=true;noon.save(CFILE,c);return[c,proceed,reset];};/**
  * Wunderground's API limit check
github scalarwaves / leximaven / bin / tools.js View on Github external
  */exports.limitOnelook=function(config){var c=config;var proceed=false;var reset=false;var stamp=new Date(c.onelook.date.stamp);var hours=df.differenceInHours(new Date(),stamp);if(hours<24){c.onelook.date.remain--;}else if(hours>=24){reset=true;c.onelook.date.stamp=new Date().toJSON();c.onelook.date.remain=c.onelook.date.limit;c.onelook.date.remain--;}c.onelook.date.remain<=0?c.onelook.date.remain=0:proceed=true;noon.save(CFILE,c);return[c,proceed,reset];};/**
  * Datamuse's API limit check
github scalarwaves / leximaven / src / commands / wordmap.js View on Github external
exports.handler = (argv) => {
  tools.checkConfig(CFILE)
  let config = noon.load(CFILE)
  const userConfig = {
    wordmap: {
      limit: argv.l
    }
  }
  if (config.merge) config = _.merge({}, config, userConfig)
  if (argv.s && config.merge) noon.save(CFILE, config)
  if (argv.s && !config.merge) throw new Error("Can't save user config, set option merge to true.")
  const theme = themes.loadTheme(config.theme)
  if (config.verbose) themes.label(theme, 'down', 'Wordmap')
  const word = argv.word
  const l = argv.l
  let bin = ''
  let dirExists = null
  try {
    fs.statSync('bin/leximaven.js')
    dirExists = true
  } catch (e) {
    if (e.code === 'ENOENT') dirExists = false
  }
  dirExists ? bin = 'bin/leximaven.js' : bin = `${process.env.NODE_PATH}/leximaven/bin/leximaven.js`
  child.spawnSync('node', [bin, 'rbrain', 'combine', `-m${l}`, `${word}`], { stdio: 'inherit' })
  child.spawnSync('node', [bin, 'rbrain', 'info', `${word}`], { stdio: 'inherit' })
github scalarwaves / iloa / src / commands / wikipedia.js View on Github external
exports.handler = (argv) => {
  tools.checkConfig(CFILE)
  let config = noon.load(CFILE)
  const userConfig = {
    wiki: {
      intro: argv.i
    }
  }
  if (config.merge) config = _.merge({}, config, userConfig)
  if (argv.s && config.merge) noon.save(CFILE, config)
  if (argv.s && !config.merge) throw new Error("Can't save user config, set option merge to true.")
  const theme = themes.loadTheme(config.theme)
  if (config.verbose) themes.label(theme, 'down', 'Wikipedia')
  const wcont = []
  wcont.push(argv.query)
  if (argv._.length > 1) {
    for (let i = 0; i <= argv._ - 1; i++) {
      if (argv._[i] !== 'wp' && argv._[i] !== 'wiki' && argv._[i] !== 'wikipedia') wcont.push(argv._[i])
    }
  }
  let words = ''
  if (wcont.length > 1) {
    words = wcont.join('+')
  } else {
    words = wcont[0]
  }
github scalarwaves / iloa / src / commands / eol / hierarchy.js View on Github external
exports.handler = (argv) => {
  tools.checkConfig(CFILE)
  let config = noon.load(CFILE)
  const userConfig = {
    common: argv.m,
    synonym: argv.y,
    cachettl: argv.c,
    language: argv.g
  }
  if (config.merge) config = _.merge({}, config, userConfig)
  if (argv.s && config.merge) noon.save(CFILE, config)
  if (argv.s && !config.merge) throw new Error("Can't save user config, set option merge to true.")
  const theme = themes.loadTheme(config.theme)
  if (config.verbose) themes.label(theme, 'down', 'Encyclopedia of Life')
  const prefix = `http://eol.org/api/hierarchies/1.0/${argv.id}.json`
  const ucont = []
  ucont.push(`cachettl=${argv.c}`)
  ucont.push(`language=${argv.g}`)
  ucont.push(`key=${process.env.EOLKEY}`)
  const url = `${prefix}?${ucont.join('&')}`
  const tofile = {
    type: 'hierarchies',
    source: 'http://eol.org'
  }
  http({ url }, (error, response) => {
    if (!error && response.statusCode === 200) {
      const body = JSON.parse(response.body)

noon

no ordinary object notation

Unlicense
Latest version published 2 years ago

Package Health Score

42 / 100
Full package analysis

Popular noon functions