Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit ee2bab6

Browse files
committed
docs: update examples
1 parent 8e937ac commit ee2bab6

File tree

10 files changed

+24
-31
lines changed

10 files changed

+24
-31
lines changed

examples/browser-add-readable-stream/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
/* global Ipfs */
44
/* eslint-env browser */
55

6-
const { Buffer } = Ipfs
7-
86
const main = async () => {
97
const repoPath = `ipfs-${Math.random()}`
108
const ipfs = await Ipfs.create({ repo: repoPath })
@@ -29,14 +27,14 @@ const createFiles = (directory) => {
2927
return [{
3028
path: `${directory}/file1.txt`,
3129

32-
// content could be a stream, a url etc
33-
content: Buffer.from('one', 'utf8')
30+
// content could be a stream, a url, a Buffer, a File etc
31+
content: 'one'
3432
}, {
3533
path: `${directory}/file2.txt`,
36-
content: Buffer.from('two', 'utf8')
34+
content: 'two'
3735
}, {
3836
path: `${directory}/file3.txt`,
39-
content: Buffer.from('three', 'utf8')
37+
content: 'three'
4038
}]
4139
}
4240

examples/browser-browserify/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ document.addEventListener('DOMContentLoaded', async () => {
1010
async function store () {
1111
const toStore = document.getElementById('source').value
1212

13-
const res = await node.add(Buffer.from(toStore))
13+
const res = await node.add(toStore)
1414

1515
res.forEach((file) => {
1616
if (file && file.hash) {

examples/browser-create-react-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"ipfs-css": "^0.13.1",
99
"react": "^16.8.0",
1010
"react-dom": "^16.8.0",
11-
"react-scripts": "3.0.1",
11+
"react-scripts": "3.1.1",
1212
"tachyons": "^4.11.1"
1313
},
1414
"scripts": {

examples/browser-create-react-app/src/hooks/use-ipfs-factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function useIpfsFactory ({ commands }) {
2929
setIpfsReady(false)
3030
}
3131
}
32-
}, [])
32+
})
3333

3434
async function startIpfs () {
3535
if (ipfs) {

examples/browser-parceljs/public/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ document.addEventListener('DOMContentLoaded', async () => {
2424

2525
const filesAdded = await node.add({
2626
path: 'hello-parcel.txt',
27-
content: Buffer.from('Hello from parcel.js bundled ipfs example')
27+
content: 'Hello from parcel.js bundled ipfs example'
2828
})
2929

3030
log(`This page deployed ${filesAdded[0].path} to IPFS and its hash is ${filesAdded[0].hash}`)

examples/browser-script-tag/index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ <h2>Some suggestions</h2>
3030
<p>Try adding a new file:</p>
3131

3232
<code style="display:block; white-space:pre-wrap; background-color:#d7d6d6">
33-
const { Buffer } = Ipfs
34-
3533
async function addFile () {
36-
const filesAdded = await node.add(Buffer.from('Hello world!'))
34+
const filesAdded = await node.add('Hello world!')
3735
filesAdded.forEach((file) => console.log('successfully stored', file.hash))
3836
}
3937

examples/browser-webpack/src/components/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class App extends React.Component {
3030

3131
this.setState({ id, agentVersion, protocolVersion })
3232

33-
const [{ hash }] = await node.add(Buffer.from(stringToUse))
33+
const [{ hash }] = await node.add(stringToUse)
3434
this.setState({ addedFileHash: hash })
3535

3636
const data = await node.cat(hash)

examples/exchange-files-in-browser/public/app.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ let info
4444
async function start () {
4545
if (!node) {
4646
const options = {
47-
pubsub: {
48-
enabled: true
49-
},
5047
repo: 'ipfs-' + Math.random(),
5148
config: {
5249
Addresses: {

examples/explore-ethereum-blockchain/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ We've some ethereum blocks available at [eth-stuffs](./eth-stuffs) folder, you c
2222

2323
```sh
2424
> ./load-eth-stuffs.sh
25-
z43AaGEvwdfzjrCZ3Sq7DKxdDHrwoaPQDtqF4jfdkNEVTiqGVFW
26-
z43AaGEywSDX5PUJcrn5GfZmb6FjisJyR7uahhWPk456f7k7LDA
27-
z43AaGF42R2DXsU65bNnHRCypLPr9sg6D7CUws5raiqATVaB1jj
28-
z45oqTS2AQ9SgyVa31LRGZgfibtdoPvP2miMNaXbDLLgD9MdAAr
29-
z45oqTS8wZaNGU2eepKHRbXvmV93cKQbiL241RB3bRtMYZP8hNm
30-
z45oqTS8wZaNGU2eepKHRbXvmV93cKQbiL241RB3bRtMYZP8hNm
31-
z45oqTS4E1GeJujnKVJG3xSVnS64A8mMCWhKSkCWACNCeD95mtQ
32-
z45oqTS4MnurEeEaanvFieeJDNHH3jGNk9NJEiyrwXwYQSWfxUB
33-
z45oqTRwExySeMeivsU1Y9UdzWDp2mx71TtQhmTGzRaXCcsNujj
34-
z45oqTRzb9a5xyvx5RbfSXH1K5jibyZ4AxnXyYReuLw7KU5veYw
25+
bagiacgzah24drzou2jlkixpblbgbg6nxfrasoklzttzoht5hixhxz3rlncyq
26+
bagiacgzanm7fiqpp7zcfehhd7apxpo4stdxx7wxn7eqrsgolj76t22dintgq
27+
bagiacgzau7z2cpinv6u3rnsa73ssc46cpongn7zh6ztjwo7hh7ao42cj4lha
28+
baglacgzaoc2jzhhxe6psrvq4ixlykpky2a23e3ltnhqpjrji3uyg6rnulxpq
29+
baglacgza2vwiqlrqgkz5jdpkzmkqznntozcnnoycn4swddtxi7njcjsmfpda
30+
baglacgza2vwiqlrqgkz5jdpkzmkqznntozcnnoycn4swddtxi7njcjsmfpda
31+
baglacgzar5mhc23wfjccxfkpf23kbufqqjsqg4t7btaocaraycwlxbaerq2q
32+
baglacgzasflr3hpssk5fpdheemyogi4df2zatql5z3pp7izau7d37ryijgca
33+
baglacgzae6kz4xubhfygknh7yqk2fbk4xztmnvwkwm36knjwukmyfepjveda
34+
baglacgzalfkeokwk7nvwenmr2k3e3f6khvch2bw54nhr25vjmjy2lshmx5mas
3535
```
3636

3737
## Explore these blocks using the DAG API
@@ -41,7 +41,7 @@ NOTE: Currently your js-ipfs daemon must NOT be running for the following exampl
4141
Some examples
4242

4343
```sh
44-
> jsipfs dag get z43AaGEvwdfzjrCZ3Sq7DKxdDHrwoaPQDtqF4jfdkNEVTiqGVFW/
45-
> jsipfs dag get z43AaGEvwdfzjrCZ3Sq7DKxdDHrwoaPQDtqF4jfdkNEVTiqGVFW/parentHash
44+
> jsipfs dag get bagiacgzah24drzou2jlkixpblbgbg6nxfrasoklzttzoht5hixhxz3rlncyq/
45+
> jsipfs dag get bagiacgzah24drzou2jlkixpblbgbg6nxfrasoklzttzoht5hixhxz3rlncyq/parentHash
4646
...
4747
```

examples/ipfs-101/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async function main () {
5757

5858
const filesAdded = await node.add({
5959
path: 'hello.txt',
60-
content: Buffer.from('Hello World 101')
60+
content: 'Hello World 101'
6161
})
6262

6363
console.log('Added file:', filesAdded[0].path, filesAdded[0].hash)
@@ -91,7 +91,7 @@ async function main () {
9191

9292
const filesAdded = await node.add({
9393
path: 'hello.txt',
94-
content: Buffer.from('Hello World 101')
94+
content: 'Hello World 101'
9595
})
9696

9797
console.log('Added file:', filesAdded[0].path, filesAdded[0].hash)

0 commit comments

Comments
 (0)