Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

steem

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

steem - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

66

lib/steem.js

@@ -644,2 +644,68 @@ var ws = require('ws');

// Stream
Steem.prototype.streamBlockNumber = function(callback) {
var current = '';
var w = new ws(this.url);
w.onmessage = function(msg) {
var data = JSON.parse(msg.data);
var blockId = data.result.head_block_number;
if (blockId != current) {
current = blockId;
callback(current);
}
};
w.onopen = function() {
setInterval(function () {
w.send(JSON.stringify({
'id': 0,
'method': 'get_dynamic_global_properties',
'params': []
}));
}, 100);
}
};
Steem.prototype.streamBlock = function(callback) {
var w = new ws(this.url);
var current = '';
var last = '';
this.streamBlockNumber(function(id) {
current = id;
});
var self = this;
w.onopen = function() {
setInterval(function () {
if (current != last) {
last = current;
self.getBlock(current, function(result) {
callback(result);
});
}
}, 100);
}
};
Steem.prototype.streamTransactions = function(callback) {
this.streamBlock(function(result) {
result.transactions.forEach(function (transaction) {
callback(transaction);
});
})
};
Steem.prototype.streamOperations = function(callback) {
this.streamBlock(function(result) {
result.transactions.forEach(function (transaction) {
transaction.operations.forEach(function (operation) {
callback(operation);
});
});
})
};
module.exports = Steem;

2

package.json
{
"name": "steem",
"version": "0.2.0",
"version": "0.2.1",
"description": "SteemJS the JavaScript API for Steem blockchain",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -402,2 +402,28 @@ # SteemJS

## Stream
### Stream Block Number
```js
steem.streamBlockNumber(function(result) {
console.log(result);
});
```
### Stream Block
```js
steem.streamBlock(function(result) {
console.log(result);
});
```
### Stream Transactions
```js
steem.streamTransactions(function(result) {
console.log(result);
});
```
### Stream Operations
```js
steem.streamOperations(function(result) {
console.log(result);
});
```
## To-Do

@@ -404,0 +430,0 @@ - Connect all the others API

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc