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

relike-utils

v0.2.6

Published

Javascript library for interacting with the ReLike universal liking service.

Downloads

20

Readme

relike-utils

Join the chat at https://gitter.im/relike-utils/Lobby npm version

Javascript library for interfacing with ReLike, the decentralized public liking service, powered by Ethereum.

Documentation

Everything in ReLike centers around the concept of an entityId. This is just a string of text but it represents anything that can be liked. Some examples of entityIds include:

"cat"
"dog"
"Terminator 3"
"🍕"
"QmW84daiALvufneDcjDeoTFKR1bGQuHFUFv1fcSSRpmuCN"
"https://www.theguardian.com/sport/2017/jun/10/nba-finals-cleveland-cavaliers-golden-state-warriors-game-4"

You can like or dislike any entityId you can think of. The sky is the limit. In its alpha stage it's very permissive so something is bound to break.

How to use

  1. Install the package

    npm i --save relike-utils
  2. Import the package into your project

    import ReLikeUtils from 'relike-utils';
  3. Instantiate a ReLikeUtils object. This has all the methods you need to interact with the ReLike liking service on Ethereum.

    const reLikeUtils = new ReLikeUtils();

    Upon instantiation, ReLikeUtils will automatically connect to whatever currentProvider it sees. An override is possible inside the config object. Please see below.

    It will also start listening for ItemLiked events. Every time someone likes or dislikes something on ReLike an event is fired. A callback can be provided to receive these events. Please see below.

    It will also start listening for any time the user changes accounts. A callback can be provided to receive the address of the new account. Please see below

    The constructor can optionally be given a config object with one or more of the following

    const reLikeUtils = new ReLikeUtils({
      // This function will be called every time ReLike notices the primary account changing
      onAccountChangeEvent: function(newAccount) {},
         
      // This function will be called every time ReLike gets an event notification of a new like
      onLikeEvent: function({ dislikes, entityId, likes, rating, user }) {},
         
      // This function will be fired when ReLike is initializing and should return a web3 object that ReLike will use instead of the one it finds
      // It receives the current web3 object if one was found
      web3Override: function(currentWeb3Object) {},
    });

List of methods and what they do

Most methods return promises.

reLikeUtils.like(entityId)

Takes any string and likes it.

reLikeUtils.unlike(entityId)

Takes any previously liked string and unlikes it. Will throw an error if the user hasn't liked this entity yet.

reLikeUtils.dislike(entityId)

takes any string and dislikes it.

reLikeUtils.unDislike(entityId)

Takes any previously disliked string and undislikes it. Will throw an error if the user hasn't disliked this entity yet.

reLikeUtils.getActiveAccount()

Returns the user address currently active in web3.

reLikeUtils.getMyRating(entityId)

Returns the user's current rating for a given string. The values are

0 = unrated
1 = like
2 = dislike
reLikeUtils.getLikeCount(entityId)

This returns an object that contains the aggregated like counts for any entity. The object is of the shape:

{
  dislikes: 2,
  likes: 4
}