Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 5b5a124

Browse files
docs(readme): Update and cleanup
1 parent 3c01070 commit 5b5a124

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

README.md

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
IPFS Blocks JavaScript Implementation
22
=====================================
33

4-
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
4+
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
55
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
66
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
77
[![Travis CI](https://travis-ci.org/ipfs/js-ipfs-blocks.svg?branch=master)](https://travis-ci.org/ipfs/js-ipfs-blocks)
@@ -40,8 +40,8 @@ A Block is a data structure available on this module.
4040

4141
## Use in Node.js
4242

43-
```JavaScript
44-
var ipfsBlocks = require('ipfs-blocks')
43+
```js
44+
const ipfsBlocks = require('ipfs-blocks')
4545
```
4646

4747
## Use in a browser with browserify, webpack or any other bundler
@@ -65,7 +65,7 @@ Loading this module through a script tag will make the `Unixfs` obj available in
6565
# Usage
6666

6767

68-
```javascript
68+
```js
6969
// then, to access each of the components
7070
ipfsBlocks.BlockService
7171
ipfsBlocks.Block
@@ -75,45 +75,54 @@ ipfsBlocks.Block
7575

7676
Create a new block
7777

78-
```JavaScript
79-
var block = new blocks.Block('some data')
80-
console.log(block.data)
78+
```js
79+
const block = new blocks.Block('some data')
80+
console.log(block.data)
8181
// It will print 'some data'
82+
8283
console.log(block.key)
8384
// It will print the sha256 multihash of 'some data'
8485
```
8586

87+
A block can also have it's own extension, which by default is `data`.
88+
89+
```js
90+
const block = new blocks.Block('data', 'ipld')
91+
console.log(block.extension)
92+
// => ipld
93+
```
94+
8695
#### BlockService
8796

8897
Create a new block service
8998

90-
```JavaScript
91-
var bs = new ipfsBlocks.BlockService(<IPFS REPO instance> [, <IPFS Exchange>])
99+
```js
100+
const bs = new ipfsBlocks.BlockService(<IPFS REPO instance> [, <IPFS Exchange>])
92101
```
93102

94-
##### addBlock
103+
##### `addBlock`
95104

96-
```JavaScript
105+
```js
97106
bs.addBlock(block, function (err) {
98107
if (!err) {
99108
// block successfuly added
100109
}
101110
})
102111
```
103112

104-
##### addBlocks
113+
##### `addBlocks`
105114

106-
```JavaScript
115+
```js
107116
bs.addBlocks(blockArray, function (err) {
108117
if (!err) {
109118
// blocks successfuly added
110119
}
111120
})
112121
```
113122

114-
##### getBlock
123+
##### `getBlock`
115124

116-
```JavaScript
125+
```js
117126
bs.getBlock(multihash, function (err, block) {
118127
if (!err) {
119128
// block successfuly retrieved
@@ -122,29 +131,29 @@ bs.getBlock(multihash, function (err, block) {
122131
```
123132

124133

125-
##### getBlocks
134+
##### `getBlocks`
126135

127-
```JavaScript
136+
```js
128137
bs.getBlocks(multihashArray, function (err, block) {
129138
if (!err) {
130139
// block successfuly retrieved
131140
}
132141
})
133142
```
134143

135-
##### deleteBlock
144+
##### `deleteBlock`
136145

137-
```JavaScript
146+
```js
138147
bs.deleteBlock(multihash, function (err) {
139148
if (!err) {
140149
// block successfuly deleted
141150
}
142151
})
143152
```
144153

145-
##### deleteBlocks
154+
##### `deleteBlocks`
146155

147-
```JavaScript
156+
```js
148157
bs.deleteBlocks(multihashArray, function (err) {
149158
if (!err) {
150159
// blocks successfuly deleted

0 commit comments

Comments
 (0)