Wondering what’s next for npm?Check out our public roadmap! »

fetch-headers

2.0.0 • Public • Published

Fetch headers polyfill

https://developer.mozilla.org/en-US/docs/Web/API/Headers

Packed with latest and newest method from the spec: iterator, entries, keys, values, and support of for...of

const Headers = require('fetch-headers')
 
header = new Headers([
  ['accept', 'application/json']
  ['accept', 'text/plain']
])

Notes

This use

  • WeakMap for private properties
  • Symbol.iterator and Generators* for iteration
  • vanilla ecmascript 6
  • no transpiler
  • no coffeescript or typescript

Up to date node version can just use this as is. (tested in v6.5.0)
Browsers should run this through closer-compiler, babel, Babili, browserify, webpack or equivalent.
Browsers need to include a polyfill for WeakMap if necessary.

Optional for those who want es5 version and don't have the time or effort to compile can use the prebuilt version

var Headers = require('fetch-headers/headers-es5.min.js')

Install

npm i fetch-headers

DownloadsWeekly Downloads

9,671

Version

2.0.0

License

MIT

Last publish

Collaborators

  • avatar