ilib-localematcher 1.3.0 → 1.3.1
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/README.md +7 -0
- package/docs/LocaleMatcher.html +1 -1
- package/docs/LocaleMatcher.js.html +4 -6
- package/docs/index.html +1 -1
- package/lib/LocaleMatcher.js +1 -1
- package/lib/LocaleMatcher.js.map +1 -1
- package/lib/localematch.js +1 -1
- package/lib/localematch.js.map +1 -1
- package/package.json +20 -13
- package/src/LocaleMatcher.js +3 -5
- package/src/localematch.js +871 -871
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ilib-localematcher",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"main": "./lib/LocaleMatcher.js",
|
|
5
5
|
"module": "./src/LocaleMatcher.js",
|
|
6
6
|
"exports": {
|
|
@@ -61,26 +61,28 @@
|
|
|
61
61
|
"build:pkg": "echo '{\"type\": \"commonjs\"}' > lib/package.json",
|
|
62
62
|
"build:data": "node scripts/genlikelyloc.js",
|
|
63
63
|
"dist": "npm-run-all build:data doc doc:html build:prod build:pkg; npm pack",
|
|
64
|
-
"test": "npm run test:
|
|
65
|
-
"test:cli": "LANG=en_US.UTF8 npm run build:dev ;
|
|
66
|
-
"test:web": "
|
|
67
|
-
"test:
|
|
68
|
-
"
|
|
64
|
+
"test": "npm run test:all",
|
|
65
|
+
"test:cli": "LANG=en_US.UTF8 npm run build:dev ; node --experimental-vm-modules node_modules/.bin/jest --testEnvironment node",
|
|
66
|
+
"test:web": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/.bin/karma start --reporters dots --single-run",
|
|
67
|
+
"test:watch": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/.bin/jest --testEnvironment node --watch",
|
|
68
|
+
"test:all": "npm-run-all test:cli test:web",
|
|
69
|
+
"debug": "npm run build:dev ; node --experimental-vm-modules --inspect-brk node_modules/.bin/jest --testEnvironment node -i",
|
|
70
|
+
"debug:web": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/.bin/karma start --reporters dots",
|
|
69
71
|
"clean": "git clean -f -d src test; rm -rf lib/*",
|
|
70
72
|
"doc": "mkdir -p docs ; jsdoc2md -c jsdoc.json --separators --source src/* -m table > docs/ilibLocaleMatcher.md",
|
|
71
73
|
"doc:html": "jsdoc -c jsdoc.json"
|
|
72
74
|
},
|
|
73
75
|
"devDependencies": {
|
|
74
|
-
"@babel/core": "^7.23.
|
|
75
|
-
"@babel/preset-env": "^7.23.
|
|
76
|
+
"@babel/core": "^7.23.5",
|
|
77
|
+
"@babel/preset-env": "^7.23.5",
|
|
76
78
|
"@babel/register": "^7.22.15",
|
|
77
|
-
"@babel/runtime": "^7.23.
|
|
78
|
-
"
|
|
79
|
-
"babel-loader": "^9.1.3",
|
|
79
|
+
"@babel/runtime": "^7.23.5",
|
|
80
|
+
"babel-loader": "^8.3.0",
|
|
80
81
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
81
82
|
"babel-plugin-module-resolver": "^5.0.0",
|
|
82
83
|
"cldr-core": "^44.0.1",
|
|
83
84
|
"docdash": "^2.0.2",
|
|
85
|
+
"expect": "^29.7.0",
|
|
84
86
|
"grunt": "^1.6.1",
|
|
85
87
|
"grunt-babel": "^8.0.0",
|
|
86
88
|
"grunt-cli": "^1.4.3",
|
|
@@ -88,12 +90,17 @@
|
|
|
88
90
|
"grunt-contrib-jshint": "^3.2.0",
|
|
89
91
|
"grunt-contrib-nodeunit": "^5.0.0",
|
|
90
92
|
"grunt-contrib-uglify": "^5.2.2",
|
|
93
|
+
"jest": "^26.6.3",
|
|
94
|
+
"jest-mock": "^29.7.0",
|
|
91
95
|
"jsdoc": "^4.0.2",
|
|
92
96
|
"jsdoc-to-markdown": "^8.0.0",
|
|
97
|
+
"karma": "^6.4.2",
|
|
98
|
+
"karma-assert": "^1.0.1",
|
|
99
|
+
"karma-chrome-launcher": "^3.2.0",
|
|
100
|
+
"karma-jasmine": "^5.1.0",
|
|
101
|
+
"karma-webpack": "^5.0.0",
|
|
93
102
|
"load-grunt-tasks": "^5.1.0",
|
|
94
|
-
"nodeunit": "^0.11.3",
|
|
95
103
|
"npm-run-all": "^4.1.5",
|
|
96
|
-
"open-cli": "^7.2.0",
|
|
97
104
|
"webpack": "^5.89.0",
|
|
98
105
|
"webpack-cli": "^5.1.4"
|
|
99
106
|
},
|
package/src/LocaleMatcher.js
CHANGED
|
@@ -294,8 +294,8 @@ class LocaleMatcher {
|
|
|
294
294
|
} else {
|
|
295
295
|
// check for containment
|
|
296
296
|
const containers = matchdata.territoryContainmentReverse[this.locale.region] || [];
|
|
297
|
-
// end at 1 because
|
|
298
|
-
for (i = containers.length-1; i
|
|
297
|
+
// end at length-1 because the end is "001" which is "the whole world" -- which is not useful
|
|
298
|
+
for (i = 0; i < containers.length-1; i++) {
|
|
299
299
|
const container = matchdata.territoryContainment[containers[i]];
|
|
300
300
|
if (container && container.indexOf(other.region) > -1) {
|
|
301
301
|
// same area only accounts for 20% of the region score
|
|
@@ -379,9 +379,7 @@ class LocaleMatcher {
|
|
|
379
379
|
const thisRegions = this._getRegionContainment(thisRegion);
|
|
380
380
|
const otherRegions = this._getRegionContainment(otherRegion);
|
|
381
381
|
|
|
382
|
-
|
|
383
|
-
// at the end of the array
|
|
384
|
-
for (let i = thisRegions.length-1; i > 0; i--) {
|
|
382
|
+
for (let i = 0; i < thisRegions.length; i++) {
|
|
385
383
|
if (otherRegions.indexOf(thisRegions[i]) > -1) {
|
|
386
384
|
return thisRegions[i];
|
|
387
385
|
}
|