ipfs-demo 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -15
- package/index.js +19 -15
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,24 +1,30 @@
|
|
1
1
|
|
2
2
|
# IPFS implementations
|
3
3
|
```javascript
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
const {create}= require('ipfs-http-client')
|
5
|
+
const ipfsClient = async () =>{
|
6
|
+
const options ={
|
7
|
+
host:'ipfs.infura.io',
|
8
|
+
port:5001,
|
9
|
+
protocol:'https',
|
10
|
+
|
11
|
+
}
|
12
|
+
const ipfs = await create(options);
|
13
|
+
return ipfs;
|
14
14
|
|
15
|
-
|
15
|
+
}
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
```
|
18
|
+
***
|
19
|
+
## function expression implementation (IIF)
|
20
|
+
---
|
21
|
+
``` javascript
|
22
|
+
|
23
|
+
( async function(){
|
24
|
+
|
19
25
|
const addText = await ipfsClient();
|
20
26
|
const storeResult = await addText.add('npm package manager')
|
21
27
|
console.log(storeResult)
|
22
|
-
|
23
|
-
|
28
|
+
|
29
|
+
})()
|
24
30
|
```
|
package/index.js
CHANGED
@@ -1,16 +1,20 @@
|
|
1
|
-
const {
|
2
|
-
const ipfsClient = async () =>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
const ipfs = await ipfsClient();
|
12
|
-
const saveData = await ipfs.add(JSON.stringify({ name: "sharvan" }));
|
13
|
-
console.log(saveData)
|
14
|
-
};
|
1
|
+
const {create}= require('ipfs-http-client')
|
2
|
+
const ipfsClient = async () =>{
|
3
|
+
const options ={
|
4
|
+
host:'ipfs.infura.io',
|
5
|
+
port:5001,
|
6
|
+
protocol:'https',
|
7
|
+
|
8
|
+
}
|
9
|
+
const ipfs = await create(options);
|
10
|
+
return ipfs;
|
15
11
|
|
16
|
-
|
12
|
+
}
|
13
|
+
|
14
|
+
( async function(){
|
15
|
+
|
16
|
+
const addText = await ipfsClient();
|
17
|
+
const storeResult = await addText.add('npm package manager')
|
18
|
+
console.log(storeResult)
|
19
|
+
|
20
|
+
})()
|