How to use the cson.parseCSONFile function in cson

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 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 firstandthird / load-grunt-config / lib / readfile.js View on Github external
throw new Error(file + ' doesn\'t exist');
    }

    var ext = path.extname(file);

    // YAML file
    if (ext.match(/ya?ml/)) {
        var res = fs.readFileSync(file, 'utf8');
        var yaml = require('js-yaml');
        return yaml.safeLoad(res, { schema: yaml.DEFAULT_FULL_SCHEMA });
    }

    // CSON file
    if (ext.match(/cson/)) {
        var cson = require('cson');
        return cson.parseCSONFile(file);
    }

    // JS / JSON / CoffeeScript
    if (ext.match(/json|js|coffee|ls/)) {
        if (!path.isAbsolute(file)) {
            file = path.join(process.cwd(), file);
        }
        return require(file);
    }

    // unknown
    throw new Error(file + ' is an unsupported filetype');

};
github poooi / poi / lib / config.es View on Github external
constructor() {
    super()
    this.configData = {}
    try {
      fs.accessSync(configPath, fs.R_OK | fs.W_OK)
      this.configData = mergeConfig(defaultConfig, CSON.parseCSONFile(configPath))
      dbg.log(`Config loaded from: ${configPath}`)
    } catch (e) {
      dbg.log(e)
    }
    this.defaultConfigData = defaultConfig
  }
github hakatashi / kyujitai.js / Gruntfile.js View on Github external
grunt.registerTask('data', 'build kyujitai.json', function () {
		var done = this.async();
		var CSON = require('cson');
		var fs = require('fs');
		var data = {
			douon: CSON.parseCSONFile('data/douon.cson'),
			kyuji: CSON.parseCSONFile('data/kyuji.cson'),
			exclude: CSON.parseCSONFile('data/exclude.cson')
		};

		fs.writeFile('data/kyujitai.json', JSON.stringify(data), done);
		grunt.log.writeln('created data/kyujitai.json');
	});
};
github paulredmond / atom-larasnippets / docs.js View on Github external
files.forEach(file => {
    var fileName = path.parse(file).base;
    var parsed = cson.parseCSONFile(file);

    Object.keys(parsed).forEach(key => {
      Object.keys(parsed[key]).forEach(title => {
        var s = parsed[key][title];
        snippets.push(new Snippet(title, s.body, s.prefix, fileName, key));
      });
    });
  });
github hakatashi / kyujitai.js / Gruntfile.js View on Github external
grunt.registerTask('data', 'build kyujitai.json', function () {
		var done = this.async();
		var CSON = require('cson');
		var fs = require('fs');
		var data = {
			douon: CSON.parseCSONFile('data/douon.cson'),
			kyuji: CSON.parseCSONFile('data/kyuji.cson'),
			exclude: CSON.parseCSONFile('data/exclude.cson')
		};

		fs.writeFile('data/kyujitai.json', JSON.stringify(data), done);
		grunt.log.writeln('created data/kyujitai.json');
	});
};
github hakatashi / kyujitai.js / Gruntfile.js View on Github external
grunt.registerTask('data', 'build kyujitai.json', function () {
		var done = this.async();
		var CSON = require('cson');
		var fs = require('fs');
		var data = {
			douon: CSON.parseCSONFile('data/douon.cson'),
			kyuji: CSON.parseCSONFile('data/kyuji.cson'),
			exclude: CSON.parseCSONFile('data/exclude.cson')
		};

		fs.writeFile('data/kyujitai.json', JSON.stringify(data), done);
		grunt.log.writeln('created data/kyujitai.json');
	});
};

cson

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

Artistic-2.0
Latest version published 4 months ago

Package Health Score

73 / 100
Full package analysis