From: Chris Duncan Date: Mon, 11 Aug 2025 13:02:32 +0000 (-0700) Subject: Simplify account range swap. X-Git-Tag: v0.10.5~41^2~122 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=e99761a3f3f3c59009c6442d5e1ba9cd83365193;p=libnemo.git Simplify account range swap. --- diff --git a/src/lib/wallet/ledger.ts b/src/lib/wallet/ledger.ts index 5bfd3c6..5a60858 100644 --- a/src/lib/wallet/ledger.ts +++ b/src/lib/wallet/ledger.ts @@ -150,16 +150,13 @@ export class Ledger extends Wallet { * // { privateKey: <...>, index: 1 } * ``` * + * If `from` is greater than `to`, their values will be swapped. * @param {number} from - Start index of secret keys. Default: 0 * @param {number} to - End index of secret keys. Default: `from` * @returns {AccountList} Object with keys of account indexes and values of the corresponding Accounts */ async accounts (from: number = 0, to: number = from): Promise { - if (from > to) { - const swap = from - from = to - to = swap - } + if (from > to) [from, to] = [to, from] const output = new AccountList() const indexes: number[] = [] for (let i = from; i <= to; i++) {