Registry / http-networking / acc-lang-parser

acc-lang-parser

JSON →
library1.0.4jsnpmunverified

A simple parser for HTTP Accept-Language headers in Node.js. Version 1.0.4 (last released in 2016) extracts the first language or all language ranges from a header string. Returns objects with 'language' and 'locale' fields. Unlike more modern alternatives like 'accept-language-parser', this package has limited features, no TypeScript support, and is unmaintained. It was originally published under the npm name 'parse-acc-lang' (now deprecated) and later republished as 'acc-lang-parser'.

npm install acc-lang-parser
INSTALL
IMPORT
SIG · ACC-LANG-PARSER
A
acc-lang-parser
http-networkingjavascriptv1.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse-acc-lang
const parser = require('parse-acc-lang');
import parser from 'parse-acc-lang';
This package is CommonJS-only, does not support ESM imports. The npm package name is 'acc-lang-parser' but the require path string is 'parse-acc-lang' (the old name).
extractFirstLang
const result = parser.extractFirstLang('de-DE');
Returns a single object with language and locale, or null if invalid input.
extractAllLangs
const results = parser.extractAllLangs('de-DE, en-GB');
const results = parser.extractAllLangs('de-DE, en-GB', { strict: true });
Returns an array of objects. No options parameter is supported.

Parses an Accept-Language header to get the first language and all languages.

const parser = require('parse-acc-lang'); const header = 'de-DE, en-GB;q=0.9, fr;q=0.8'; const first = parser.extractFirstLang(header); console.log(first); // { language: 'de', locale: 'DE' } const all = parser.extractAllLangs(header); console.log(all); // [ // { language: 'de', locale: 'DE' }, // { language: 'en', locale: 'GB' }, // { language: 'fr', locale: '' } // ]
Debug
Known issues
breakingPackage name mismatch: npm package is 'acc-lang-parser' but require path uses 'parse-acc-lang'.
fix
Use require('parse-acc-lang') in code, not require('acc-lang-parser').
affects: >=1.0.0
deprecatedNo TypeScript definitions available.
fix
Create your own .d.ts file or use a modern alternative with TypeScript support.
affects: >=1.0.0
gotchaIf extracted language tag has no locale (e.g., 'fr'), the locale field is an empty string ''.
fix
Check for empty locale string before use.
affects: >=1.0.0
gotchaQuality values (q=) are ignored; the parser does not sort by weight.
fix
Use a more complete parser like 'accept-language-parser' if you need quality weighting.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'parse-acc-lang'
Using require('acc-lang-parser') instead of require('parse-acc-lang').
fix
Use require('parse-acc-lang') in your code, even though the npm package name is 'acc-lang-parser'.
TypeError: parser.extractFirstLang is not a function
Incorrect import path or using a different package version.
fix
Ensure you require('parse-acc-lang') and that the module exports the correct functions.
Expected an object but got undefined
Input header is null, undefined, or an empty string.
fix
Pass a valid Accept-Language header string. For null/undefined, manually handle or return a default.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
40 hits · last 30 days
node
34
OpenAI (training)
1
Resources
acc-lang-parser — npm install acc-lang-parser · libregistry