JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 546544
  • Score
    100M100P100Q178559F
  • License MIT

Utilities for working with a Headers instance

Package Exports

  • headers-utils

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (headers-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Published version Build status

headers-utils

Utilities for working with a Headers instance.

Motivation

Various request issuing libraries expect a different format of headers. This library chooses the Headers instance as the middle-ground between server and client, and provides transformer functions to convert that instance to primitives, or vice-versa.

Getting started

$ npm install headers-utils

API

Conversion

  • headersToList: (h: Headers): Array<[string, string | string[]]>
  • headersToObject: (h: Headers): Record<string, string | string[]>
  • listToHeaders: (l: Array<[string, string | string[]]>): Headers
  • objectToHeaders: (o: Record<string, string | string[]>): Headers

Transformation

  • flattenHeadersList: (l: Array<[string, string | string[]]>): Array<string, string>
  • flattenHeadersObject: (o: Record<string, string | string[]>): Record<string, string>