ipfs-demo 1.0.6 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +28 -4
- package/index.js +19 -15
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,6 +1,30 @@
|
|
1
1
|
|
2
|
-
#
|
2
|
+
# IPFS implementations
|
3
3
|
```javascript
|
4
|
-
(
|
5
|
-
|
6
|
-
|
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
|
+
|
15
|
+
}
|
16
|
+
|
17
|
+
```
|
18
|
+
***
|
19
|
+
## function expression implementation (IIF)
|
20
|
+
---
|
21
|
+
``` javascript
|
22
|
+
|
23
|
+
( async function(){
|
24
|
+
|
25
|
+
const addText = await ipfsClient();
|
26
|
+
const storeResult = await addText.add('npm package manager')
|
27
|
+
console.log(storeResult)
|
28
|
+
|
29
|
+
})()
|
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
|
+
})()
|