diff --git a/docs/examples/baconjs/index.js b/docs/examples/baconjs/index.js deleted file mode 100644 index 0b84f10..0000000 --- a/docs/examples/baconjs/index.js +++ /dev/null @@ -1,24 +0,0 @@ -// external -import {} from 'https://unpkg.com/jquery' -// external -import {fromEvent} from 'https://unpkg.com/baconjs?module' - -const upEl = globalThis.document.createElement('button') -const downEl = globalThis.document.createElement('button') -const counterEl = globalThis.document.createElement('div') - -globalThis.document.body.appendChild(upEl) -globalThis.document.body.appendChild(downEl) -globalThis.document.body.appendChild(counterEl) - -const up = fromEvent(upEl, 'click'); -const down = fromEvent(downEl, 'click'); - -const counter = - // map up to 1, down to -1 - up.map(1).merge(down.map(-1)) - // accumulate sum - .scan(0, (x,y) => x + y); - -// assign observable value to jQuery property text -counter.onValue(text => Object.assign(counterEl, {innerText: text})); diff --git a/docs/examples/ethers/index.js b/docs/examples/ethers/index.js new file mode 100644 index 0000000..3dfea5c --- /dev/null +++ b/docs/examples/ethers/index.js @@ -0,0 +1,14 @@ +import {ethers} from 'https://unpkg.com/ethers/dist/ethers.esm.js' + +const URL = 'https://ethereum-goerli-rpc.allthatnode.com' + +const p = ethers.getDefaultProvider(URL) + +const latest = await p.getBlock() + +const txs = await Promise.all(latest.transactions.map(t => + p.getTransactionReceipt(t) +)) + +const totalGas = txs.reduce((gas,tx) => + gas.add(tx.gasUsed), ethers.BigNumber.from(0))