0.0.1 • Published 7 years ago

@ipfn/runtime v0.0.1

Weekly downloads
-
License
-
Repository
github
Last release
7 years ago

IPFN runtime in JavaScript

IPFN project npm Dependency Status Dev Dependency Status Circle CI

IPFN neurons runtime in JavaScript.

Install

This project is available through npm. To install run:

$ npm install @ipfn/runtime

Requirements

To import projects from IPFS it should me mounted at /ipfs/ and NODE_PATH should point to it.

$ ipfs mount
IPFS mounted at: /ipfs
IPNS mounted at: /ipns
$ export NODE_PATH=/ipfs

Usage

This example uses a counterexample package.

import Session from '@ipfn/session';
import { fire, subscribe, lookup } from '@ipfn/runtime';

// Create a new session of firings
const session = new Session();

// Lookup `Counter` neuron
const counter = lookup('QmSidsSRhbtHUGorPhNZC5HBMM6zvCgVTRa9RYH637sE2S/Counter');

// We will log to console all firings during this session
subscribe(session, counter.increment.count, count => {
  console.log(`Incremented to ${count}`);
});

// Fire `5` on `count` input on `increment` neuron
fire(session, counter.increment.count, 5);

See package tests for more examples.