Package Exports
- ipfs-repo
- ipfs-repo/src/default-options-browser.js
- ipfs-repo/src/default-options.js
- ipfs-repo/src/lock
- ipfs-repo/src/lock-memory.js
- ipfs-repo/src/lock.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ipfs-repo) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
IPFS Repo JavaScript Implementation
Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript
This is the implementation of the IPFS repo spec in JavaScript.
Table of Contents
Background
Here is the architectural reasoning for this repo:
┌────────────────────────────────────────┐
│ IPFSRepo │
└────────────────────────────────────────┘
┌─────────────────┐
│ / │
├─────────────────┤
│ Datastore │
└─────────────────┘
│
┌───────────┴───────────┐
│ │
┌─────────────────┐ ┌─────────────────┐
│ /blocks │ │ /datastore │
├─────────────────┤ ├─────────────────┤
│ Datastore │ │ LevelDatastore │
└─────────────────┘ └─────────────────┘
┌────────────────────────────────────────┐ ┌────────────────────────────────────────┐
│ IPFSRepo - Default Node.js │ │ IPFSRepo - Default Browser │
└────────────────────────────────────────┘ └────────────────────────────────────────┘
┌─────────────────┐ ┌─────────────────┐
│ / │ │ / │
├─────────────────┤ ├─────────────────┤
│ FsDatastore │ │LevelJSDatastore │
└─────────────────┘ └─────────────────┘
│ │
┌───────────┴───────────┐ ┌───────────┴───────────┐
│ │ │ │
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ /blocks │ │ /datastore │ │ /blocks │ │ /datastore │
├─────────────────┤ ├─────────────────┤ ├─────────────────┤ ├─────────────────┤
│ FlatfsDatastore │ │LevelDBDatastore │ │LevelJSDatastore │ │LevelJSDatastore │
└─────────────────┘ └─────────────────┘ └─────────────────┘ └─────────────────┘
This provides a well defined interface for creating and interacting with an IPFS repo.
Install
npm
> npm install ipfs-repo
Use in Node.js
var IPFSRepo = require('ipfs-repo')
Use in a browser with browserify, webpack or any other bundler
var IPFSRepo = require('ipfs-repo')
Use in a browser Using a script tag
Loading this module through a script tag will make the IpfsRepo
obj available in the global namespace.
<script src="https://unpkg.com/ipfs-repo/dist/index.min.js"></script>
<!-- OR -->
<script src="https://unpkg.com/ipfs-repo/dist/index.js"></script>
Usage
Example:
const Repo = require('ipfs-repo')
const repo = new Repo('/tmp/ipfs-repo')
repo.init({ cool: 'config' }, (err) => {
if (err) {
throw err
}
repo.open((err) => {
if (err) {
throw err
}
console.log('repo is ready')
})
})
This now has created the following structure, either on disk or as an in memory representation:
├── blocks
│ ├── SHARDING
│ └── _README
├── config
├── datastore
└── version
API
See https://ipfs.github.io/js-ipfs-repo
Notes
Contribute
There are some ways you can make this module better:
- Consult our open issues and take on one of them
- Help our tests reach 100% coverage!
This repository falls under the IPFS Code of Conduct.