]> git.codecow.com Git - libnemo.git/commitdiff
Fix wallet account usage docs. next/test-coverage
authorChris Duncan <chris@zoso.dev>
Sun, 3 May 2026 15:48:17 +0000 (08:48 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 3 May 2026 15:48:17 +0000 (08:48 -0700)
README.md

index 6ca67b2671ad9d3f101500a24460eb2e30eef164..6feed199e3d0d5404d139675c049ca8c1023be6c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -91,7 +91,7 @@ address can be considered correct for Nano protocol purposes.
 Wallet accounts are cached in an array-like numerically-indexed Map. This means
 that deriving an account any time after the first will be faster, and it also
 means that deriving a range of accounts will return an object that can be
-treated somewhat like a [sparse array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays).
+treated somewhat like a [sparse array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays) using the `get/set` syntax of Map objects.
 
 ```javascript
 try {
@@ -102,9 +102,13 @@ try {
 
 const firstAccount = await wallet.account();
 const secondAccount = await wallet.account(1);
+const { address, publicKey } = secondAccount;
+
 const multipleAccounts = await wallet.accounts(2, 3);
-const thirdAccount = multipleAccounts[2];
-const { address, publicKey } = firstAccount;
+const thirdAccount = multipleAccounts.get(2);
+for (const [i, a] of multipleAccounts) {
+  console.log(`Index ${i} returns account ${a.address}`);
+}
 
 const nodeUrl = "https://nano-node.example.com/";
 await firstAccount.refresh(nodeUrl); // online