🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

ipfs-repo

Package Overview
Dependencies
Maintainers
1
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipfs-repo

IPFS Repo implementation

0.1.0
Source
npm
Version published
Weekly downloads
3.4K
-28.87%
Maintainers
1
Weekly downloads
 
Created
Source

js-ipfs-repo

Build Status Dependency Status js-standard-style

Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript

API

Repo

Constructor, accepts a path and options:

var Repo = require('js-ipfs-repo')
var repo = new Repo('/Users/someone/.ipfs', {adaptor: 'fs'})

Options:

  • adaptor: String with the adaptor. Defaults to fs

version

Read/Write the version number of that repository.

repo.version.read(function (err, num) {
  console.log(err, num) // => 2
})

repo.version.write(3, function (err) {
  console.log(err)
})

api

Read/Write the JSON configuration for that repository.

repo.api.read(function (err, multiaddr) {
  console.log(err, multiaddr)
})

repo.api.write('/ip4/127.0.0.1/tcp/5001', function (err) {
  console.log(err)
})

config

Read/Write the JSON configuration for that repository.

repo.config.read(function (err, json) {
  console.log(err, json)
})

repo.config.write({foo: 'bar'}, function (err) {
  console.log(err)
})

blocks

Store data on the block store.

repo.blocks.read('12200007d4e3a319cd8c7c9979280e150fc5dbaae1ce54e790f84ae5fd3c3c1a0475', function (buff, err) {
  console.log(err)
})
repo.blocks.write(buff, function (buff, err) {
  console.log(buff.toString('utf-8'), err)
})

repo

Read/Write the repo.lock file.

repo.repo.read(function (err, content) {
  console.log(err, content)
})

repo.repo.write('foo', function (err) {
  console.log(err)
})

Adaptors

By default it will use the fs-repo adaptor. Eventually we can write other adaptors and make those available on configuration.

fs-repo

The default adaptor. Uses the repo.lock file to ensure there are no simultaneous reads nor writes. Uses the fs-blob-store.

memory-repo

Ideal for testing purposes. Uses the abstract-blob-store.

Tests

Help us make more tests! Also, enabling them to be run in Node.js and the Browser.

Keywords

IPFS

FAQs

Package last updated on 10 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts