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

@anychain/core

v0.2.2

Published

Blockchain data structure for Node.js

Downloads

3

Readme

anychain

A blockchain data structure for Node.js! :rocket:

Quick Start (JavaScript)

const { Blockchain } = require("@anychain/core");

const blockchain = new Blockchain();

const shipments = [
  {
    trackingId: 42,
    latitude: 40.758895,
    longitude: -73.985131
  }
];

blockchain.add(shipments);

Quick Start (TypeScript)

import { Block, Blockchain } from "@anychain/core";

interface Shipment {
  trackingId: number;
  latitude: number;
  longitude: number;
}

const shipments: Shipment[] = [
  {
    trackingId: 42,
    latitude: 40.758895,
    longitude: -73.985131
  }
];

const blockchain: Blockchain<Shipment[]> = new Blockchain<Shipment[]>();

const latestBlock: Block<Shipment[]> = blockchain.add(shipments);

Installation

yarn add @anychain/core
# or
npm install --save @anychain/core

API

constructor(chain?: Block<T>[])

Pass an optional existing chain to the constructor.

#add(data: T): Block<T>

Adds a new block with the given data to the blockchain.

#update(chain: Block<T>[]): boolean

Overwrite the current chain with a more recent one. Returns true when the update was successful.

#toJSON(): string

Returns the following JSON for the example above:

[
  {
    "index": 0,
    "parent": null,
    "data": "GENESIS",
    "time": 1522226975631,
    "hash": "2e465389daa2d20a41fcd12cb7cf2b59fbd04e72dcd5d21cb5c72c91fd83119b"
  },
  {
    "index": 1,
    "parent": "2e465389daa2d20a41fcd12cb7cf2b59fbd04e72dcd5d21cb5c72c91fd83119b",
    "data": [
      {
        "trackingId": 42,
        "latitude": 40.758895,
        "longitude": -73.985131
      }
    ],
    "time": 1522226975631,
    "hash": "9467452a7cdb8491d3b5c1cce93583bb2840e6c0b9e2612f6a915e1df207c52a"
  }
]

#getChain(): Block<T>[]

Returns the full chain as array.

#getGenesisBlock(): Block<T>

Returns the first block in the chain (genesis).

#getLatestBlock(): Block<T>

Returns the latest block in the chain.

License

MIT