File tree Expand file tree Collapse file tree 10 files changed +47
-47
lines changed
Expand file tree Collapse file tree 10 files changed +47
-47
lines changed Original file line number Diff line number Diff line change @@ -84,15 +84,19 @@ By default IPFS is bundled with [dag-pb](https://www.npmjs.com/package/ipld-dag-
8484To configure other types, we must pass the ` ipld.formats ` option to the ` IPFS.create() ` function:
8585
8686``` javascript
87- const IPFS = require (" ipfs" );
87+ import * as IPFS from ' ipfs'
88+ import * as ipldGit from ' ipld-git'
89+ import * as ipldZcash from ' ipld-zcash'
90+ import * as ipldBitcoin from ' ipld-bitcoin'
91+ import * as ipldEth from ' ipld-ethereum'
8892
8993const node = await IPFS .create ({
9094 ipld: {
9195 formats: [
92- require ( " ipld-git " ) ,
93- require ( " ipld-zcash " ) ,
94- require ( " ipld-bitcoin " ) ,
95- ... Object .values (require ( " ipld-ethereum " ) ), // this format exports multiple codecs so flatten into a list
96+ ipldGit ,
97+ ipldZcash ,
98+ ipldBitcoin ,
99+ ... Object .values (ipldEth ), // this format exports multiple codecs so flatten into a list
96100 // etc, etc
97101 ],
98102 },
Original file line number Diff line number Diff line change 1- 'use strict'
2-
3- const IPFS = require ( 'ipfs-core' )
1+ import * as IPFS from 'ipfs-core'
42
53function createNode ( options ) {
64 options = options || { }
@@ -20,4 +18,4 @@ function createNode (options) {
2018 } )
2119}
2220
23- module . exports = createNode
21+ export default createNode
Original file line number Diff line number Diff line change 1- 'use strict'
1+ import createNode from './create-node.js'
2+ import path from 'path'
3+ import { CID } from 'multiformats/cid'
4+ import * as MultihashDigest from 'multiformats/hashes/digest'
5+ import fs from 'fs/promises'
6+ import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
7+ import { convert } from 'ipld-format-to-blockcodec'
8+ import sha3 from 'js-sha3'
9+ import { fileURLToPath } from 'url'
10+ import * as ipldEth from 'ipld-ethereum'
211
3- const createNode = require ( './create-node' )
4- const path = require ( 'path' )
5- const { CID } = require ( 'multiformats/cid' )
6- const MultihashDigest = require ( 'multiformats/hashes/digest' )
7- const fs = require ( 'fs' ) . promises
8- const { toString : uint8ArrayToString } = require ( 'uint8arrays/to-string' )
9- const { convert } = require ( 'ipld-format-to-blockcodec' )
10- const sha3 = require ( 'js-sha3' )
12+ const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
1113
1214async function main ( ) {
1315 const ipfs = await createNode ( {
1416 ipld : {
1517 codecs : [
16- ...Object . values ( require ( 'ipld-ethereum' ) ) . map ( format => convert ( format ) )
18+ ...Object . values ( ipldEth ) . map ( format => convert ( format ) )
1719 ] ,
1820 hashers : [ {
1921 name : 'keccak-256' ,
Original file line number Diff line number Diff line change 1- 'use strict'
2-
3- const createNode = require ( './create-node' )
4- const { fromString : uint8ArrayFromString } = require ( 'uint8arrays/from-string' )
1+ import createNode from './create-node.js'
2+ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
53
64async function main ( ) {
75 const ipfs = await createNode ( )
Original file line number Diff line number Diff line change 1- 'use strict'
2-
3- const createNode = require ( './create-node' )
1+ import createNode from './create-node.js'
42
53async function main ( ) {
64 const ipfs = await createNode ( )
Original file line number Diff line number Diff line change 1- 'use strict'
2-
3- const createNode = require ( './create-node' )
1+ import createNode from './create-node.js'
42
53async function main ( ) {
64 const ipfs = await createNode ( )
Original file line number Diff line number Diff line change 1- 'use strict'
1+ import createNode from './create-node.js'
2+ import path from 'path'
3+ import { CID } from 'multiformats/cid'
4+ import * as MultihashDigest from 'multiformats/hashes/digest'
5+ import fs from 'fs/promises'
6+ import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
7+ import { convert } from 'ipld-format-to-blockcodec'
8+ import crypto from 'crypto'
9+ import { fileURLToPath } from 'url'
10+ import ipldGit from 'ipld-git'
211
3- const createNode = require ( './create-node' )
4- const path = require ( 'path' )
5- const { CID } = require ( 'multiformats/cid' )
6- const MultihashDigest = require ( 'multiformats/hashes/digest' )
7- const fs = require ( 'fs' ) . promises
8- const { toString : uint8ArrayToString } = require ( 'uint8arrays/to-string' )
9- const { convert } = require ( 'ipld-format-to-blockcodec' )
10- const crypto = require ( 'crypto' )
12+ const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
1113
1214async function main ( ) {
1315 const ipfs = await createNode ( {
1416 ipld : {
1517 codecs : [
16- convert ( require ( 'ipld-git' ) )
18+ convert ( ipldGit )
1719 ] ,
1820 hashers : [ {
1921 name : 'sha1' ,
Original file line number Diff line number Diff line change 22 "name" : " example-traverse-ipld-graphs" ,
33 "version" : " 2.0.1" ,
44 "private" : true ,
5+ "type" : " module" ,
56 "description" : " How to traverse IPLD graphs" ,
67 "keywords" : [],
78 "license" : " MIT" ,
1415 },
1516 "dependencies" : {
1617 "@ipld/dag-pb" : " ^2.1.3" ,
17- "ipfs-core" : " ^0.14.0 " ,
18+ "ipfs-core" : " ^0.15.2 " ,
1819 "ipld-ethereum" : " ^6.0.0" ,
1920 "ipld-format-to-blockcodec" : " 0.0.1" ,
2021 "ipld-git" : " ^0.6.1" ,
2122 "js-sha3" : " ^0.8.0" ,
22- "multiformats" : " ^9.4.1 "
23+ "multiformats" : " ^9.6.5 "
2324 },
2425 "devDependencies" : {
2526 "test-util-ipfs-example" : " ^1.0.2"
Original file line number Diff line number Diff line change 1- 'use strict'
2-
3- const createNode = require ( './create-node' )
1+ import createNode from './create-node.js'
42
53async function main ( ) {
64 const ipfs = await createNode ( )
Original file line number Diff line number Diff line change 1- 'use strict'
1+ import path from 'path'
2+ import { node } from 'test-util-ipfs-example'
3+ import { fileURLToPath } from 'url'
24
3- const path = require ( 'path' )
4- const { node } = require ( 'test-util-ipfs-example' ) ;
5+ const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
56
67async function runTest ( ) {
78 console . info ( 'Testing put.js' )
You can’t perform that action at this time.
0 commit comments