npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dknowledgr

v0.11.7

Published

Dknowledgr blockchain RPC client library

Downloads

10

Readme

dknowledgr Build Status Coverage Status Package Version

Robust dknowledgr blockchain client library that runs in both node.js and the browser.

Created from dsteem 0.8.7


note As of version 0.7.0 WebSocket support has been removed. The only transport provided now is HTTP(2). For most users the only change required is to swap wss:// to https:// in the address. If you run your own full node make sure to set the proper CORS headers if you plan to access it from a browser.


Browser compatibility

Build Status

Installation

Via npm

For node.js or the browser with browserify or webpack.

npm install dknowledgr

From cdn or self-hosted script

Grab dist/dsteem.js from a release and include in your html:

<script src="dsteem.js"></script>

Or from the unpkg cdn:

<script src="https://unpkg.com/dknowledgr@^0.8.0/dist/dsteem.js"></script>

Make sure to set the version you want when including from the cdn, you can also use dknowledgr@latest but that is not always desirable. See unpkg.com for more information.

Usage

In the browser

<script src="https://unpkg.com/dknowledgr@latest/dist/dsteem.js"></script>
<script>
    var client = new dsteem.Client('https://api.steemit.com')
    client.database.getDiscussions('trending', {tag: 'writing', limit: 1}).then(function(discussions){
        document.body.innerHTML += '<h1>' + discussions[0].title + '</h1>'
        document.body.innerHTML += '<h2>by ' + discussions[0].author + '</h2>'
        document.body.innerHTML += '<pre style="white-space: pre-wrap">' + discussions[0].body + '</pre>'
    })
</script>

See the demo source for an example on how to setup a livereloading TypeScript pipeline with wintersmith and browserify.

In node.js

With TypeScript:

import {Client} from 'dknowledgr'

const client = new Client('https://api.steemit.com')

for await (const block of client.blockchain.getBlocks()) {
    console.log(`New block, id: ${ block.block_id }`)
}

With JavaScript:

var dknowledgr = require('dknowledgr')

var client = new dknowledgr.Client('https://api.steemit.com')
var key = dknowledgr.PrivateKey.fromLogin('username', 'password', 'posting')

client.broadcast.vote({
    voter: 'username',
    author: 'almost-digital',
    permlink: 'dknowledgr-is-the-best',
    weight: 10000
}, key).then(function(result){
   console.log('Included in block: ' + result.block_num)
}, function(error) {
   console.error(error)
})

With ES2016 (node.js 7+):

const {Client} = require('dknowledgr')

const client = new Client('https://api.steemit.com')

async function main() {
    const props = await client.database.getChainProperties()
    console.log(`Maximum blocksize consensus: ${ props.maximum_block_size } bytes`)
    client.disconnect()
}

main().catch(console.error)

With node.js streams:

var dknowledgr = require('dknowledgr')
var es = require('event-stream') // npm install event-stream
var util = require('util')

var client = new dknowledgr.Client('https://api.steemit.com')

var stream = client.blockchain.getBlockStream()

stream.pipe(es.map(function(block, callback) {
    callback(null, util.inspect(block, {colors: true, depth: null}) + '\n')
})).pipe(process.stdout)

Bundling

The easiest way to bundle dknowledgr (with browserify, webpack etc.) is to just npm install dknowledgr and require('dknowledgr') which will give you well-tested (see browser compatibility matrix above) pre-bundled code guaranteed to JustWork™. However, that is not always desirable since it will not allow your bundler to de-duplicate any shared dependencies dknowledgr and your app might have.

To allow for deduplication you can require('dknowledgr/lib/index-browser'), or if you plan to provide your own polyfills: require('dknowledgr/lib/index'). See src/index-browser.ts for a list of polyfills expected.


Share and Enjoy!