🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

parse-formats

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-formats

Methods for synchronously parsing various data formats to JS objects.

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

parse-formats

Provides a list of various modules to parse data formats synchronously to JS objects.

Feel free to suggest more formats or more modules to parse them with via issue or pull request.

NPM


/* Common patterns */
function parse (parser, data, opts) {
	return parser.parse(data, opts);
}

function self (parser, data, opts) {
	return parser(data, opts);
}


/* { ext: { moduleName: function(module, data, opts) } } */
module.exports = {
	'.cson':  { 'cson-parser': parse },
	'.csv':   {
		'parser-csv': function (parser, data, opts) {
			return parser.parseSync(data, opts);
		},
	},
	'.hjson': { 'hjson': parse },
	'.ini':   { 'ini': parse },
	'.json':  {
		'strip-json-comments': function (stripComments, data) {
			return JSON.parse(stripComments(data));
		},
		'path': function (_, data) {
			return JSON.parse(data);
		},
	},
	'.json5': { 'json5': parse },
	'.xml': {
		'xml2json': function (xml2json, data, opts) {
			return JSON.parse(xml2json.toJson(data, opts));
		},
	},
	'.yaml': { 'js-yaml': jsYaml },
	'.yml':  { 'js-yaml': jsYaml },
};

function jsYaml (jsYaml, data, opts) {
	return jsYaml.load(data, opts);
}

Keywords

cson

FAQs

Package last updated on 22 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts