|
1 | | -IPFS Repo JavaScript Implementation |
2 | | -=================================== |
3 | | - |
4 | | -> Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript |
| 1 | +# IPFS Repo JavaScript Implementation |
5 | 2 |
|
6 | 3 | [](http://ipn.io) |
7 | 4 | [](http://ipfs.io/) |
8 | 5 | [](http://webchat.freenode.net/?channels=%23ipfs) |
| 6 | +[](https://github.com/RichardLitt/standard-readme) |
9 | 7 | [](https://travis-ci.org/ipfs/js-ipfs-repo) |
10 | 8 | [](https://coveralls.io/github/ipfs/js-ipfs-repo?branch=master) [](https://david-dm.org/ipfs/js-ipfs-repo) |
11 | 9 | [](https://github.com/feross/standard) |
12 | 10 |
|
13 | | -## Description |
| 11 | +> Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript |
14 | 12 |
|
15 | 13 | This is the implementation of the [IPFS repo spec](https://github.com/ipfs/specs/tree/master/repo) in JavaScript. |
16 | 14 |
|
17 | | -## Architecture |
| 15 | +## Table of Contents |
| 16 | + |
| 17 | +- [Background](#background) |
| 18 | + - [Good to know (historical context)](#good-to-know-historical-context) |
| 19 | +- [Install](#install) |
| 20 | + - [npm](#npm) |
| 21 | + - [Use in Node.js](#use-in-nodejs) |
| 22 | + - [Use in a browser with browserify, webpack or any other bundler](#use-in-a-browser-with-browserify-webpack-or-any-other-bundler) |
| 23 | + - [Use in a browser Using a script tag](#use-in-a-browser-using-a-script-tag) |
| 24 | +- [Usage](#usage) |
| 25 | +- [API](#api) |
| 26 | + - [var repo = new IPFSRepo(path, opts)](#var-repo--new-ipfsrepopath-opts) |
| 27 | + - [repo.exists(cb)](#repoexistscb) |
| 28 | + - [repo.version.get(cb(err, version))](#repoversiongetcberr-version) |
| 29 | + - [repo.version.set(version, cb(err))](#repoversionsetversion-cberr) |
| 30 | + - [repo.config.get(cb(err, config))](#repoconfiggetcberr-config) |
| 31 | + - [repo.config.set(config, cb(err))](#repoconfigsetconfig-cberr) |
| 32 | + - [repo.keys](#repokeys) |
| 33 | + - [repo.datastore.read(key, cb(err, buffer))](#repodatastorereadkey-cberr-buffer) |
| 34 | + - [repo.datastore.write(buffer, cb(err, buffer))](#repodatastorewritebuffer-cberr-buffer) |
| 35 | + - [repo.datastoreLegacy](#repodatastorelegacy) |
| 36 | +- [Contribute](#contribute) |
| 37 | +- [License](#license) |
| 38 | + |
| 39 | +## Background |
| 40 | + |
| 41 | +Here is the architectural reasoning for this repo: |
18 | 42 |
|
19 | 43 | ```bash |
20 | 44 | ┌─────────────────────────────────┐ |
@@ -48,13 +72,47 @@ more. Each of the individual repos has an interface defined by |
48 | 72 | enables us to make IPFS Repo portable (running on Node.js vs the browser) and |
49 | 73 | accept different types of storage mechanisms for each repo (fs, levelDB, etc). |
50 | 74 |
|
51 | | -## Good to know (historical context) |
| 75 | +### Good to know (historical context) |
52 | 76 |
|
53 | 77 | - The datastore folder holds the legacy version of datastore, still built in levelDB, there is a current endeavour of pushing it to fs completely. |
54 | 78 | - The blocks folder is the current version of datastore. |
55 | 79 | - The keys repo doesn't exist yet, as the private key is simply stored inside config |
56 | 80 |
|
57 | | -# Example |
| 81 | +## Install |
| 82 | + |
| 83 | +### npm |
| 84 | + |
| 85 | +```sh |
| 86 | +> npm i ipfs-repo |
| 87 | +``` |
| 88 | + |
| 89 | +### Use in Node.js |
| 90 | + |
| 91 | +```JavaScript |
| 92 | +var IPFSRepo = require('ipfs-repo') |
| 93 | +``` |
| 94 | + |
| 95 | +### Use in a browser with browserify, webpack or any other bundler |
| 96 | + |
| 97 | +The code published to npm that gets loaded on require is in fact a ES5 transpiled version with the right shims added. This means that you can require it and use with your favourite bundler without having to adjust asset management process. |
| 98 | + |
| 99 | +```JavaScript |
| 100 | +var IPFSRepo = require('ipfs-repo') |
| 101 | +``` |
| 102 | + |
| 103 | +### Use in a browser Using a script tag |
| 104 | + |
| 105 | +Loading this module through a script tag will make the `Unixfs` obj available in the global namespace. |
| 106 | + |
| 107 | +```html |
| 108 | +<script src="https://npmcdn.com/ipfs-repo/dist/index.min.js"></script> |
| 109 | +<!-- OR --> |
| 110 | +<script src="https://npmcdn.com/ipfs-repo/dist/index.js"></script> |
| 111 | +``` |
| 112 | + |
| 113 | +## Usage |
| 114 | + |
| 115 | +Example: |
58 | 116 |
|
59 | 117 | ```js |
60 | 118 | var fsBlobStore = require('fs-blob-store') // an in-memory blob store |
@@ -124,42 +182,18 @@ Read and write buffers to/from the repo's block store. |
124 | 182 |
|
125 | 183 | **WIP** |
126 | 184 |
|
127 | | -# Installation |
128 | | - |
129 | | -## npm |
130 | | - |
131 | | -```sh |
132 | | -> npm i ipfs-repo |
133 | | -``` |
134 | | - |
135 | | -## Use in Node.js |
136 | | - |
137 | | -```JavaScript |
138 | | -var IPFSRepo = require('ipfs-repo') |
139 | | -``` |
140 | | - |
141 | | -## Use in a browser with browserify, webpack or any other bundler |
142 | | - |
143 | | -The code published to npm that gets loaded on require is in fact a ES5 transpiled version with the right shims added. This means that you can require it and use with your favourite bundler without having to adjust asset management process. |
144 | | - |
145 | | -```JavaScript |
146 | | -var IPFSRepo = require('ipfs-repo') |
147 | | -``` |
148 | | - |
149 | | -## Use in a browser Using a script tag |
150 | | - |
151 | | -Loading this module through a script tag will make the `Unixfs` obj available in the global namespace. |
152 | | - |
153 | | -```html |
154 | | -<script src="https://npmcdn.com/ipfs-repo/dist/index.min.js"></script> |
155 | | -<!-- OR --> |
156 | | -<script src="https://npmcdn.com/ipfs-repo/dist/index.js"></script> |
157 | | -``` |
158 | | - |
159 | 185 | ## Contribute |
160 | 186 |
|
161 | 187 | There are some ways you can make this module better: |
162 | 188 |
|
163 | 189 | - Consult our [open issues](https://github.com/ipfs/js-ipfs-repo/issues) and take on one of them |
164 | 190 | - Help our tests reach 100% coverage! |
165 | 191 |
|
| 192 | +This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). |
| 193 | + |
| 194 | +[](https://github.com/ipfs/community/blob/master/contributing.md) |
| 195 | + |
| 196 | +## License |
| 197 | + |
| 198 | +[MIT](LICENSE) |
| 199 | + |
0 commit comments