resolve-accept-language 3.1.7 → 3.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/directives.js +1 -1
- package/lib/cjs/locales.js +1 -1
- package/lib/esm/directives.js +1 -1
- package/lib/esm/locales.js +1 -1
- package/package.json +93 -87
package/lib/cjs/directives.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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(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;
|
package/lib/cjs/locales.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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(
|
|
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?"":"i").test(e)};exports.isLocale=isLocale;
|
package/lib/esm/directives.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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(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}))};
|
package/lib/esm/locales.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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(
|
|
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?"":"i").test(e)};
|
package/package.json
CHANGED
|
@@ -1,87 +1,93 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "resolve-accept-language",
|
|
3
|
-
"version": "3.1.
|
|
4
|
-
"description": "Resolve the preferred locale based on the value of an `Accept-Language` HTTP header.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"accept-language",
|
|
7
|
-
"RFC 4647",
|
|
8
|
-
"locale",
|
|
9
|
-
"language tags",
|
|
10
|
-
"RFC 4646",
|
|
11
|
-
"BCP 47",
|
|
12
|
-
"RFC 2616",
|
|
13
|
-
"resolve",
|
|
14
|
-
"detect",
|
|
15
|
-
"intl",
|
|
16
|
-
"i18n",
|
|
17
|
-
"internationalization"
|
|
18
|
-
],
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/resolve-accept-language/resolve-accept-language.git"
|
|
22
|
-
},
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"author": "resolve-accept-language",
|
|
25
|
-
"type": "module",
|
|
26
|
-
"exports": {
|
|
27
|
-
".": {
|
|
28
|
-
"import": {
|
|
29
|
-
"types": "./lib/esm/index.d.ts",
|
|
30
|
-
"default": "./lib/esm/index.js"
|
|
31
|
-
},
|
|
32
|
-
"require": {
|
|
33
|
-
"types": "./lib/cjs/index.d.ts",
|
|
34
|
-
"default": "./lib/cjs/index.js"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"main": "lib/cjs/index.js",
|
|
39
|
-
"module": "lib/esm/index.js",
|
|
40
|
-
"types": "lib/esm/index.d.ts",
|
|
41
|
-
"files": [
|
|
42
|
-
"lib"
|
|
43
|
-
],
|
|
44
|
-
"scripts": {
|
|
45
|
-
"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
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"eslint": "
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"eslint
|
|
66
|
-
"eslint-
|
|
67
|
-
"eslint-
|
|
68
|
-
"eslint-
|
|
69
|
-
"eslint-plugin-
|
|
70
|
-
"eslint-plugin-
|
|
71
|
-
"eslint-plugin-
|
|
72
|
-
"eslint-plugin-
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "resolve-accept-language",
|
|
3
|
+
"version": "3.1.9",
|
|
4
|
+
"description": "Resolve the preferred locale based on the value of an `Accept-Language` HTTP header.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"accept-language",
|
|
7
|
+
"RFC 4647",
|
|
8
|
+
"locale",
|
|
9
|
+
"language tags",
|
|
10
|
+
"RFC 4646",
|
|
11
|
+
"BCP 47",
|
|
12
|
+
"RFC 2616",
|
|
13
|
+
"resolve",
|
|
14
|
+
"detect",
|
|
15
|
+
"intl",
|
|
16
|
+
"i18n",
|
|
17
|
+
"internationalization"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/resolve-accept-language/resolve-accept-language.git"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": "resolve-accept-language",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./lib/esm/index.d.ts",
|
|
30
|
+
"default": "./lib/esm/index.js"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./lib/cjs/index.d.ts",
|
|
34
|
+
"default": "./lib/cjs/index.js"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"main": "lib/cjs/index.js",
|
|
39
|
+
"module": "lib/esm/index.js",
|
|
40
|
+
"types": "lib/esm/index.d.ts",
|
|
41
|
+
"files": [
|
|
42
|
+
"lib"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"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",
|
|
46
|
+
"check-nvm-node-version": "check-node-version --node $(node -p \"'>=' + require('fs').readFileSync('.nvmrc', 'utf-8').trim()\")",
|
|
47
|
+
"depcheck": "depcheck",
|
|
48
|
+
"eslint-fix": "eslint --fix",
|
|
49
|
+
"prepare": "husky",
|
|
50
|
+
"prettier-write": "prettier --write .",
|
|
51
|
+
"release": "dotenv -- release-it --only-version",
|
|
52
|
+
"test": "jest --coverage",
|
|
53
|
+
"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');\""
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@eslint/js": "^9.15.0",
|
|
57
|
+
"@release-it/conventional-changelog": "9.0.3",
|
|
58
|
+
"@types/jest": "29.5.14",
|
|
59
|
+
"@types/node": "^22.9.3",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "8.15.0",
|
|
61
|
+
"@typescript-eslint/parser": "8.15.0",
|
|
62
|
+
"check-node-version": "^4.2.1",
|
|
63
|
+
"depcheck": "^1.4.7",
|
|
64
|
+
"dotenv-cli": "7.4.4",
|
|
65
|
+
"eslint": "9.15.0",
|
|
66
|
+
"eslint-config-prettier": "9.1.0",
|
|
67
|
+
"eslint-import-resolver-node": "0.3.9",
|
|
68
|
+
"eslint-import-resolver-typescript": "3.6.3",
|
|
69
|
+
"eslint-plugin-compat": "^6.0.1",
|
|
70
|
+
"eslint-plugin-import-x": "^4.4.3",
|
|
71
|
+
"eslint-plugin-jest": "28.9.0",
|
|
72
|
+
"eslint-plugin-jsdoc": "50.5.0",
|
|
73
|
+
"eslint-plugin-json-files": "4.4.2",
|
|
74
|
+
"eslint-plugin-prefer-arrow-functions": "3.4.1",
|
|
75
|
+
"eslint-plugin-prettier": "5.2.1",
|
|
76
|
+
"eslint-plugin-tsdoc": "0.4.0",
|
|
77
|
+
"eslint-plugin-unicorn": "56.0.1",
|
|
78
|
+
"globals": "15.12.0",
|
|
79
|
+
"husky": "^9.1.7",
|
|
80
|
+
"jest": "29.7.0",
|
|
81
|
+
"jsonc-eslint-parser": "2.4.0",
|
|
82
|
+
"prettier": "3.3.3",
|
|
83
|
+
"prettier-plugin-organize-imports": "4.1.0",
|
|
84
|
+
"prettier-plugin-sh": "0.14.0",
|
|
85
|
+
"release-it": "17.10.0",
|
|
86
|
+
"terser": "^5.36.0",
|
|
87
|
+
"ts-jest": "29.2.5",
|
|
88
|
+
"typescript": "5.7.2"
|
|
89
|
+
},
|
|
90
|
+
"engines": {
|
|
91
|
+
"node": ">=4.0.0"
|
|
92
|
+
}
|
|
93
|
+
}
|