Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

README.md 1.1KB

il y a 4 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ## Caseless -- wrap an object to set and get property with caseless semantics but also preserve caseing.
  2. This library is incredibly useful when working with HTTP headers. It allows you to get/set/check for headers in a caseless manner while also preserving the caseing of headers the first time they are set.
  3. ## Usage
  4. ```javascript
  5. var headers = {}
  6. , c = caseless(headers)
  7. ;
  8. c.set('a-Header', 'asdf')
  9. c.get('a-header') === 'asdf'
  10. ```
  11. ## has(key)
  12. Has takes a name and if it finds a matching header will return that header name with the preserved caseing it was set with.
  13. ```javascript
  14. c.has('a-header') === 'a-Header'
  15. ```
  16. ## set(key, value[, clobber=true])
  17. Set is fairly straight forward except that if the header exists and clobber is disabled it will add `','+value` to the existing header.
  18. ```javascript
  19. c.set('a-Header', 'fdas')
  20. c.set('a-HEADER', 'more', false)
  21. c.get('a-header') === 'fdsa,more'
  22. ```
  23. ## swap(key)
  24. Swaps the casing of a header with the new one that is passed in.
  25. ```javascript
  26. var headers = {}
  27. , c = caseless(headers)
  28. ;
  29. c.set('a-Header', 'fdas')
  30. c.swap('a-HEADER')
  31. c.has('a-header') === 'a-HEADER'
  32. headers === {'a-HEADER': 'fdas'}
  33. ```