-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add a few examples to README.md #534
Changes from 5 commits
f4ce915
9b45d2f
d238e0d
df056ae
d9683b5
933b631
a0c06cb
f30ff6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,8 @@ This project is available through [npm](https://www.npmjs.com/). To install: | |
$ npm install ipfs --save | ||
``` | ||
|
||
Requires npm@3 and node >= 4, tested on OSX & Linux, expected to work on Windows. | ||
|
||
### Use in Node.js | ||
|
||
To include this project programmatically: | ||
|
@@ -110,8 +112,40 @@ The last published version of the package become [available for download](htt | |
|
||
### Examples | ||
|
||
> **Will come soon** | ||
```js | ||
var fs = require('fs'); | ||
var promisify = require('promisify-es6') | ||
|
||
var IPFS = require('ipfs') | ||
var node = new IPFS() | ||
|
||
function displayVersion() { | ||
console.log(node.version()); | ||
} | ||
|
||
function initializeRepo() { | ||
node.init(function(err){ | ||
console.log(err); | ||
}) | ||
} | ||
|
||
function startDaemon() { | ||
node.goOnline(function(msg) {}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will fix this up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the idea that you would go online do some work and then go offline. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was my thought at least, did you have something else in mind? |
||
} | ||
|
||
function addFile() { | ||
var readStream = fs.createReadStream('PathOfFileToAdd'); | ||
node.files.add(readStream).then(function(hash) { | ||
console.log(hash); | ||
}); | ||
} | ||
|
||
function catFile() { | ||
node.files.cat('HashOfExistingFile').then(function(stream) { | ||
stream.pipe(process.stdout, { end : false }); | ||
}); | ||
} | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please change the code style to be consistent with our code base, i.e standard There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your feedback. I will read the standard and apply. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you :) |
||
### API | ||
|
||
A complete API definition will come, meanwhile, you can learn how to you use js-ipfs throught he standard interface at [![](https://img.shields.io/badge/interface--ipfs--core-API%20Docs-blue.svg)](https://github.com/ipfs/interface-ipfs-core) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable
promisify
does not seem to be used anywhere below in your examples.(Should you decide to delete this line?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove that line. Thank you.