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

Commit 6b92ece

Browse files
committed
Improve IPFS finding in example
1 parent a37b485 commit 6b92ece

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,9 @@ There's still a bit of work required to start up a node in a robust way (i.e. wi
185185
186186
```javascript
187187
// Find the IPFS implementation
188-
var IPFS
189-
if (!(typeof require === 'undefined')) {
190-
// Can load through Node
191-
IPFS = require('ipfs')
192-
} else if (!(typeof Ipfs === 'undefined')) {
193-
// Can load through browser global
194-
IPFS = Ipfs
195-
}
188+
const IPFS = typeof Ipfs !== 'undefined' ? Ipfs // browser global
189+
: typeof require === 'function' ? require('ipfs') // cjs require
190+
: throw new Error('could not load IPFS')
196191

197192
// Make an IPFS node
198193
var ipfs = new IPFS()

0 commit comments

Comments
 (0)