[gnome-maps/wip/mlundblad/es6-modules: 17/28] scripts/extractPoiTypesFromID: Stop using imports.byteArray
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/es6-modules: 17/28] scripts/extractPoiTypesFromID: Stop using imports.byteArray
- Date: Wed, 8 Jun 2022 20:09:13 +0000 (UTC)
commit 1dd1a160bf6253ccdcc981dfb08fcba1e142d8a8
Author: Marcus Lundblad <ml dfupdate se>
Date: Mon May 23 23:34:43 2022 +0200
scripts/extractPoiTypesFromID: Stop using imports.byteArray
Replace usage with ES TextDecoder.
scripts/extractPoiTypesFromID.js | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
---
diff --git a/scripts/extractPoiTypesFromID.js b/scripts/extractPoiTypesFromID.js
index 4ef45fb4..32585b17 100755
--- a/scripts/extractPoiTypesFromID.js
+++ b/scripts/extractPoiTypesFromID.js
@@ -31,8 +31,6 @@
import Gio from 'gi://Gio';
-const ByteArray = imports.byteArray;
-
const PRESETS_PATH = 'data/presets';
const LOCALES_PATH = 'dist/translations';
const PRESET_TYPES = [ 'aeroway',
@@ -45,18 +43,12 @@ const PRESET_TYPES = [ 'aeroway',
const OUTPUT = {};
-function getBufferText(buffer) {
- if (buffer instanceof Uint8Array) {
- return ByteArray.toString(buffer);
- } else {
- return buffer.toString();
- }
-}
+let decoder = new TextDecoder('utf-8');
function parseJson(dirPath, fileName) {
let file = Gio.File.new_for_path(dirPath + '/' + fileName);
let [status, buffer] = file.load_contents(null);
- let {tags, name} = JSON.parse(getBufferText(buffer));
+ let {tags, name} = JSON.parse(decoder.decode(buffer));
for (let key in tags) {
let value = tags[key];
@@ -92,7 +84,7 @@ function processTypes(basePath) {
function processLocale(dirPath, fileName) {
let file = Gio.File.new_for_path(dirPath + '/' + fileName);
let [status, buffer] = file.load_contents(null);
- let object = JSON.parse(getBufferText(buffer));
+ let object = JSON.parse(decoder.decode(buffer));
let lang = fileName.substring(0, fileName.indexOf('.json'));
for (let type in OUTPUT) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]