How to use cson - 10 common examples

To help you get started, we’ve selected a few cson 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 liuderchi / atom-i18n / spec / validation.js View on Github external
it('fetches descriptive part of config-schema.js then compares keys of settings.cson with it', async () => {
        const neverShownDesciptionInSettingsPanelItems = [
          'core.customFileTypes',
          'core.disabledPackages',
          'core.themes',
          'editor.invisibles',   // NOTE shows only editor.invisibles.*
        ]    // NOTE Manually updated exceptional list from https://github.com/atom/settings-view/blob/master/lib/settings-panel.js#L339-L350

        const templateSettingsControls = CSON.load(path.join(__dirname, '../def/template', 'settings.cson'))
          .Settings.settings.controls.map(({ _id }) => _id)

        const axios = require('axios')
        const configURL = `https://raw.githubusercontent.com/atom/atom/${ATOM_VERSION}/src/config-schema.js`
        console.info(`fetching ${configURL}...`)

        const flattenSrcConfigKeys = await axios.get(configURL).then(({ data }) => {
          const srcConfig = eval(data)
          const keysWithoutDescriptionToKeep = [
            'core.autoHideMenuBar', // platform specific
          ]
          return Object.keys(flattenObj(srcConfig))
            .filter(key => key.search(/enum/g) === -1)
            .filter(key => key.search(/description$/g) !== -1)
            .concat(keysWithoutDescriptionToKeep)
            .map(key => key.replace(/\.properties/g, '').replace(/\.description/g, ''))
github simonknittel / discord-bot-api / src / modules / config.js View on Github external
function reload(callback) {
    config = CSON.load('./config.cson'); // Load the config from the config.cson
    events.emit('config reloaded');
    automaticReload(); // eslint-disable-line no-use-before-define
    if (callback) callback();
}
reload();
github viko16 / boost2fs / index.js View on Github external
async readNote (fileName) {
    const filePath = path.resolve(this.inputPath, 'notes', fileName)
    // Parses a CSON file into an Object
    const parsedObj = await cson.load(filePath)
    // Skip the deleted note
    if (parsedObj.isTrashed === true) return

    switch (parsedObj.type) {
      case NOTE_TYPE.MARKDOWN_NOTE:
        await this.parseMarkdownNote(parsedObj)
        break
      case NOTE_TYPE.SNIPPET_NOTE:
        await this.parseSnippetNote(parsedObj)
        break
      default:
        console.info('unhandle type: ', parsedObj.type)
        break
    }
  }
github simonknittel / discord-bot-api / src / modules / config.js View on Github external
function save(callback) {
    const csonString = CSON.createCSONString(config);

    fs.writeFile('./config.cson', csonString, (error) => {
        if (error) {
            console.log(chalk.red(error));
            console.log(''); // Empty line
            callback(error);
            return false;
        }

        callback();
    });
}
github poooi / poi / views / redux / info / quests.es View on Github external
export function reducer(state = initState, action, store) {
  const { type, postBody, body } = action
  switch (type) {
    //== Initialization. This takes place once every flash loading ==
    case '@@Response/kcsapi/api_get_member/require_info': {
      const admiralId = body.api_basic.api_member_id
      // Load static quest goal data
      let questGoals = {}
      try {
        questGoals = CSON.parseCSONFile(questGoalsPath)
      } catch (e) {
        console.warn('No quest goal data!')
      }
      // Load quest tracking of this account
      let records = {}
      try {
        records = CSON.parseCSONFile(questTrackingPath(admiralId))
        if (records && records.time) {
          records = outdateRecords(questGoals, records, records.time, Date.now())
        }
      } catch (e) {
        console.warn('No quest tracking data!')
      }
      delete records.time // Time is added ad-hoc upon saving
      return {
        ...state,
github poooi / poi / views / redux / info / quests.es View on Github external
const { type, postBody, body } = action
  switch (type) {
    //== Initialization. This takes place once every flash loading ==
    case '@@Response/kcsapi/api_get_member/require_info': {
      const admiralId = body.api_basic.api_member_id
      // Load static quest goal data
      let questGoals = {}
      try {
        questGoals = CSON.parseCSONFile(questGoalsPath)
      } catch (e) {
        console.warn('No quest goal data!')
      }
      // Load quest tracking of this account
      let records = {}
      try {
        records = CSON.parseCSONFile(questTrackingPath(admiralId))
        if (records && records.time) {
          records = outdateRecords(questGoals, records, records.time, Date.now())
        }
      } catch (e) {
        console.warn('No quest tracking data!')
      }
      delete records.time // Time is added ad-hoc upon saving
      return {
        ...state,
        records,
        questGoals,
        activeQuests: outdateActiveQuests(state.activeQuests, Date.now()),
      }
    }

    //== Daily update ==
github deepal / boostnote-github-sync / preprocessor / index.js View on Github external
/**
                 * 'rename' event represents a file create or delete. So we need to explicitely
                 * determine whether this is a file create or delete.
                 * https://nodejs.org/api/fs.html#fs_fs_watch_filename_options_listener
                */
                const isFile = (await getStat(changedFile)).isFile();

                if (!isFile) {
                    return this.logger.info(`path ${changedFile} is not a regular file. ignoring`);
                }
            }
            const fileContent = await readFile(changedFile);
            const fileChecksum = checksum(fileContent);

            if (ext === '.cson') {
                const data = cson.parse(fileContent.toString());
                if (data && data.isTrashed) {
                    // If the note was deleted from BoostNote, isTrashed is set to true.
                    return {
                        event: this.constants.events.FILE_DELETE,
                        file: changedFile
                    };
                }

                return {
                    event: this.constants.events.FILE_CREATE_OR_UPDATE,
                    file: changedFile,
                    type: data.type || this.constants.fileTypes.UNKNOWN,
                    raw: data,
                    checksum: fileChecksum
                };
            }
github bentonam / fakeit / packages / fakeit-format-cson / src / index.js View on Github external
return new Promise((resolve, reject) => {
        cson.parse(obj, {}, (err, result: Object) => {
          /* istanbul ignore next */
          if (err) {
            return reject(err)
          }
          resolve(result)
        })
      })
    },
github liuderchi / atom-i18n / lib / main.js View on Github external
constructor() {
    this.pref = { done: false }
    this.delay = this.delay.bind(this)
    this.customMenuI18n = this.customMenuI18n.bind(this)
    const LOCALE = atom.config.get('atom-i18n.locale')
    // BUG when running spec, LOCALE is not initialized
    if (!atom.config.get('atom-i18n.customMenuI18nPath')) {
      atom.config.set('atom-i18n.customMenuI18nPath', path.join(__dirname, '../def', 'custom_menu.cson'))
    }
    this.defM = CSON.load(path.join(__dirname, '../def', LOCALE, `menu_${process.platform}.cson`))
    this.defC = CSON.load(path.join(__dirname, '../def', LOCALE, 'context.cson'))
    this.defS = CSON.load(path.join(__dirname, '../def', LOCALE, 'settings.cson'))
    this.defA = CSON.load(path.join(__dirname, '../def', LOCALE, 'about.cson'))
    this.defW = CSON.load(path.join(__dirname, '../def', LOCALE, 'welcome.cson'))
  }
github liuderchi / atom-i18n / lib / main.js View on Github external
constructor() {
    this.pref = { done: false }
    this.delay = this.delay.bind(this)
    this.customMenuI18n = this.customMenuI18n.bind(this)
    const LOCALE = atom.config.get('atom-i18n.locale')
    // BUG when running spec, LOCALE is not initialized
    if (!atom.config.get('atom-i18n.customMenuI18nPath')) {
      atom.config.set('atom-i18n.customMenuI18nPath', path.join(__dirname, '../def', 'custom_menu.cson'))
    }
    this.defM = CSON.load(path.join(__dirname, '../def', LOCALE, `menu_${process.platform}.cson`))
    this.defC = CSON.load(path.join(__dirname, '../def', LOCALE, 'context.cson'))
    this.defS = CSON.load(path.join(__dirname, '../def', LOCALE, 'settings.cson'))
    this.defA = CSON.load(path.join(__dirname, '../def', LOCALE, 'about.cson'))
    this.defW = CSON.load(path.join(__dirname, '../def', LOCALE, 'welcome.cson'))
  }

cson

CoffeeScript-Object-Notation Parser. Same as JSON but for CoffeeScript objects.

Artistic-2.0
Latest version published 11 months ago

Package Health Score

66 / 100
Full package analysis