aboutsummaryrefslogtreecommitdiff
path: root/extension/lib/util.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-01-10 20:07:42 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-01-10 20:07:42 +0100
commit473503a246aa7a23539a349710c5549d1d87c147 (patch)
tree2b1ee9b420df72a0d861759d1fbcd2226e489086 /extension/lib/util.js
parentdd19e0ecbe114ebd71122ff57ea56eabb6258b75 (diff)
The great modularization.
Use ES6 module syntax and SystemJS modules for everything. Some testing stubs were added as well.
Diffstat (limited to 'extension/lib/util.js')
-rw-r--r--extension/lib/util.js49
1 files changed, 0 insertions, 49 deletions
diff --git a/extension/lib/util.js b/extension/lib/util.js
deleted file mode 100644
index 938f6c730..000000000
--- a/extension/lib/util.js
+++ /dev/null
@@ -1,49 +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, ...args) {
- 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(p, fn) {
- return p.then((x) => { fn(); return x; })
- .catch((e) => { fn(); throw e; });
-}