aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-01-10 23:52:58 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-01-10 23:52:58 +0100
commitb3f0b76f7f6a8836a20c908b3a22a34c3a13c9b9 (patch)
tree07c6aef1b87386de726ee89734d46a68edb92908
parent473503a246aa7a23539a349710c5549d1d87c147 (diff)
downloadwallet-core-b3f0b76f7f6a8836a20c908b3a22a34c3a13c9b9.tar.xz
Replace format util with ES6 string templates.
-rw-r--r--extension/lib/util.ts55
-rw-r--r--extension/lib/wallet/emscriptif.ts10
-rw-r--r--extension/lib/wallet/wxmessaging.js2
-rw-r--r--extension/lib/wallet/wxmessaging.ts4
-rw-r--r--extension/manifest.json2
-rw-r--r--extension/popup/balance-overview.html1
-rw-r--r--extension/popup/history.html1
-rw-r--r--extension/tsconfig.json1
8 files changed, 7 insertions, 69 deletions
diff --git a/extension/lib/util.ts b/extension/lib/util.ts
deleted file mode 100644
index f2fdb131a..000000000
--- a/extension/lib/util.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- This file is part of TALER
- (C) 2015 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
- */
-
-'use strict';
-
-/**
- * Parse an amount that is specified like '5.42 EUR'.
- * Returns a {currency,value,fraction} object or null
- * if the input is invalid.
- */
-function amount_parse_pretty(s) {
- let pattern = /(\d+)(.\d+)?\s*([a-zA-Z]+)/;
- let matches = pattern.exec(s);
- if (null == matches) {
- return null;
- }
- return {
- // Always succeeds due to regex
- value: parseInt(matches[1]),
- // Should we warn / fail on lost precision?
- fraction: Math.round(parseFloat(matches[2] || "0") * 1000000),
- currency: matches[3],
- };
-}
-
-
-function format(s: string, ...args: any[]) {
- function r(m, n) {
- let i = parseInt(n);
- return args[i];
- }
- s = s.replace(/{{/g, '{');
- s = s.replace(/}}/g, '}');
- s = s.replace(/{([0-9]+)}/g, r);
- return s;
-}
-
-
-function promiseFinally<T>(p: Promise<T>, fn): Promise<T> {
- return p.then((x) => { fn(); return x; })
- .catch((e) => {fn(); throw e;});
-}
diff --git a/extension/lib/wallet/emscriptif.ts b/extension/lib/wallet/emscriptif.ts
index d8fd72289..eb6a292a7 100644
--- a/extension/lib/wallet/emscriptif.ts
+++ b/extension/lib/wallet/emscriptif.ts
@@ -595,7 +595,7 @@ export class HashCode extends PackedArenaObject {
qual = RandomQuality.NONCE;
break;
default:
- throw Error(format("unknown crypto quality: {0}", qual));
+ throw Error(`unknown crypto quality: ${qual}`);
}
this.alloc();
emsc.hash_create_random(qual, this.nativePtr);
@@ -680,7 +680,7 @@ abstract class SignatureStruct {
let name = f[0];
let member = this.members[name];
if (!member) {
- throw Error(format("Member {0} not set", name));
+ throw Error(`Member ${name} not set`);
}
totalSize += member.size();
}
@@ -705,7 +705,7 @@ abstract class SignatureStruct {
let name = f[0];
let member = this.members[name];
if (!member) {
- throw Error(format("Member {0} not set", name));
+ throw Error(`Member ${name} not set`);
}
res[name] = member.toJson();
}
@@ -719,10 +719,10 @@ abstract class SignatureStruct {
typemap[f[0]] = f[1];
}
if (!(name in typemap)) {
- throw Error(format("Key {0} not found", name));
+ throw Error(`Key ${name} not found`);
}
if (!(value instanceof typemap[name])) {
- throw Error(format("Wrong type for {0}", name));
+ throw Error("Wrong type for ${name}");
}
this.members[name] = value;
}
diff --git a/extension/lib/wallet/wxmessaging.js b/extension/lib/wallet/wxmessaging.js
index c656f2632..7a6f501be 100644
--- a/extension/lib/wallet/wxmessaging.js
+++ b/extension/lib/wallet/wxmessaging.js
@@ -98,7 +98,7 @@ System.register(["./wallet", "./db", "./http"], function(exports_1) {
if (req.type in handlers) {
return handlers[req.type](db, req.detail, onresponse);
}
- console.error(format("Request type {1} unknown, req {0}", JSON.stringify(req), req.type));
+ console.error("Request type " + JSON.stringify(req) + " unknown, req " + req.type);
return false;
});
});
diff --git a/extension/lib/wallet/wxmessaging.ts b/extension/lib/wallet/wxmessaging.ts
index 1b345e22f..6c8f77a8b 100644
--- a/extension/lib/wallet/wxmessaging.ts
+++ b/extension/lib/wallet/wxmessaging.ts
@@ -127,9 +127,7 @@ export function wxMain() {
if (req.type in handlers) {
return handlers[req.type](db, req.detail, onresponse);
}
- console.error(format("Request type {1} unknown, req {0}",
- JSON.stringify(req),
- req.type));
+ console.error(`Request type ${JSON.stringify(req)} unknown, req ${req.type}`);
return false;
});
});
diff --git a/extension/manifest.json b/extension/manifest.json
index b7991e3f3..619d986a2 100644
--- a/extension/manifest.json
+++ b/extension/manifest.json
@@ -28,7 +28,6 @@
"js": [
"lib/vendor/system.src.js",
"lib/vendor/URI.js",
- "lib/util.js",
"content_scripts/notify.js"
],
"run_at": "document_start"
@@ -44,7 +43,6 @@
"scripts": [
"lib/vendor/URI.js",
"lib/vendor/handlebars-v4.0.5.js",
- "lib/util.js",
"lib/emscripten/libwrapper.js",
"lib/vendor/system.src.js",
"background/main.js"
diff --git a/extension/popup/balance-overview.html b/extension/popup/balance-overview.html
index 166908bbc..b27a9353a 100644
--- a/extension/popup/balance-overview.html
+++ b/extension/popup/balance-overview.html
@@ -4,7 +4,6 @@
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="popup.css" type="text/css">
- <script src="../lib/util.js" type="text/javascript"></script>
<script src="../lib/vendor/handlebars-v4.0.5.js" type="text/javascript"></script>
<script src="../lib/commonHelpers.js" type="text/javascript"></script>
<script src="balance-overview.js" type="text/javascript"></script>
diff --git a/extension/popup/history.html b/extension/popup/history.html
index dccc84605..0b211d8af 100644
--- a/extension/popup/history.html
+++ b/extension/popup/history.html
@@ -4,7 +4,6 @@
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="popup.css" type="text/css">
- <script src="../lib/util.js" type="text/javascript"></script>
<script src="history.js" type="text/javascript"></script>
<script id="balance-template" type="text/x-handlebars-template">
diff --git a/extension/tsconfig.json b/extension/tsconfig.json
index 4d220b601..e76d322af 100644
--- a/extension/tsconfig.json
+++ b/extension/tsconfig.json
@@ -17,7 +17,6 @@
"lib/wallet/checkable.ts",
"lib/wallet/wxmessaging.ts",
"lib/wallet/types.ts",
- "lib/util.ts",
"lib/commonHelpers.ts",
"lib/polyfill-react.ts",
"lib/wallet/timerThread.ts",