Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Dec 20, 2024
1 parent 54b8930 commit ff429c2
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/headers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import Headers from '@mjackson/headers';
let headers = new Headers();

// Accept
headers.accept = { 'text/html': 1, 'text/*': 0.9 };
// or headers.accept = 'text/html,text/*;q=0.9';
headers.accept = 'text/html, text/*;q=0.9';

headers.accept.mediaTypes; // [ 'text/html', 'text/*' ]
Object.fromEntries(headers.accept.entries()); // { 'text/html': 1, 'text/*': 0.9 }
Expand All @@ -43,17 +42,15 @@ headers.accept.set('text/*', 0.8);
headers.get('Accept'); // 'text/html,text/plain;q=0.9,text/*;q=0.8'

// Accept-Encoding
headers.acceptEncoding = { gzip: 1, deflate: 0.8 };
// or headers.acceptEncoding = 'gzip, deflate;q=0.8';
headers.acceptEncoding = 'gzip, deflate;q=0.8';

headers.acceptEncoding.accepts('gzip'); // true
headers.acceptEncoding.accepts('br'); // false

headers.acceptEncoding.getPreferred(['gzip', 'deflate']); // 'gzip'

// Accept-Language
headers.acceptLanguage = { 'en-US': 1, en: 0.9 };
// or headers.acceptLanguage = 'en-US,en;q=0.9';
headers.acceptLanguage = 'en-US, en;q=0.9';

headers.acceptLanguage.languages; // [ 'en-us', 'en' ]
Object.fromEntries(headers.acceptLanguage.entries()); // { 'en-us': 1, en: 0.9 }
Expand Down

0 comments on commit ff429c2

Please sign in to comment.