0.0.1 • Published 10 years ago

parse-attributes v0.0.1

Weekly downloads
411
License
MIT
Repository
github
Last release
10 years ago

parse-attributes Build Status Coverage Status

Parse attributes from xmlish strings like a boss

Install

npm install --save parse-attributes

Docs

Test-documentation generated with mocha's "doc" reporter.

Usage

var parseAttributes = require('parse-attributes');
console.log(parseAttributes('foo="bar" bar=baz boo=\'quux\' boolean'));

Outputs:

{
    "foo": "bar",
    "bar": "baz"
    "boo": "quux"
    "boolean": true
}

Things that break

The parser currently is not able to differentiate between escaped quotes and the ending quote. As soon as the same type of quote as the opening quote is found, the parser stops and takes takes everything in-between as value. This breaks valid JSON in attribute values.