Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@escapace/accept-language-parser
Advanced tools
Parses the accept-language header from an HTTP request and produces an array of language objects sorted by quality.
Parses the accept-language header from an HTTP request and produces an array of language objects sorted by quality.
npm install @escapace/accept-language-parser
import { parse } from '@escapace/accept-language-parser'
const languages = parse('en-GB,en;q=0.8')
console.log(languages)
Output will be:
;[
{
code: 'en',
region: 'GB',
quality: 1.0,
},
{
code: 'en',
region: undefined,
quality: 0.8,
},
]
Output is always sorted in quality order from highest -> lowest. As per the HTTP spec, omitting the quality value implies 1.0.
import { pick } from '@escapace/accept-language-parser'
const language = pick(['fr-CA', 'fr-FR', 'fr'], 'en-GB,en-US;q=0.9,fr-CA;q=0.7,en;q=0.8')
console.log(language)
Output will be:
'fr-CA'
The options
supports the loose
flag which allows partial matching on supported languages.
For example:
pick(['fr', 'en'], 'en-GB,en-US;q=0.9,fr-CA;q=0.7,en;q=0.8', {
loose: true,
})
Would return:
'fr'
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 langauges first, you should list it first as well.
For example:
;['fr-CA', 'fr']
FAQs
Parses the accept-language header from an HTTP request and produces an array of language objects sorted by quality.
The npm package @escapace/accept-language-parser receives a total of 486 weekly downloads. As such, @escapace/accept-language-parser popularity was classified as not popular.
We found that @escapace/accept-language-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.