1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.iso2FlagEmoji = iso2FlagEmoji;
|
7 |
|
8 | function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
9 |
|
10 | function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
11 |
|
12 | function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
13 |
|
14 | function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
15 |
|
16 | function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | var ISO_REGEX = /^[a-z]{2}$/i;
|
26 |
|
27 | var OFFSET = 127397;
|
28 |
|
29 | function iso2FlagEmoji(iso) {
|
30 | if (!ISO_REGEX.test(iso)) {
|
31 | var type = _typeof(iso);
|
32 |
|
33 | if (process.env.NODE_ENV !== "production") {
|
34 | console.warn("iso argument must be an ISO 3166-1 alpha-2 string, but got '".concat(type === 'string' ? iso : type, "' instead."));
|
35 | }
|
36 |
|
37 | return;
|
38 | }
|
39 |
|
40 | var chars = Array.from(iso.toUpperCase()).map(function (char) {
|
41 | return char.charCodeAt(0) + OFFSET;
|
42 | });
|
43 | return String.fromCodePoint.apply(String, _toConsumableArray(chars));
|
44 | } |
\ | No newline at end of file |