How to use the cson.parse 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 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 zjhmale / vscode-idris / sync.js View on Github external
let toJSON = (text, name) => {
  let space = "\t"

  try {
    let parsed = CSON.parse(text)
    console.log(chalk.green.bold(`Translated ${name}`))
    return JSON.stringify(parsed, null, space)
  } catch (error) {
    console.log(chalk.red.bold(`Translate ${name} failed`))
    return null
  }
}
github jhanstra / snipster / commands / init / sync.js View on Github external
const syncSnippetsFromAtom = (userDirectory) => {
  let atomPreSnipsterMap = {}
  try {
    atomPreSnipsterMap = cson.parse(fs.readFileSync(os.homedir() + '/.atom/snippets.cson', 'utf-8'))
    write.sync(os.homedir() + '/.atom/snippets.cson.snipster-backup-' + Date.now(), fs.readFileSync(os.homedir() + '/.atom/snippets.cson', 'utf-8'))
  } catch(e) {
    console.log(chalk.red("Snipster tried to find your pre-existing Atom snippets, but the snippets file does not exist. Please check that you have Atom installed.\nIf you feel there is an error, please submit an issue to ") + chalk.yellow('https://github.com/jhanstra/snipster/issues.'))
  }
  let snippetFilesSynced = transferMapToSnipster(atomPreSnipsterMap, 'atom', userDirectory)
}
github HelloWorld017 / Nexodus / src / games / Battlerite.js View on Github external
isRoyale: +isRoyale
			}),

			{
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded',
					'Cookie': launcher.cookieText,
					'Referer': this.referer
				}
			}
		);

		const objMatch = startGameToken.match(/PS\.game\.startGame\(([^)]*)\)/);
		if(!objMatch) throw new ErrorServer();

		const startObject = CSON.parse(objMatch[1]);

		return {
			game: startObject.gameCode + ':0',
			arg: startObject.param
		};
	},
github ajaxorg / ace / tool / lib.js View on Github external
json = result[0];
        });
    } else {
        try {
            xmlOrJSON = xmlOrJSON.replace(
                /("(?:\\.|[^"])*")|(?:,\s*)+([\]\}])|(\w+)\s*:|([\]\}]\s*[\[\{])|(\/\/.*|\/\*(?:[^\*]|\*(?=[^\/]))*?\*\/)/g,
                function(_, str, extraComma, noQuote, missingComma, comment) {
                    if (comment)
                        return "";
                    if (missingComma)
                        return missingComma[0] + "," + missingComma.slice(1);
                    return str || extraComma || '"' + noQuote + '":';
            });
            json = JSON.parse(xmlOrJSON);
        } catch(e) {
            json = cson.parse(xmlOrJSON);
        }
    }
    callback && callback(json);
    return json;
};
github poooi / poi / fcd / build.js View on Github external
const validateShipTag = async () => {
  const file = await fs.readFile('shiptag.cson')
  const { data } = CSON.parse(file)

  const count = size(data.mapname)

  assert(count > 0)
  assert(size(data.color) === count)
  assert(size(data.fleetname['zh-CN']) === count)
  assert(size(data.fleetname['zh-TW']) === count)
  assert(size(data.fleetname['ja-JP']) === count)
  assert(size(data.fleetname['en-US']) === count)
}
github poooi / poi / fcd / build.js View on Github external
async function CSON2JSON(name) {
  const data = await fs.readFile(`${name}.cson`)
  await writeJSON(`${name}.json`, CSON.parse(data))
}
github aigis-styleguide / aigis / src / load_config_cson.js View on Github external
fs.readFile(configPath, "utf8", (err, file) =>{
      if (err) reject(err.message);
      var config = CSON.parse(file);
      resolve(config);
    });
  });
github aigis-styleguide / aigis / src2 / CommentModel.js View on Github external
parse(rule) {
    var reg = /-{3}[\s\S]+?-{3}/;
    var cson = rule.comment.match(reg)[0].replace(/---/g, "");
    var md = rule.comment.replace(reg, "");
    this.cson = CSON.parse(cson);
    this.md = md;
  }
  inject() {

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