@metabin/share
Utility for schema-driven data sharing
Last updated 3 years ago by negamaxi .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @metabin/share 
SYNC missed versions from official npm registry.

Metabin Share

Advanced data sharing ultility

Installation

Metabin share can be used as a local npm module

npm install @metabin/share

Also it can be installed for command line usage.

npm install -g @metabin/share

Usage

Metabin-share connects to ipfs daemon runned on localhost. You can use either go version or js version of ipfs. Go here for details on installation.

After you install ipfs on your machine run it with the following command:

$ ipfs daemon --enable-pubsub-experiment

...or for js version of ipfs installed globally via npm:

$ jsipfs daemon --enable-pubsub-experiment

As a command line tool

To share some data use put command followed by list of meta .json files.

$ metabin put meta1.json folder/meta2.json

To get some data from the sharing space use get command followed by list of content identifiers (cids).

$ metabin get zdpuAufGD4jzjxTfLiJYSNPNpBTdfLaVjXZARCDk1fBYW5j7Y

As a javascript module

To share some data use metabinShare.put() command with a valid metabin object passed as a first argument.


import metabinShare from '@metabin/share'
// const metabinShare = require('@metabin/share')
// const { put } = require('@metabin/share')

const validMetaObj = {
  "schema": {
    "field": [[ "A", "B", "C" ]]
  },
  "data": {
    "field": 1
  }
}

const { validatorReports, cid } = metabinShare.put(validMetaObj)

console.log(cid)
// zdpuAufGD4jzjxTfLiJYSNPNpBTdfLaVjXZARCDk1fBYW5j7Y

console.log(validatorReports)
// [ { path: '/field', valid: true, message: undefined } ]

To get some data from the sharing space use metabinShare.get() with a content identifier (cid) passed as a first argument.


import metabinShare from '@metabin/share'
// const metabinShare = require('@metabin/share')
// const { get } = require('@metabin/share')

const validCid = 'zdpuAufGD4jzjxTfLiJYSNPNpBTdfLaVjXZARCDk1fBYW5j7Y'

const { validatorReports, metaObj } = metabinShare.get(validCid)

console.log(metaObj)
/*
{
  "schema": {
    "field": [[ "A", "B", "C" ]]
  },
  "data": {
    "field": 1
  }
}
*/

console.log(validatorReports)
// [ { path: '/field', valid: true, message: undefined } ]

License

MIT

Current Tags

  • 0.0.2                                ...           latest (3 years ago)

2 Versions

  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (32)
Dev Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |