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

slpclient

v1.0.48

Published

Connect to the SLP world (socket and HTTP)

Downloads

4

Readme

SLPClient

A library for interacting with SLPDB from a browser or server, with BitDB API calls wrapped into lexical endpoints.

Please see the sidebar on the left of the documentation for method calls. Please feel free to contribute your own method calls whenever you want.

Installation

npm install --save slpclient

This module was built using Node v8.14.0

Basic Usage

var slpclient = new SLPClient(httpURL,socketURL);
// Get the token info for a genesis tx: 
var tokenInfo = await slpclient.getInfo(tokenId);

Advanced Features (Cascade)

Most cryptocurrency libraries today are more difficult than they need to be. Traditional requests are generally easier to test, so they're done first. WebSocket requests are harder to test, but have the advantage of always giving you the most recent data as it comes in. Generally, a real-time web developer will use both these types of requests in their code to get the intitial data, then update the data as it comes in. SLPClient aims to do this for you automatically, using a .live() chain variable. Traditional requests are available with a .get() chain, and websocket requests are available with the .on() chain.

For example. You can access a given data (e.g. info)in three different ways:

  1. slpclient.info(tokenId).get() will make an HTTP request to get the latest balance.
  2. slpclient.info(tokenId).on(callback) fires a callback with the latest Websocket data as it comes in
  3. slpclient.info(tokenId).live() is a combination of .get() and .on(), which first performs an HTTP request, then updates its response with the latest data from the WebSocket. This function returns a pointer to an object containing the latest data. To access the value, chain .is to the return value.

So, instead of firing a callback, the .live() variable allows your object to have a key which always refreshes with the latest value. This should produce much cleaner and simpler code.

var x = {}; 
x.tokenInfo = await slpclient.info(tokenId).live();
console.log(x.tokenInfo.is) // .is contains the latest value 

If you don't want to use chaining, you can always access this data traditionally too (e.g. slpclient.getInfo and slpclient.onAllAddressesWithToken)

Test

A good way to get started is to run the in-browser tests.

npm run hot

Serverside-validation

Under the hood, SLPClient is using MongoDB queries to access SLPDB on a remote server. Since any MongoDB query can be written (like a loop or really big query), this provides an abusive level of power to the client.

To avoid this abuse, SLPClient adds its lexical function calls to the JSON query sent to the server. These function calls (e.g. .history(simpleledger:qrqfrqwofeqwefqwff)) can be used to 'regex' the query on the server side before sending it to SLPDB. This does make the 'raw' query function irrelevant. This is available in the ./server/ directory.

The server in the ./server/ directory