parses an http prefer header, aka rfc7240
npm install parse-prefer-headerParses an HTTP Prefer header, aka
RFC7240.
``js
const parsePreferHeader = require('parse-prefer-header');
const preferences = parsePreferHeader('respond-async, wait=300');
// preferences = { respondAsync: true, wait: '300' }
`
``
$ npm install parse-prefer-header
- Parses the HTTP Prefer header into a friendly JavaScript objectrespondAsync
- Normalizes tokens into JavaScript properties (e.g. )foo=";= ,;="
- Handles quoting correctly (e.g. becomes { foo: ';= ,;='})
- Supports token parameters
`typescript`
parsePreferHeader(preferHeader: string | string[]): { [key: string]: string | boolean }
Parses the Prefer header value, or an Array of such values, and returns an
object mapping each preference token to its value or true`.
See here for an explanation of
the initial set of preferences.