dsteem vs steemjs
I tested out dsteem library recently, and I really like about it. Therefore, I am writing a post to make a brief comparison with steemjs (which I had been using it in the previous project)
Since, dsteem is written in TypeScript, type is much more easier to be check with VSCode
dsteem
- Written in TypeScript
- Well documented
steemjs
- Written in JS
- Official repo by steemit
- More stars on GitHub
Let's make a simple use case
Get all the latest post on the blockchain
in dsteem, (using TypeScript)
import {Client, BlockchainMode} from 'dsteem'
const client = new Client('https://api.steemit.com')
const stream = client.blockchain.getOperationsStream({ mode: BlockchainMode.Latest })
stream.on('data', operation => {
if (operation.op[0] == 'comment') {
// insert code here
}
}
in steemjs, (using JavaScript)
const steem = require('steem')
steem.api.streamTransactions('head', function(err, result) {
if (result.operations[0][0] === 'comment') {
// insert code here
}
})
Comment
in dsteem,
let key = PrivateKey.fromLogin(ACCOUNT_NAME, ACCOUNT_KEY, 'posting')
client.broadcast.comment({
parent_author: data.author,
parent_permlink: data.permlink,
author: process.env.ACCOUNT_NAME,
permlink: "random",
title: "",
body: "the comment body",
json_metadata: "{ tags: ['cn-malaysia'], app: 'cn-malaysia' }"
}, key)
in steemjs,
steem.broadcast.comment(
process.env.ACCOUNT_KEY,
data.author,
data.permlink,
process.env.ACCOUNT_NAME,
'insert_some_title',
'',
commentContent,
{ tags: ['cn-malaysia'], app: 'cn-malaysia' },
function(err, result) {
console.log(err, result);
}
);
Final thoughts
I am still trying out on dsteem, but my feel on dsteem are much easier to be used since it has TypeScript intergrated with it. The only issue I had with SteemJS is for async/await code and not well documented official documentation.
One drawback about dsteem is that is does not have much example, so I had to trial and error to test a certain code.
恭喜你!您的这篇文章入选 @justyy 今日 (2018-04-22) 榜单 【优秀被错过的文章】, 回复本条评论24小时内领赏,点赞本评论将支持 @dailychina 并增加将来您的奖赏。
Congratulations! This post has been selected by @justyy as today's (2018-04-22) 【Good Posts You May Miss】, Steem On! Reply to this message in 24 hours to get rewards. Upvote this comment to support the @dailychina and increase your future rewards! ^_^
You've been upvoted by TeamMalaysia community. Here are trending posts by other TeamMalaysia authors at http://steemit.com/trending/teammalaysia
To support the growth of TeamMalaysia Follow our upvotes by using steemauto.com and follow trail of @myach
Vote TeamMalaysia witness bitrocker2020 using this link vote for witness