Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

resolve-accept-language

Package Overview
Dependencies
Maintainers
0
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolve-accept-language - npm Package Compare versions

Comparing version 3.1.7 to 3.1.8

2

lib/cjs/directives.js

@@ -1,1 +0,1 @@

"use strict";var __assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var i in r=arguments[t])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e},__assign.apply(this,arguments)},__read=this&&this.__read||function(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var a,i,n=t.call(e),o=[];try{for(;(void 0===r||r-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(e){i={error:e}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},__spreadArray=this&&this.__spreadArray||function(e,r,t){if(t||2===arguments.length)for(var a,i=0,n=r.length;i<n;i++)!a&&i in r||(a||(a=Array.prototype.slice.call(r,0,i)),a[i]=r[i]);return e.concat(a||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDirectives=void 0;var getDirective=function(e){var r=e.match(/^(([a-z]{2})(-([a-z]{2}|419))?)(;q=((1(\.0{0,3})?)|(0(\.\d{0,3})?)))?$/i);if(r){var t=r[2],a=r[4],i=r[6],n=t.toLowerCase(),o=a?a.toUpperCase():void 0;if("419"!==o||"es"===n){var s=void 0===i?1:Number.parseFloat(i);return{languageCode:n,countryCode:o,locale:o?"".concat(n,"-").concat(o):void 0,quality:s}}}},getDirectives=function(e){var r=[],t=0;e.split(",").forEach((function(e){var a=getDirective(e.trim());a&&(r.some((function(e){return e.languageCode===a.languageCode&&e.locale===a.locale}))||(r.push(__assign(__assign({},a),{headerPosition:t})),t++))}));var a=r.findIndex((function(e){return"es-419"===e.locale}));if(a>=0){var i=r[a],n=["es-AR","es-CL","es-CO","es-CR","es-HN","es-MX","es-PE","es-US","es-UY","es-VE"].map((function(e){return __assign(__assign({},i),{locale:e})}));r.splice.apply(r,__spreadArray([a,1],__read(n),!1))}return r.sort((function(e,r){var t=r.quality-e.quality;return t||e.headerPosition-r.headerPosition}))};exports.getDirectives=getDirectives;
"use strict";var __assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var i in r=arguments[t])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e},__assign.apply(this,arguments)},__read=this&&this.__read||function(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var a,i,n=t.call(e),o=[];try{for(;(void 0===r||r-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(e){i={error:e}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},__spreadArray=this&&this.__spreadArray||function(e,r,t){if(t||2===arguments.length)for(var a,i=0,n=r.length;i<n;i++)!a&&i in r||(a||(a=Array.prototype.slice.call(r,0,i)),a[i]=r[i]);return e.concat(a||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDirectives=void 0;var getDirective=function(e){var r=e.match(/^(([a-z]{2})(-([a-z]{2}|419))?)(;q=((1(\.0{0,3})?)|(0(\.\d{0,3})?)))?$/i);if(r){var t=r[2],a=r[4],i=r[6],n=t.toLowerCase(),o=a?a.toUpperCase():void 0;if("419"!==o||"es"===n){var s=void 0===i?1:Number(i);return{languageCode:n,countryCode:o,locale:o?"".concat(n,"-").concat(o):void 0,quality:s}}}},getDirectives=function(e){var r=[],t=0;e.split(",").forEach((function(e){var a=getDirective(e.trim());a&&(r.some((function(e){return e.languageCode===a.languageCode&&e.locale===a.locale}))||(r.push(__assign(__assign({},a),{headerPosition:t})),t++))}));var a=r.findIndex((function(e){return"es-419"===e.locale}));if(-1!==a){var i=r[a],n=["es-AR","es-CL","es-CO","es-CR","es-HN","es-MX","es-PE","es-US","es-UY","es-VE"].map((function(e){return __assign(__assign({},i),{locale:e})}));r.splice.apply(r,__spreadArray([a,1],__read(n),!1))}return r.sort((function(e,r){var t=r.quality-e.quality;return t||e.headerPosition-r.headerPosition}))};exports.getDirectives=getDirectives;

@@ -1,1 +0,1 @@

"use strict";var __read=this&&this.__read||function(e,o){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var a,r,i=t.call(e),s=[];try{for(;(void 0===o||o-- >0)&&!(a=i.next()).done;)s.push(a.value)}catch(e){r={error:e}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}return s};Object.defineProperty(exports,"__esModule",{value:!0}),exports.isLocale=exports.LocaleList=exports.Locale=void 0;var Locale=function(e){if(!(0,exports.isLocale)(e,!1))throw new Error("invalid locale identifier '".concat(e,"'"));var o=__read(e.split("-"),2),t=o[0],a=o[1];this.languageCode=t.toLowerCase(),this.countryCode=a.toUpperCase(),this.identifier="".concat(this.languageCode,"-").concat(this.countryCode)};exports.Locale=Locale;var LocaleList=function(e){var o=this;this.languages=new Set,this.countries=new Set,this.locales=new Set,this.objects=[],e.forEach((function(e){var t=new Locale(e);o.objects.push(t),o.locales.add(t.identifier),o.languages.add(t.languageCode),o.countries.add(t.countryCode)}))};exports.LocaleList=LocaleList;var isLocale=function(e,o){return void 0===o&&(o=!0),new RegExp(/^[a-z]{2}-[A-Z]{2}$/,o?void 0:"i").test(e)};exports.isLocale=isLocale;
"use strict";var __read=this&&this.__read||function(e,o){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var a,r,i=t.call(e),s=[];try{for(;(void 0===o||o-- >0)&&!(a=i.next()).done;)s.push(a.value)}catch(e){r={error:e}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}return s};Object.defineProperty(exports,"__esModule",{value:!0}),exports.isLocale=exports.LocaleList=exports.Locale=void 0;var Locale=function(e){if(!(0,exports.isLocale)(e,!1))throw new Error("invalid locale identifier '".concat(e,"'"));var o=__read(e.split("-"),2),t=o[0],a=o[1];this.languageCode=t.toLowerCase(),this.countryCode=a.toUpperCase(),this.identifier="".concat(this.languageCode,"-").concat(this.countryCode)};exports.Locale=Locale;var LocaleList=function(e){var o=this;this.languages=new Set,this.countries=new Set,this.locales=new Set,this.objects=[],e.forEach((function(e){var t=new Locale(e);o.objects.push(t),o.locales.add(t.identifier),o.languages.add(t.languageCode),o.countries.add(t.countryCode)}))};exports.LocaleList=LocaleList;var isLocale=function(e,o){return void 0===o&&(o=!0),new RegExp("^[a-z]{2}-[A-Z]{2}$",o?"":"i").test(e)};exports.isLocale=isLocale;

@@ -1,1 +0,1 @@

var __assign=this&&this.__assign||function(){return __assign=Object.assign||function(r){for(var e,a=1,t=arguments.length;a<t;a++)for(var n in e=arguments[a])Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r},__assign.apply(this,arguments)},__read=this&&this.__read||function(r,e){var a="function"==typeof Symbol&&r[Symbol.iterator];if(!a)return r;var t,n,i=a.call(r),o=[];try{for(;(void 0===e||e-- >0)&&!(t=i.next()).done;)o.push(t.value)}catch(r){n={error:r}}finally{try{t&&!t.done&&(a=i.return)&&a.call(i)}finally{if(n)throw n.error}}return o},__spreadArray=this&&this.__spreadArray||function(r,e,a){if(a||2===arguments.length)for(var t,n=0,i=e.length;n<i;n++)!t&&n in e||(t||(t=Array.prototype.slice.call(e,0,n)),t[n]=e[n]);return r.concat(t||Array.prototype.slice.call(e))},getDirective=function(r){var e=r.match(/^(([a-z]{2})(-([a-z]{2}|419))?)(;q=((1(\.0{0,3})?)|(0(\.\d{0,3})?)))?$/i);if(e){var a=e[2],t=e[4],n=e[6],i=a.toLowerCase(),o=t?t.toUpperCase():void 0;if("419"!==o||"es"===i){var s=void 0===n?1:Number.parseFloat(n);return{languageCode:i,countryCode:o,locale:o?"".concat(i,"-").concat(o):void 0,quality:s}}}};export var getDirectives=function(r){var e=[],a=0;r.split(",").forEach((function(r){var t=getDirective(r.trim());t&&(e.some((function(r){return r.languageCode===t.languageCode&&r.locale===t.locale}))||(e.push(__assign(__assign({},t),{headerPosition:a})),a++))}));var t=e.findIndex((function(r){return"es-419"===r.locale}));if(t>=0){var n=e[t],i=["es-AR","es-CL","es-CO","es-CR","es-HN","es-MX","es-PE","es-US","es-UY","es-VE"].map((function(r){return __assign(__assign({},n),{locale:r})}));e.splice.apply(e,__spreadArray([t,1],__read(i),!1))}return e.sort((function(r,e){var a=e.quality-r.quality;return a||r.headerPosition-e.headerPosition}))};
var __assign=this&&this.__assign||function(){return __assign=Object.assign||function(r){for(var e,a=1,t=arguments.length;a<t;a++)for(var n in e=arguments[a])Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r},__assign.apply(this,arguments)},__read=this&&this.__read||function(r,e){var a="function"==typeof Symbol&&r[Symbol.iterator];if(!a)return r;var t,n,i=a.call(r),o=[];try{for(;(void 0===e||e-- >0)&&!(t=i.next()).done;)o.push(t.value)}catch(r){n={error:r}}finally{try{t&&!t.done&&(a=i.return)&&a.call(i)}finally{if(n)throw n.error}}return o},__spreadArray=this&&this.__spreadArray||function(r,e,a){if(a||2===arguments.length)for(var t,n=0,i=e.length;n<i;n++)!t&&n in e||(t||(t=Array.prototype.slice.call(e,0,n)),t[n]=e[n]);return r.concat(t||Array.prototype.slice.call(e))},getDirective=function(r){var e=r.match(/^(([a-z]{2})(-([a-z]{2}|419))?)(;q=((1(\.0{0,3})?)|(0(\.\d{0,3})?)))?$/i);if(e){var a=e[2],t=e[4],n=e[6],i=a.toLowerCase(),o=t?t.toUpperCase():void 0;if("419"!==o||"es"===i){var s=void 0===n?1:Number(n);return{languageCode:i,countryCode:o,locale:o?"".concat(i,"-").concat(o):void 0,quality:s}}}};export var getDirectives=function(r){var e=[],a=0;r.split(",").forEach((function(r){var t=getDirective(r.trim());t&&(e.some((function(r){return r.languageCode===t.languageCode&&r.locale===t.locale}))||(e.push(__assign(__assign({},t),{headerPosition:a})),a++))}));var t=e.findIndex((function(r){return"es-419"===r.locale}));if(-1!==t){var n=e[t],i=["es-AR","es-CL","es-CO","es-CR","es-HN","es-MX","es-PE","es-US","es-UY","es-VE"].map((function(r){return __assign(__assign({},n),{locale:r})}));e.splice.apply(e,__spreadArray([t,1],__read(i),!1))}return e.sort((function(r,e){var a=e.quality-r.quality;return a||r.headerPosition-e.headerPosition}))};

@@ -1,1 +0,1 @@

var __read=this&&this.__read||function(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var a,r,i=o.call(e),n=[];try{for(;(void 0===t||t-- >0)&&!(a=i.next()).done;)n.push(a.value)}catch(e){r={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}return n},Locale=function(e){if(!isLocale(e,!1))throw new Error("invalid locale identifier '".concat(e,"'"));var t=__read(e.split("-"),2),o=t[0],a=t[1];this.languageCode=o.toLowerCase(),this.countryCode=a.toUpperCase(),this.identifier="".concat(this.languageCode,"-").concat(this.countryCode)};export{Locale};var LocaleList=function(e){var t=this;this.languages=new Set,this.countries=new Set,this.locales=new Set,this.objects=[],e.forEach((function(e){var o=new Locale(e);t.objects.push(o),t.locales.add(o.identifier),t.languages.add(o.languageCode),t.countries.add(o.countryCode)}))};export{LocaleList};export var isLocale=function(e,t){return void 0===t&&(t=!0),new RegExp(/^[a-z]{2}-[A-Z]{2}$/,t?void 0:"i").test(e)};
var __read=this&&this.__read||function(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var a,r,i=o.call(e),n=[];try{for(;(void 0===t||t-- >0)&&!(a=i.next()).done;)n.push(a.value)}catch(e){r={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}return n},Locale=function(e){if(!isLocale(e,!1))throw new Error("invalid locale identifier '".concat(e,"'"));var t=__read(e.split("-"),2),o=t[0],a=t[1];this.languageCode=o.toLowerCase(),this.countryCode=a.toUpperCase(),this.identifier="".concat(this.languageCode,"-").concat(this.countryCode)};export{Locale};var LocaleList=function(e){var t=this;this.languages=new Set,this.countries=new Set,this.locales=new Set,this.objects=[],e.forEach((function(e){var o=new Locale(e);t.objects.push(o),t.locales.add(o.identifier),t.languages.add(o.languageCode),t.countries.add(o.countryCode)}))};export{LocaleList};export var isLocale=function(e,t){return void 0===t&&(t=!0),new RegExp("^[a-z]{2}-[A-Z]{2}$",t?"":"i").test(e)};
{
"name": "resolve-accept-language",
"version": "3.1.7",
"version": "3.1.8",
"description": "Resolve the preferred locale based on the value of an `Accept-Language` HTTP header.",

@@ -45,25 +45,30 @@ "keywords": [

"scripts": {
"build": "npm run prettier-write && npm run eslint-fix && rm -Rf ./lib && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json && tsc -p tsconfig.build-scripts.json && node lib/build-scripts/build.js && npm run test",
"build": "npm run check-nvm-node-version && npm run prettier-write && npm run eslint-fix && rm -Rf ./lib && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json && tsc -p src/build-scripts/tsconfig.json && node lib/build-scripts/build.js && npm run test",
"check-nvm-node-version": "check-node-version --node $(node -p \"require('fs').readFileSync('.nvmrc', 'utf-8').trim()\")",
"depcheck": "depcheck",
"eslint-fix": "eslint --fix",
"prepare": "husky",
"prettier-write": "prettier --write .",
"release": "dotenv -- release-it --only-version",
"test": "jest --coverage"
"test": "jest --coverage",
"test-node-version": "node -e \"var resolveAcceptLanguage = require('./lib/cjs/index.js').resolveAcceptLanguage; var result = resolveAcceptLanguage('fr-CA;q=0.01,en-CA;q=0.1,en-US;q=0.001', ['en-US', 'fr-CA'], 'en-US'); console.log(result === 'fr-CA' ? 'success' : 'failure');\""
},
"devDependencies": {
"@eslint/js": "^9.10.0",
"@eslint/js": "^9.12.0",
"@release-it/conventional-changelog": "8.0.2",
"@types/jest": "29.5.13",
"@types/node": "^22.5.5",
"@typescript-eslint/eslint-plugin": "8.5.0",
"@typescript-eslint/parser": "8.5.0",
"@types/node": "^22.7.4",
"@typescript-eslint/eslint-plugin": "8.8.0",
"@typescript-eslint/parser": "8.8.0",
"check-node-version": "^4.2.1",
"depcheck": "^1.4.7",
"dotenv-cli": "7.4.2",
"eslint": "9.10.0",
"eslint": "9.12.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-node": "0.3.9",
"eslint-import-resolver-typescript": "3.6.3",
"eslint-plugin-import-x": "^4.2.1",
"eslint-plugin-compat": "^6.0.1",
"eslint-plugin-import-x": "^4.3.1",
"eslint-plugin-jest": "28.8.3",
"eslint-plugin-jsdoc": "50.2.3",
"eslint-plugin-jsdoc": "50.3.1",
"eslint-plugin-json-files": "4.4.1",

@@ -73,11 +78,12 @@ "eslint-plugin-prefer-arrow-functions": "3.4.1",

"eslint-plugin-tsdoc": "0.3.0",
"eslint-plugin-unicorn": "55.0.0",
"globals": "15.9.0",
"eslint-plugin-unicorn": "56.0.0",
"globals": "15.10.0",
"husky": "^9.1.6",
"jest": "29.7.0",
"jsonc-eslint-parser": "2.4.0",
"prettier": "3.3.3",
"prettier-plugin-organize-imports": "4.0.0",
"prettier-plugin-organize-imports": "4.1.0",
"prettier-plugin-sh": "0.14.0",
"release-it": "17.6.0",
"terser": "^5.32.0",
"release-it": "17.7.0",
"terser": "^5.34.1",
"ts-jest": "29.2.5",

@@ -87,4 +93,4 @@ "typescript": "5.6.2"

"engines": {
"node": "^14.18.1 || >=16.0.0"
"node": ">=4.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc