]> git.codecow.com Git - libnemo.git/commitdiff
Simplify account range swap.
authorChris Duncan <chris@zoso.dev>
Mon, 11 Aug 2025 13:02:32 +0000 (06:02 -0700)
committerChris Duncan <chris@zoso.dev>
Mon, 11 Aug 2025 13:02:32 +0000 (06:02 -0700)
src/lib/wallet/ledger.ts

index 5bfd3c6be9c0c970bc6b1743318048e432729ef9..5a608580ee3503a26eae14d2c02421193d7d491b 100644 (file)
@@ -150,16 +150,13 @@ export class Ledger extends Wallet {
        * // { privateKey: <...>, index: 1 }\r
        * ```\r
        *\r
+       * If `from` is greater than `to`, their values will be swapped.\r
        * @param {number} from - Start index of secret keys. Default: 0\r
        * @param {number} to - End index of secret keys. Default: `from`\r
        * @returns {AccountList} Object with keys of account indexes and values of the corresponding Accounts\r
        */\r
        async accounts (from: number = 0, to: number = from): Promise<AccountList> {\r
-               if (from > to) {\r
-                       const swap = from\r
-                       from = to\r
-                       to = swap\r
-               }\r
+               if (from > to) [from, to] = [to, from]\r
                const output = new AccountList()\r
                const indexes: number[] = []\r
                for (let i = from; i <= to; i++) {\r