UNPKG
@fluent/langneg
Version:
latest (0.7.0)
0.7.0
0.6.2
0.6.1
0.6.0
0.5.2
0.5.1
0.5.0
0.4.0
0.3.0
Language Negotiation API for Fluent
projectfluent.org
projectfluent/fluent.js
@fluent/langneg
/
esm
/
accepted_languages.js
8 lines
(7 loc)
•
268 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
export
function
acceptedLanguages
(
str =
""
) {
if
(
typeof
str !==
"string"
) {
throw
new
TypeError
(
"Argument must be a string"
); }
const
tokens = str.
split
(
","
).
map
(
t
=>
t.
trim
());
return
tokens.
filter
(
t
=>
t !==
""
).
map
(
t
=>
t.
split
(
";"
)[
0
]); }