From 1e20a90b0df9a60e58f29df07a5c73eb969f3c30 Mon Sep 17 00:00:00 2001 From: freearhey Date: Wed, 6 May 2020 18:01:36 +0300 Subject: [PATCH] Created code2flag() function --- scripts/helper.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/helper.js b/scripts/helper.js index 7d7791bb07..2aafd730b3 100644 --- a/scripts/helper.js +++ b/scripts/helper.js @@ -12,6 +12,19 @@ const iso6393 = require('iso-639-3') let cache = {} let helper = {} +helper.code2flag = function (code) { + switch (code) { + case 'uk': + return '🇬🇧' + case 'int': + return '🌎' + default: + return code + .toUpperCase() + .replace(/./g, char => String.fromCodePoint(char.charCodeAt(0) + 127397)) + } +} + helper.sortBy = function (arr, fields) { return arr.sort((a, b) => { for (let field of fields) {