Props to @aokisok for this snippet, indeed!
If I recall correctly, the next version of the Arweave.js library has this built-in, so you will just be able to create, sign, and send transactions efficiently without having to manually set the anchor.
-arweave-sam