diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-03-30 16:09:32 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-03-30 16:09:32 +0530 |
commit | aaf950e2ad5c07d4423f9822e3a0ae9f7b8d2bdf (patch) | |
tree | 9274139660f30c4857d80044eb4ac283aac1775a /src/util | |
parent | 15e18440dbad55df19977a2eb7053681259afc18 (diff) |
re-format with prettier v2, fix HTML
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/RequestThrottler.ts | 29 | ||||
-rw-r--r-- | src/util/assertUnreachable.ts | 2 | ||||
-rw-r--r-- | src/util/asyncMemo.ts | 7 | ||||
-rw-r--r-- | src/util/codec-test.ts | 12 | ||||
-rw-r--r-- | src/util/codec.ts | 27 | ||||
-rw-r--r-- | src/util/helpers-test.ts | 11 | ||||
-rw-r--r-- | src/util/helpers.ts | 19 | ||||
-rw-r--r-- | src/util/http.ts | 6 | ||||
-rw-r--r-- | src/util/libtoolVersion-test.ts | 30 | ||||
-rw-r--r-- | src/util/libtoolVersion.ts | 18 | ||||
-rw-r--r-- | src/util/payto-test.ts | 2 | ||||
-rw-r--r-- | src/util/payto.ts | 7 | ||||
-rw-r--r-- | src/util/promiseUtils.ts | 6 | ||||
-rw-r--r-- | src/util/query.ts | 37 | ||||
-rw-r--r-- | src/util/talerconfig.ts | 6 | ||||
-rw-r--r-- | src/util/taleruri-test.ts | 50 | ||||
-rw-r--r-- | src/util/time.ts | 6 | ||||
-rw-r--r-- | src/util/timer.ts | 7 | ||||
-rw-r--r-- | src/util/wire.ts | 2 |
19 files changed, 168 insertions, 116 deletions
diff --git a/src/util/RequestThrottler.ts b/src/util/RequestThrottler.ts index 0566306de..c99c7e949 100644 --- a/src/util/RequestThrottler.ts +++ b/src/util/RequestThrottler.ts @@ -21,7 +21,12 @@ /** * Imports. */ -import { getTimestampNow, Timestamp, timestampSubtractDuraction, timestampDifference } from "../util/time"; +import { + getTimestampNow, + Timestamp, + timestampSubtractDuraction, + timestampDifference, +} from "../util/time"; /** * Maximum request per second, per origin. @@ -38,7 +43,6 @@ const MAX_PER_MINUTE = 100; */ const MAX_PER_HOUR = 1000; - /** * Throttling state for one origin. */ @@ -52,12 +56,21 @@ class OriginState { const now = getTimestampNow(); const d = timestampDifference(now, this.lastUpdate); if (d.d_ms === "forever") { - throw Error("assertion failed") + throw Error("assertion failed"); } const d_s = d.d_ms / 1000; - this.tokensSecond = Math.min(MAX_PER_SECOND, this.tokensSecond + (d_s / 1000)); - this.tokensMinute = Math.min(MAX_PER_MINUTE, this.tokensMinute + (d_s / 1000 * 60)); - this.tokensHour = Math.min(MAX_PER_HOUR, this.tokensHour + (d_s / 1000 * 60 * 60)); + this.tokensSecond = Math.min( + MAX_PER_SECOND, + this.tokensSecond + d_s / 1000, + ); + this.tokensMinute = Math.min( + MAX_PER_MINUTE, + this.tokensMinute + (d_s / 1000) * 60, + ); + this.tokensHour = Math.min( + MAX_PER_HOUR, + this.tokensHour + (d_s / 1000) * 60 * 60, + ); this.lastUpdate = now; } @@ -104,13 +117,13 @@ export class RequestThrottler { if (s) { return s; } - const ns = this.perOriginInfo[origin] = new OriginState(); + const ns = (this.perOriginInfo[origin] = new OriginState()); return ns; } /** * Apply throttling to a request. - * + * * @returns whether the request should be throttled. */ applyThrottle(requestUrl: string): boolean { diff --git a/src/util/assertUnreachable.ts b/src/util/assertUnreachable.ts index 90f2476b4..ffdf88f04 100644 --- a/src/util/assertUnreachable.ts +++ b/src/util/assertUnreachable.ts @@ -16,4 +16,4 @@ export function assertUnreachable(x: never): never { throw new Error("Didn't expect to get here"); -}
\ No newline at end of file +} diff --git a/src/util/asyncMemo.ts b/src/util/asyncMemo.ts index 17204a88e..84fe6b802 100644 --- a/src/util/asyncMemo.ts +++ b/src/util/asyncMemo.ts @@ -40,9 +40,9 @@ export class AsyncOpMemoMap<T> { // Wrap the operation in case it immediately throws const p = Promise.resolve().then(() => pg()); this.memoMap[key] = { - p, - n, - t: new Date().getTime(), + p, + n, + t: new Date().getTime(), }; return p.finally(() => { this.cleanUp(key, n); @@ -53,7 +53,6 @@ export class AsyncOpMemoMap<T> { } } - export class AsyncOpMemoSingle<T> { private n = 0; private memoEntry: MemoEntry<T> | undefined; diff --git a/src/util/codec-test.ts b/src/util/codec-test.ts index 7c7c93c7b..e25a9d3cd 100644 --- a/src/util/codec-test.ts +++ b/src/util/codec-test.ts @@ -19,7 +19,13 @@ */ import test from "ava"; -import { Codec, makeCodecForObject, makeCodecForConstString, codecForString, makeCodecForUnion } from "./codec"; +import { + Codec, + makeCodecForObject, + makeCodecForConstString, + codecForString, + makeCodecForUnion, +} from "./codec"; interface MyObj { foo: string; @@ -37,7 +43,7 @@ interface AltTwo { type MyUnion = AltOne | AltTwo; -test("basic codec", t => { +test("basic codec", (t) => { const myObjCodec = makeCodecForObject<MyObj>() .property("foo", codecForString) .build("MyObj"); @@ -49,7 +55,7 @@ test("basic codec", t => { }); }); -test("union", t => { +test("union", (t) => { const altOneCodec: Codec<AltOne> = makeCodecForObject<AltOne>() .property("type", makeCodecForConstString("one")) .property("foo", codecForString) diff --git a/src/util/codec.ts b/src/util/codec.ts index 09fa9f953..a8f495238 100644 --- a/src/util/codec.ts +++ b/src/util/codec.ts @@ -110,7 +110,8 @@ class ObjectCodecBuilder<OutputType, PartialOutputType> { throw new DecodingError( `expected object for ${objectDisplayName} at ${renderContext( c, - )} but got ${typeof x}`) + )} but got ${typeof x}`, + ); } const obj: any = {}; for (const prop of propList) { @@ -273,7 +274,9 @@ export const codecForNumber: Codec<number> = { if (typeof x === "number") { return x; } - throw new DecodingError(`expected number at ${renderContext(c)} but got ${typeof x}`); + throw new DecodingError( + `expected number at ${renderContext(c)} but got ${typeof x}`, + ); }, }; @@ -285,7 +288,9 @@ export const codecForBoolean: Codec<boolean> = { if (typeof x === "boolean") { return x; } - throw new DecodingError(`expected boolean at ${renderContext(c)} but got ${typeof x}`); + throw new DecodingError( + `expected boolean at ${renderContext(c)} but got ${typeof x}`, + ); }, }; @@ -297,7 +302,9 @@ export const codecForString: Codec<string> = { if (typeof x === "string") { return x; } - throw new DecodingError(`expected string at ${renderContext(c)} but got ${typeof x}`); + throw new DecodingError( + `expected string at ${renderContext(c)} but got ${typeof x}`, + ); }, }; @@ -320,21 +327,25 @@ export function makeCodecForConstString<V extends string>(s: V): Codec<V> { return x; } throw new DecodingError( - `expected string constant "${s}" at ${renderContext(c)} but got ${typeof x}`, + `expected string constant "${s}" at ${renderContext( + c, + )} but got ${typeof x}`, ); }, }; } -export function makeCodecOptional<V>(innerCodec: Codec<V>): Codec<V | undefined> { +export function makeCodecOptional<V>( + innerCodec: Codec<V>, +): Codec<V | undefined> { return { decode(x: any, c?: Context): V | undefined { if (x === undefined || x === null) { return undefined; } return innerCodec.decode(x, c); - } - } + }, + }; } export function typecheckedCodec<T = undefined>(c: Codec<T>): Codec<T> { diff --git a/src/util/helpers-test.ts b/src/util/helpers-test.ts index 74817120a..35f3d87b2 100644 --- a/src/util/helpers-test.ts +++ b/src/util/helpers-test.ts @@ -14,25 +14,26 @@ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - import test from "ava"; import * as helpers from "./helpers"; - test("URL canonicalization", (t) => { // converts to relative, adds https t.is( "https://alice.example.com/exchange/", - helpers.canonicalizeBaseUrl("alice.example.com/exchange")); + helpers.canonicalizeBaseUrl("alice.example.com/exchange"), + ); // keeps http, adds trailing slash t.is( "http://alice.example.com/exchange/", - helpers.canonicalizeBaseUrl("http://alice.example.com/exchange")); + helpers.canonicalizeBaseUrl("http://alice.example.com/exchange"), + ); // keeps http, adds trailing slash t.is( "http://alice.example.com/exchange/", - helpers.canonicalizeBaseUrl("http://alice.example.com/exchange#foobar")); + helpers.canonicalizeBaseUrl("http://alice.example.com/exchange#foobar"), + ); t.pass(); }); diff --git a/src/util/helpers.ts b/src/util/helpers.ts index 722688d35..130dcdaef 100644 --- a/src/util/helpers.ts +++ b/src/util/helpers.ts @@ -34,7 +34,6 @@ export function amountToPretty(amount: AmountJson): string { return `${x} ${amount.currency}`; } - /** * Canonicalize a base url, typically for the exchange. * @@ -53,7 +52,6 @@ export function canonicalizeBaseUrl(url: string) { return x.href; } - /** * Convert object to JSON with canonical ordering of keys * and whitespace omitted. @@ -84,7 +82,6 @@ export function canonicalJson(obj: any): string { return s + "}"; } - /** * Check for deep equality of two objects. * Only arrays, objects and primitives are supported. @@ -99,11 +96,12 @@ export function deepEquals(x: any, y: any): boolean { } const p = Object.keys(x); - return Object.keys(y).every((i) => p.indexOf(i) !== -1) && - p.every((i) => deepEquals(x[i], y[i])); + return ( + Object.keys(y).every((i) => p.indexOf(i) !== -1) && + p.every((i) => deepEquals(x[i], y[i])) + ); } - /** * Map from a collection to a list or results and then * concatenate the results. @@ -125,12 +123,11 @@ export function hash(val: any): number { } /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed - * integers. Since we want the results to be always positive, convert the - * signed int to an unsigned by doing an unsigned bitshift. */ + * integers. Since we want the results to be always positive, convert the + * signed int to an unsigned by doing an unsigned bitshift. */ return h >>> 0; } - /** * Lexically compare two strings. */ @@ -146,10 +143,10 @@ export function strcmp(s1: string, s2: string): number { /** * Run a function and return its result. - * + * * Used as a nicer-looking way to do immediately invoked function * expressions (IFFEs). */ export function runBlock<T>(f: () => T) { return f(); -}
\ No newline at end of file +} diff --git a/src/util/http.ts b/src/util/http.ts index 93c748d79..1a5cb85fa 100644 --- a/src/util/http.ts +++ b/src/util/http.ts @@ -101,12 +101,12 @@ export class BrowserHttpLib implements HttpRequestLibrary { myRequest.send(); } - myRequest.onerror = e => { + myRequest.onerror = (e) => { console.error("http request error"); reject(Error("could not make XMLHttpRequest")); }; - myRequest.addEventListener("readystatechange", e => { + myRequest.addEventListener("readystatechange", (e) => { if (myRequest.readyState === XMLHttpRequest.DONE) { if (myRequest.status === 0) { reject( @@ -134,7 +134,7 @@ export class BrowserHttpLib implements HttpRequestLibrary { // Create a map of header names to values const headerMap = new Headers(); - arr.forEach(function(line) { + arr.forEach(function (line) { const parts = line.split(": "); const header = parts.shift(); const value = parts.join(": "); diff --git a/src/util/libtoolVersion-test.ts b/src/util/libtoolVersion-test.ts index 0a610e455..e58e94759 100644 --- a/src/util/libtoolVersion-test.ts +++ b/src/util/libtoolVersion-test.ts @@ -19,12 +19,30 @@ import * as LibtoolVersion from "./libtoolVersion"; import test from "ava"; test("version comparison", (t) => { - t.deepEqual(LibtoolVersion.compare("0:0:0", "0:0:0"), {compatible: true, currentCmp: 0}); + t.deepEqual(LibtoolVersion.compare("0:0:0", "0:0:0"), { + compatible: true, + currentCmp: 0, + }); t.deepEqual(LibtoolVersion.compare("0:0:0", ""), undefined); t.deepEqual(LibtoolVersion.compare("foo", "0:0:0"), undefined); - t.deepEqual(LibtoolVersion.compare("0:0:0", "1:0:1"), {compatible: true, currentCmp: -1}); - t.deepEqual(LibtoolVersion.compare("0:0:0", "1:5:1"), {compatible: true, currentCmp: -1}); - t.deepEqual(LibtoolVersion.compare("0:0:0", "1:5:0"), {compatible: false, currentCmp: -1}); - t.deepEqual(LibtoolVersion.compare("1:0:0", "0:5:0"), {compatible: false, currentCmp: 1}); - t.deepEqual(LibtoolVersion.compare("1:0:1", "1:5:1"), {compatible: true, currentCmp: 0}); + t.deepEqual(LibtoolVersion.compare("0:0:0", "1:0:1"), { + compatible: true, + currentCmp: -1, + }); + t.deepEqual(LibtoolVersion.compare("0:0:0", "1:5:1"), { + compatible: true, + currentCmp: -1, + }); + t.deepEqual(LibtoolVersion.compare("0:0:0", "1:5:0"), { + compatible: false, + currentCmp: -1, + }); + t.deepEqual(LibtoolVersion.compare("1:0:0", "0:5:0"), { + compatible: false, + currentCmp: 1, + }); + t.deepEqual(LibtoolVersion.compare("1:0:1", "1:5:1"), { + compatible: true, + currentCmp: 0, + }); }); diff --git a/src/util/libtoolVersion.ts b/src/util/libtoolVersion.ts index cc2435b94..5e9d0b74e 100644 --- a/src/util/libtoolVersion.ts +++ b/src/util/libtoolVersion.ts @@ -19,7 +19,6 @@ * See https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html */ - /** * Result of comparing two libtool versions. */ @@ -44,7 +43,10 @@ interface Version { /** * Compare two libtool-style version strings. */ -export function compare(me: string, other: string): VersionMatchResult|undefined { +export function compare( + me: string, + other: string, +): VersionMatchResult | undefined { const meVer = parseVersion(me); const otherVer = parseVersion(other); @@ -52,16 +54,16 @@ export function compare(me: string, other: string): VersionMatchResult|undefined return undefined; } - const compatible = (meVer.current - meVer.age <= otherVer.current && - meVer.current >= (otherVer.current - otherVer.age)); + const compatible = + meVer.current - meVer.age <= otherVer.current && + meVer.current >= otherVer.current - otherVer.age; const currentCmp = Math.sign(meVer.current - otherVer.current); - return {compatible, currentCmp}; + return { compatible, currentCmp }; } - -function parseVersion(v: string): Version|undefined { +function parseVersion(v: string): Version | undefined { const [currentStr, revisionStr, ageStr, ...rest] = v.split(":"); if (rest.length !== 0) { return undefined; @@ -82,5 +84,5 @@ function parseVersion(v: string): Version|undefined { return undefined; } - return {current, revision, age}; + return { current, revision, age }; } diff --git a/src/util/payto-test.ts b/src/util/payto-test.ts index 82daff164..01280b650 100644 --- a/src/util/payto-test.ts +++ b/src/util/payto-test.ts @@ -28,4 +28,4 @@ test("basic payto parsing", (t) => { const r3 = parsePaytoUri("payto://x-taler-bank/123"); t.is(r3?.targetType, "x-taler-bank"); t.is(r3?.targetPath, "123"); -});
\ No newline at end of file +}); diff --git a/src/util/payto.ts b/src/util/payto.ts index 0926fdeed..ac5bc0c7f 100644 --- a/src/util/payto.ts +++ b/src/util/payto.ts @@ -20,9 +20,8 @@ interface PaytoUri { params: { [name: string]: string }; } - export function parsePaytoUri(s: string): PaytoUri | undefined { - const pfx = "payto://" + const pfx = "payto://"; if (!s.startsWith(pfx)) { return undefined; } @@ -50,5 +49,5 @@ export function parsePaytoUri(s: string): PaytoUri | undefined { targetPath, targetType, params, - } -}
\ No newline at end of file + }; +} diff --git a/src/util/promiseUtils.ts b/src/util/promiseUtils.ts index 9add2c407..d409686d9 100644 --- a/src/util/promiseUtils.ts +++ b/src/util/promiseUtils.ts @@ -14,11 +14,11 @@ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - export interface OpenedPromise<T> { +export interface OpenedPromise<T> { promise: Promise<T>; resolve: (val: T) => void; reject: (err: any) => void; - } +} /** * Get an unresolved promise together with its extracted resolve / reject @@ -57,4 +57,4 @@ export class AsyncCondition { this._waitPromise = op.promise; this._resolveWaitPromise = op.resolve; } -}
\ No newline at end of file +} diff --git a/src/util/query.ts b/src/util/query.ts index 3303907fe..ce704b4fc 100644 --- a/src/util/query.ts +++ b/src/util/query.ts @@ -271,11 +271,14 @@ export class TransactionHandle { return new ResultStream<T>(req); } - iterIndexed<S extends IDBValidKey,T>( + iterIndexed<S extends IDBValidKey, T>( index: Index<S, T>, key?: any, ): ResultStream<T> { - const req = this.tx.objectStore(index.storeName).index(index.indexName).openCursor(key); + const req = this.tx + .objectStore(index.storeName) + .index(index.indexName) + .openCursor(key); return new ResultStream<T>(req); } @@ -298,7 +301,7 @@ function runWithTransaction<T>( ): Promise<T> { const stack = Error("Failed transaction was started here."); return new Promise((resolve, reject) => { - const storeName = stores.map(x => x.name); + const storeName = stores.map((x) => x.name); const tx = db.transaction(storeName, mode); let funResult: any = undefined; let gotFunResult: boolean = false; @@ -332,11 +335,11 @@ function runWithTransaction<T>( const th = new TransactionHandle(tx); const resP = Promise.resolve().then(() => f(th)); resP - .then(result => { + .then((result) => { gotFunResult = true; funResult = result; }) - .catch(e => { + .catch((e) => { if (e == TransactionAbort) { console.info("aborting transaction"); } else { @@ -344,7 +347,8 @@ function runWithTransaction<T>( console.error(stack); tx.abort(); } - }).catch((e) => { + }) + .catch((e) => { console.error("fatal: aborting transaction failed", e); }); }); @@ -394,15 +398,19 @@ export function openDatabase( databaseName: string, databaseVersion: number, onVersionChange: () => void, - onUpgradeNeeded: (db: IDBDatabase, oldVersion: number, newVersion: number) => void, + onUpgradeNeeded: ( + db: IDBDatabase, + oldVersion: number, + newVersion: number, + ) => void, ): Promise<IDBDatabase> { return new Promise<IDBDatabase>((resolve, reject) => { const req = idbFactory.open(databaseName, databaseVersion); - req.onerror = e => { + req.onerror = (e) => { console.log("taler database error", e); reject(new Error("database error")); }; - req.onsuccess = e => { + req.onsuccess = (e) => { req.result.onversionchange = (evt: IDBVersionChangeEvent) => { console.log( `handling live db version change from ${evt.oldVersion} to ${evt.newVersion}`, @@ -412,7 +420,7 @@ export function openDatabase( }; resolve(req.result); }; - req.onupgradeneeded = e => { + req.onupgradeneeded = (e) => { const db = req.result; onUpgradeNeeded(db, e.oldVersion, e.newVersion!); console.log( @@ -441,7 +449,7 @@ export class Database { stores: {} as { [s: string]: any }, version: db.version, }; - + return new Promise((resolve, reject) => { const tx = db.transaction(Array.from(db.objectStoreNames)); tx.addEventListener("complete", () => { @@ -489,7 +497,7 @@ export class Database { }); }); } - + async get<T>(store: Store<T>, key: any): Promise<T | undefined> { const tx = this.db.transaction([store.name], "readonly"); const req = tx.objectStore(store.name).get(key); @@ -503,10 +511,7 @@ export class Database { key: any, ): Promise<T | undefined> { const tx = this.db.transaction([index.storeName], "readonly"); - const req = tx - .objectStore(index.storeName) - .index(index.indexName) - .get(key); + const req = tx.objectStore(index.storeName).index(index.indexName).get(key); const v = await requestToPromise(req); await transactionToPromise(tx); return v; diff --git a/src/util/talerconfig.ts b/src/util/talerconfig.ts index 333bcd1bb..61c75574f 100644 --- a/src/util/talerconfig.ts +++ b/src/util/talerconfig.ts @@ -110,11 +110,13 @@ export class Configuration { getString(section: string, option: string): ConfigValue<string> { const val = (this.sectionMap[section] ?? {})[option]; - return new ConfigValue(section, option, val, x => x); + return new ConfigValue(section, option, val, (x) => x); } getAmount(section: string, option: string): ConfigValue<AmountJson> { const val = (this.sectionMap[section] ?? {})[option]; - return new ConfigValue(section, option, val, x => Amounts.parseOrThrow(x)); + return new ConfigValue(section, option, val, (x) => + Amounts.parseOrThrow(x), + ); } } diff --git a/src/util/taleruri-test.ts b/src/util/taleruri-test.ts index 052581a91..9efc1846d 100644 --- a/src/util/taleruri-test.ts +++ b/src/util/taleruri-test.ts @@ -22,7 +22,7 @@ import { parseTipUri, } from "./taleruri"; -test("taler pay url parsing: wrong scheme", t => { +test("taler pay url parsing: wrong scheme", (t) => { const url1 = "talerfoo://"; const r1 = parsePayUri(url1); t.is(r1, undefined); @@ -32,7 +32,7 @@ test("taler pay url parsing: wrong scheme", t => { t.is(r2, undefined); }); -test("taler pay url parsing: defaults", t => { +test("taler pay url parsing: defaults", (t) => { const url1 = "taler://pay/example.com/-/-/myorder"; const r1 = parsePayUri(url1); if (!r1) { @@ -52,7 +52,7 @@ test("taler pay url parsing: defaults", t => { t.is(r2.sessionId, "mysession"); }); -test("taler pay url parsing: trailing parts", t => { +test("taler pay url parsing: trailing parts", (t) => { const url1 = "taler://pay/example.com/-/-/myorder/mysession/spam/eggs"; const r1 = parsePayUri(url1); if (!r1) { @@ -63,7 +63,7 @@ test("taler pay url parsing: trailing parts", t => { t.is(r1.sessionId, "mysession"); }); -test("taler pay url parsing: instance", t => { +test("taler pay url parsing: instance", (t) => { const url1 = "taler://pay/example.com/-/myinst/myorder"; const r1 = parsePayUri(url1); if (!r1) { @@ -74,7 +74,7 @@ test("taler pay url parsing: instance", t => { t.is(r1.orderId, "myorder"); }); -test("taler pay url parsing: path prefix and instance", t => { +test("taler pay url parsing: path prefix and instance", (t) => { const url1 = "taler://pay/example.com/mypfx/myinst/myorder"; const r1 = parsePayUri(url1); if (!r1) { @@ -84,7 +84,7 @@ test("taler pay url parsing: path prefix and instance", t => { t.is(r1.merchantBaseUrl, "https://example.com/mypfx/instances/myinst/"); }); -test("taler pay url parsing: complex path prefix", t => { +test("taler pay url parsing: complex path prefix", (t) => { const url1 = "taler://pay/example.com/mypfx%2Fpublic/-/myorder"; const r1 = parsePayUri(url1); if (!r1) { @@ -96,7 +96,7 @@ test("taler pay url parsing: complex path prefix", t => { t.is(r1.sessionId, undefined); }); -test("taler pay uri parsing: complex path prefix and instance", t => { +test("taler pay uri parsing: complex path prefix and instance", (t) => { const url1 = "taler://pay/example.com/mypfx%2Fpublic/foo/myorder"; const r1 = parsePayUri(url1); if (!r1) { @@ -107,29 +107,29 @@ test("taler pay uri parsing: complex path prefix and instance", t => { t.is(r1.orderId, "myorder"); }); -test("taler refund uri parsing: non-https #1", t => { +test("taler refund uri parsing: non-https #1", (t) => { const url1 = "taler://refund/example.com/-/-/myorder?insecure=1"; const r1 = parseRefundUri(url1); if (!r1) { t.fail(); return; - } + } t.is(r1.merchantBaseUrl, "http://example.com/public/"); - t.is(r1.orderId, "myorder") + t.is(r1.orderId, "myorder"); }); -test("taler pay uri parsing: non-https #1", t => { +test("taler pay uri parsing: non-https #1", (t) => { const url1 = "taler://pay/example.com/-/-/myorder?insecure=1"; const r1 = parsePayUri(url1); if (!r1) { t.fail(); return; - } + } t.is(r1.merchantBaseUrl, "http://example.com/public/"); - t.is(r1.orderId, "myorder") + t.is(r1.orderId, "myorder"); }); -test("taler pay url parsing: non-https #2", t => { +test("taler pay url parsing: non-https #2", (t) => { const url1 = "taler://pay/example.com/-/-/myorder?insecure=2"; const r1 = parsePayUri(url1); if (!r1) { @@ -140,7 +140,7 @@ test("taler pay url parsing: non-https #2", t => { t.is(r1.orderId, "myorder"); }); -test("taler withdraw uri parsing", t => { +test("taler withdraw uri parsing", (t) => { const url1 = "taler://withdraw/bank.example.com/-/12345"; const r1 = parseWithdrawUri(url1); if (!r1) { @@ -150,7 +150,7 @@ test("taler withdraw uri parsing", t => { t.is(r1.statusUrl, "https://bank.example.com/api/withdraw-operation/12345"); }); -test("taler refund uri parsing", t => { +test("taler refund uri parsing", (t) => { const url1 = "taler://refund/merchant.example.com/-/-/1234"; const r1 = parseRefundUri(url1); if (!r1) { @@ -161,7 +161,7 @@ test("taler refund uri parsing", t => { t.is(r1.orderId, "1234"); }); -test("taler refund uri parsing with instance", t => { +test("taler refund uri parsing with instance", (t) => { const url1 = "taler://refund/merchant.example.com/-/myinst/1234"; const r1 = parseRefundUri(url1); if (!r1) { @@ -169,23 +169,23 @@ test("taler refund uri parsing with instance", t => { return; } t.is(r1.orderId, "1234"); - t.is(r1.merchantBaseUrl, "https://merchant.example.com/public/instances/myinst/"); + t.is( + r1.merchantBaseUrl, + "https://merchant.example.com/public/instances/myinst/", + ); }); -test("taler tip pickup uri", t => { +test("taler tip pickup uri", (t) => { const url1 = "taler://tip/merchant.example.com/-/-/tipid"; const r1 = parseTipUri(url1); if (!r1) { t.fail(); return; } - t.is( - r1.merchantBaseUrl, - "https://merchant.example.com/public/", - ); + t.is(r1.merchantBaseUrl, "https://merchant.example.com/public/"); }); -test("taler tip pickup uri with instance", t => { +test("taler tip pickup uri with instance", (t) => { const url1 = "taler://tip/merchant.example.com/-/tipm/tipid"; const r1 = parseTipUri(url1); if (!r1) { @@ -199,7 +199,7 @@ test("taler tip pickup uri with instance", t => { t.is(r1.merchantTipId, "tipid"); }); -test("taler tip pickup uri with instance and prefix", t => { +test("taler tip pickup uri with instance and prefix", (t) => { const url1 = "taler://tip/merchant.example.com/my%2fpfx/tipm/tipid"; const r1 = parseTipUri(url1); if (!r1) { diff --git a/src/util/time.ts b/src/util/time.ts index 2740c361f..138ecb876 100644 --- a/src/util/time.ts +++ b/src/util/time.ts @@ -138,7 +138,11 @@ export function timestampDifference(t1: Timestamp, t2: Timestamp): Duration { return { d_ms: Math.abs(t1.t_ms - t2.t_ms) }; } -export function timestampIsBetween(t: Timestamp, start: Timestamp, end: Timestamp) { +export function timestampIsBetween( + t: Timestamp, + start: Timestamp, + end: Timestamp, +) { if (timestampCmp(t, start) < 0) { return false; } diff --git a/src/util/timer.ts b/src/util/timer.ts index 000f36608..8706c939e 100644 --- a/src/util/timer.ts +++ b/src/util/timer.ts @@ -31,8 +31,7 @@ export interface TimerHandle { } class IntervalHandle { - constructor(public h: any) { - } + constructor(public h: any) {} clear() { clearInterval(this.h); @@ -40,8 +39,7 @@ class IntervalHandle { } class TimeoutHandle { - constructor(public h: any) { - } + constructor(public h: any) {} clear() { clearTimeout(this.h); @@ -78,7 +76,6 @@ export function after(delayMs: number, callback: () => void): TimerHandle { return new TimeoutHandle(setTimeout(callback, delayMs)); } - const nullTimerHandle = { clear() { // do nothing diff --git a/src/util/wire.ts b/src/util/wire.ts index 757ba9266..21ad600fc 100644 --- a/src/util/wire.ts +++ b/src/util/wire.ts @@ -14,7 +14,6 @@ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - /** * Display and manipulate wire information. * @@ -50,4 +49,3 @@ export function summarizeWire(w: any): string { return i18n.str`Unknown Wire Detail`; } } - |