0.1.0 • Published 6 years ago
structured-header v0.1.0
Structured Header parser for Javascript
This library is a parser for the structured header specification. Currently it's still a draft, so this package is also in alpha until the specification stabilizes as a RFC.
Installation
Using npm:
npm install structured-header
Using Yarn:
yarn add structured-header
API
The library exposes 3 functions, and they're used as such:
var header = require('structured-header');
header.parseDictionary('foo=1.23, en="Applepie", da=*w4ZibGV0w6ZydGUK*');
// Returns { foo: 1.23, en: 'Applepie', da: new Buffer('...') };
header.parseList('foo, bar, baz_45');
// Returns ['foo', 'bar', 'baz_45'];
header.parseParameterizedList('abc_123;a=1;b=2; c, def_456, ghi;q="19";r=foo');
// Returns [
// [ 'abc_123', { a: 1, b: 2, c: null } ],
// [ 'def_456', {} ],
// [ 'ghi', { q: '19', r: 'foo' } ]
// ]
Browser support
There is a minified version of this library in the dist/
directory. This minified
file will expose a global variable called 'structuredHeader' which contains the rest
of the api.