Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Replace country-regex with i18n-iso-countries#7366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dimitrov570 wants to merge9 commits intoplotly:master
base:master
Choose a base branch
Loading
fromdimitrov570:replace-country-regex
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsdraftlogs/7366_change.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
- Replace country-regex package with i18n-iso-countries [[#7366](https://github.com/plotly/plotly.js/pull/7366)]
23 changes: 17 additions & 6 deletionspackage-lock.json
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

2 changes: 1 addition & 1 deletionpackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,7 +81,6 @@
"color-normalize": "1.5.0",
"color-parse": "2.0.0",
"color-rgba": "3.0.0",
"country-regex": "^1.1.0",
"d3-force": "^1.2.1",
"d3-format": "^1.4.5",
"d3-geo": "^1.12.1",
Expand All@@ -95,6 +94,7 @@
"gl-text": "^1.4.0",
"has-hover": "^1.0.1",
"has-passive-events": "^1.0.0",
"i18n-iso-countries": "^7.13.0",
"is-mobile": "^4.0.0",
"maplibre-gl": "^4.7.1",
"mouse-change": "^1.4.0",
Expand Down
16 changes: 8 additions & 8 deletionssrc/lib/geo_location_utils.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
'use strict';

var d3 = require('@plotly/d3');
var countryRegex = require('country-regex');
var { area: turfArea } = require('@turf/area');
var { centroid: turfCentroid } = require('@turf/centroid');
var { bbox: turfBbox } = require('@turf/bbox');
const countries = require("i18n-iso-countries");

var identity = require('./identity');
var loggers = require('./loggers');
var isPlainObject = require('./is_plain_object');
var nestedProperty = require('./nested_property');
var polygon = require('./polygon');

// make list of all country iso3 ids from at runtime
var countryIds = Object.keys(countryRegex);
countries.registerLocale(require("i18n-iso-countries/langs/en.json"));

var locationmodeToIdFinder = {
'ISO-3': identity,
Expand All@@ -22,11 +21,12 @@ var locationmodeToIdFinder = {
};

function countryNameToISO3(countryName) {
for(var i = 0; i < countryIds.length; i++) {
var iso3 = countryIds[i];
var regex = new RegExp(countryRegex[iso3]);

if(regex.test(countryName.trim().toLowerCase())) return iso3;
// remove sequences of whitespaces
var cleanName = countryName.replace(/\s+/g, ' ').trim();
var alpha3Code = countries.getAlpha3Code(cleanName, "en")

if (alpha3Code !== undefined) {
return alpha3Code;
}

loggers.log('Unrecognized country name: ' + countryName + '.');
Expand Down
46 changes: 28 additions & 18 deletionstasks/compress_attributes.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,22 +35,32 @@ function makeRegex(regexStr) {
);
}

module.exports = function() {
var allChunks = [];
return through(function(chunk, enc, next) {
allChunks.push(chunk);
next();
}, function(done) {
var str = Buffer.concat(allChunks).toString('utf-8');
this.push(
str
.replace(makeStringRegex('description'), '')
.replace(makeJoinedArrayRegex('description'), '')
.replace(makeArrayRegex('requiredOpts'), '')
.replace(makeArrayRegex('otherOpts'), '')
.replace(makeStringRegex('role'), '')
.replace(makeStringRegex('hrName'), '')
);
done();
});
module.exports = path => {
const allChunks = [];
return through(
(chunk, _, next) => {
allChunks.push(chunk);
next();
},
function(done) {
const str = Buffer.concat(allChunks).toString('utf-8');

// Return JSON as stringified JSON so that ESBuild will handle transformation
if(path.toLowerCase().endsWith('.json')) {
this.push(JSON.stringify(str));
done();
}

this.push(
str
.replace(makeStringRegex('description'), '')
.replace(makeJoinedArrayRegex('description'), '')
.replace(makeArrayRegex('requiredOpts'), '')
.replace(makeArrayRegex('otherOpts'), '')
.replace(makeStringRegex('role'), '')
.replace(makeStringRegex('hrName'), '')
);
done();
}
);
};
Loading

[8]ページ先頭

©2009-2025 Movatter.jp