Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 8a29370

Browse files
committed
Add docs about loose option
1 parent bb9133d commit 8a29370

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Output will be:
4343

4444
Output is always sorted in quality order from highest -> lowest. as per the http spec, omitting the quality value implies 1.0.
4545

46-
#### parser.pick(supportedLangugagesArray, acceptLanguageHeader)
46+
#### parser.pick(supportedLangugagesArray, acceptLanguageHeader, options = {})
4747

4848
*Alias*: parser.pick(supportedLanguagesArray, parsedAcceptLanguageHeader)
4949

@@ -61,7 +61,22 @@ Output will be:
6161
"fr-CA"
6262
```
6363

64-
__Running tests__
64+
The `options` currently supports only `loose` option that allows partial matching on supported languages. For example:
65+
66+
67+
```
68+
parser.pick(['fr', 'en'], 'en-GB,en-US;q=0.9,fr-CA;q=0.7,en;q=0.8');
69+
```
70+
71+
Would return:
72+
73+
```
74+
"fr"
75+
```
76+
77+
In loose mode the order of `supportedLanguagesArray` matters, as it is the first partially matching language that is returned. It means that if you want to pick more specific langauge first, you should list it first as well, for example: `['fr-CA', 'fr']`.
78+
79+
### Running test
6580
```
6681
npm install
6782
npm test

0 commit comments

Comments
 (0)