From 58c7a206140aad726adc9317a1afa398ecd7b428 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 23 Oct 2017 10:35:35 +0100 Subject: [PATCH 1/8] docs: update API docs section (#614) --- README.md | 247 ++++++++++++++++++++++++------------------------------ 1 file changed, 110 insertions(+), 137 deletions(-) diff --git a/README.md b/README.md index 2a2dff488..7be48dc3e 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ - [In a web browser from CDN](#in-a-web-browser-from-cdn) - [CORS](#cors) - [Usage](#usage) - - [API](#api) + - [API Docs](#api) - [Callbacks and promises](#callbacks-and-promises) - [Contribute](#contribute) - [License](#license) @@ -156,11 +156,111 @@ $ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\"PUT\", \"P ### API +[![](https://github.com/ipfs/interface-ipfs-core/raw/master/img/badge.png)](https://github.com/ipfs/interface-ipfs-core) + > `js-ipfs-api` follows the spec defined by [`interface-ipfs-core`](https://github.com/ipfs/interface-ipfs-core), which concerns the interface to expect from IPFS implementations. This interface is a currently active endeavor. You can use it today to consult the methods available. -#### Caveats +#### `Files` + +- [files](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/FILES) + - [`ipfs.files.add(data, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/FILES.md#add) + - alias to `ipfs.add` + - [`ipfs.files.createAddStream([options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/FILES.md#createaddstream) + - [`ipfs.files.cat(multihash, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/FILES.md#cat) + - alias to `ipfs.cat` + - [`ipfs.files.get(hash, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/FILES.md#get) + - alias to `ipfs.get` + - `ipfs.ls` + - mfs (mutable file system) specific: + - [`ipfs.files.cp`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#cp) + - [`ipfs.files.ls`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#ls) + - [`ipfs.files.mkdir`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#mkdir) + - [`ipfs.files.stat`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#stat) + - [`ipfs.files.rm`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#rm) + - [`ipfs.files.read`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#read) + - [`ipfs.files.write`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#write) + - [`ipfs.files.mv`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#mv) +- [block](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BLOCK.md) + - [`ipfs.block.get(cid, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BLOCK.md#get) + - [`ipfs.block.put(block, cid, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BLOCK.md#put) + - [`ipfs.block.stat(cid, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BLOCK.md#stat) +- [repo](https://github.com/ipfs/interface-ipfs-core/tree/master/API/repo) + - [`ipfs.repo.stat()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/repo#stat) + - [`ipfs.repo.gc()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/repo#gc) + +#### `Graph` + +- [dag (not implemented, yet!)](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/DAG.md) + - [`ipfs.dag.put(dagNode, options, callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/DAG.md#dagput) + - [`ipfs.dag.get(cid [, path, options], callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/DAG.md#dagget) + - [`ipfs.dag.tree(cid [, path, options], callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/DAG.md#dagtree) +- [object](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md). + - [`ipfs.object.new([template][, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectnew) + - [`ipfs.object.put(obj, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectput) + - [`ipfs.object.get(multihash, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectget) + - [`ipfs.object.data(multihash, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectdata) + - [`ipfs.object.links(multihash, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectlinks) + - [`ipfs.object.stat(multihash, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectstat) + - [`ipfs.object.patch.addLink(multihash, DAGLink, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectpatchaddlink) + - [`ipfs.object.patch.rmLink(multihash, DAGLink, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectpatchrmlink) + - [`ipfs.object.patch.appendData(multihash, data, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectpatchappenddata) + - [`ipfs.object.patch.setData(multihash, data, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectpatchsetdata) +- [pin](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/) + - [`ipfs.pin.add()`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/PIN.md#add) + - [`ipfs.pin.rm()`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/PIN.md#rm) + - [`ipfs.pin.ls()`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/PIN.md#ls) +- [refs](https://github.com/ipfs/interface-ipfs-core/tree/master/API/refs) + - [`ipfs.refs.local()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/refs#local) + + +#### `Network` + +- [bootstrap](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/) + - `ipfs.bootstrap.list` + - `ipfs.bootstrap.add` + - `ipfs.bootstrap.rm` +- [bitswap](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/) + - `ipfs.bitswap.wantlist()` + - `ipfs.bitswap.stat()` + - `ipfs.bitswap.unwant()` +- [dht](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/) + - [`ipfs.dht.findprovs()`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/DHT.md#findprovs) + - [`ipfs.dht.get()`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/DHT.md#get) + - [`ipfs.dht.put()`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/DHT.md#put) +- [pubsub](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/PUBSUB.md) + - [`ipfs.pubsub.subscribe(topic, options, handler, callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/PUBSUB.md#pubsubsubscribe) + - [`ipfs.pubsub.unsubscribe(topic, handler)`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/PUBSUB.md#pubsubunsubscribe) + - [`ipfs.pubsub.publish(topic, data, callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/PUBSUB.md#pubsubpublish) + - [`ipfs.pubsub.ls(topic, callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/PUBSUB.md#pubsubls) + - [`ipfs.pubsub.peers(topic, callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/PUBSUB.md#pubsubpeers) +- [swarm](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/SWARM.md) + - [`ipfs.swarm.addrs([callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/SWARM.md#addrs) + - [`ipfs.swarm.connect(addr, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/SWARM.md#connect) + - [`ipfs.swarm.disconnect(addr, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/SWARM.md#disconnect) + - [`ipfs.swarm.peers([opts] [, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/SWARM.md#peers) +- [name](https://github.com/ipfs/interface-ipfs-core/tree/master/API/name) + - [`ipfs.name.publish()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/name#publish) + - [`ipfs.name.resolve()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/name#resolve) + +#### `Node Management` + +- [miscellaneous operations](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/MISCELLANEOUS.md) + - [`ipfs.id([callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/MISCELLANEOUS.md#id) + - [`ipfs.version([callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/MISCELLANEOUS.md#version) + - [`ipfs.ping()`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/MISCELLANEOUS.md#ping) +- [config](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/CONFIG.md) + - [`ipfs.config.get([key, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/CONFIG.md#configget) + - [`ipfs.config.set(key, value, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/CONFIG.md#configset) + - [`ipfs.config.replace(config, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/CONFIG.md#configreplace) +- log: + - [`ipfs.log.ls([callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/generic) + - [`ipfs.log.tail([callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/generic) + - [`ipfs.log.level(subsystem, level, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/generic) +- key: + - [`ipfs.key.gen(name, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/key#gen) + - [`ipfs.key.list([options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/key#list) -##### Pubsub +#### `Pubsub Caveat` **Currently, the [PubSub API only works in Node.js envinroment](https://github.com/ipfs/js-ipfs-api/issues/518)** @@ -182,135 +282,13 @@ This means: - See https://github.com/ipfs/js-ipfs for details on pubsub in js-ipfs -##### [bitswap](https://github.com/ipfs/interface-ipfs-core/tree/master/API/bitswap) - -- [`ipfs.bitswap.wantlist()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/bitswap#wantlist) -- [`ipfs.bitswap.stat()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/bitswap#stat) -- [`ipfs.bitswap.unwant()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/bitswap#unwant) - -##### [block](https://github.com/ipfs/interface-ipfs-core/tree/master/API/block) - -- [`ipfs.block.get(cid, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/block#get) -- [`ipfs.block.put(block, cid, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/block#put) -- [`ipfs.block.stat(cid, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/block#stat) - -##### [bootstrap](https://github.com/ipfs/interface-ipfs-core/tree/master/API/bootstrap) - -- [`ipfs.bootstrap.list()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/bootstrap#list) -- [`ipfs.bootstrap.add()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/bootstrap#add) -- [`ipfs.bootstrap.rm()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/bootstrap#rm) - -##### [config](https://github.com/ipfs/interface-ipfs-core/tree/master/API/config) - -- [`ipfs.config.get([key, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/config#configget) -- [`ipfs.config.set(key, value, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/config#configset) -- [`ipfs.config.replace(config, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/config#configreplace) - -##### [dag (not implemented, yet!)](https://github.com/ipfs/interface-ipfs-core/tree/master/API/dag) - -- [`ipfs.dag.put(dagNode, options, callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/dag#dagput) -- [`ipfs.dag.get(cid [, path, options], callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/dag#dagget) -- [`ipfs.dag.tree(cid [, path, options], callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/dag#dagtree) - -##### [dht](https://github.com/ipfs/interface-ipfs-core/tree/master/API/dht) - -- [`ipfs.dht.findprovs()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/dht#findprovs) -- [`ipfs.dht.get()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/dht#get) -- [`ipfs.dht.put()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/dht#put) - -##### [files](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files) - -- [`ipfs.files.add(data, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#add) - - alias to `ipfs.add` -- [`ipfs.files.createAddStream([options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#createaddstream) -- [`ipfs.files.cat(multihash, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#cat) - - alias to `ipfs.cat` -- [`ipfs.files.get(hash, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#get) - - alias to `ipfs.get` -- [`ipfs.ls`]() -- mfs (mutable file system) specific: - - [`ipfs.files.cp`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#cp) - - [`ipfs.files.ls`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#ls) - - [`ipfs.files.mkdir`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#mkdir) - - [`ipfs.files.stat`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#stat) - - [`ipfs.files.rm`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#rm) - - [`ipfs.files.read`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#read) - - [`ipfs.files.write`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#write) - - [`ipfs.files.mv`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/files#mv) - -##### [generic operations](https://github.com/ipfs/interface-ipfs-core/tree/master/API/generic) - -- [`ipfs.id([callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/generic#id) -- [`ipfs.version([callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/generic#version) -- [`ipfs.ping()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/generic#ping) - -- log: - - [`ipfs.log.ls([callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/generic) - - [`ipfs.log.tail([callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/generic) - - [`ipfs.log.level(subsystem, level, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/generic) - -- key: - - [`ipfs.key.gen(name, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/key#gen) - - [`ipfs.key.list([options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/key#list) - -##### [name](https://github.com/ipfs/interface-ipfs-core/tree/master/API/name) - -- [`ipfs.name.publish()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/name#publish) -- [`ipfs.name.resolve()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/name#resolve) - -##### [object](https://github.com/ipfs/interface-ipfs-core/tree/master/API/object) - -- [`ipfs.object.new([template][, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/object#objectnew) -- [`ipfs.object.put(obj, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/object#objectput) -- [`ipfs.object.get(multihash, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/object#objectget) -- [`ipfs.object.data(multihash, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/object#objectdata) -- [`ipfs.object.links(multihash, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/object#objectlinks) -- [`ipfs.object.stat(multihash, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/object#objectstat) -- [`ipfs.object.patch.addLink(multihash, DAGLink, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/object#objectpatchaddlink) -- [`ipfs.object.patch.rmLink(multihash, DAGLink, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/object#objectpatchrmlink) -- [`ipfs.object.patch.appendData(multihash, data, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/object#objectpatchappenddata) -- [`ipfs.object.patch.setData(multihash, data, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/object#objectpatchsetdata) - -##### [pin](https://github.com/ipfs/interface-ipfs-core/tree/master/API/pin) - -- [`ipfs.pin.add()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/pin#add) -- [`ipfs.pin.rm()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/pin#rm) -- [`ipfs.pin.ls()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/pin#ls) - -##### [pubsub (not implemented, yet!)](https://github.com/ipfs/interface-ipfs-core/tree/master/API/pubsub) - -> active branch: https://github.com/ipfs/js-ipfs-api/pull/493 - -- [`ipfs.pubsub.subscribe(topic, options, handler, callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/pubsub#pubsubsubscribe) -- [`ipfs.pubsub.unsubscribe(topic, handler)`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/pubsub#pubsubunsubscribe) -- [`ipfs.pubsub.publish(topic, data, callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/pubsub#pubsubpublish) -- [`ipfs.pubsub.ls(topic, callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/pubsub#pubsubls) -- [`ipfs.pubsub.peers(topic, callback)`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/pubsub#pubsubpeers) - -##### [refs](https://github.com/ipfs/interface-ipfs-core/tree/master/API/refs) - -- [`ipfs.refs.local()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/refs#local) - -##### [repo](https://github.com/ipfs/interface-ipfs-core/tree/master/API/repo) - -- [`ipfs.repo.stat()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/repo#stat) -- [`ipfs.repo.gc()`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/repo#gc) - -##### [swarm](https://github.com/ipfs/interface-ipfs-core/tree/master/API/swarm) - -- [`ipfs.swarm.addrs([callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/swarm#addrs) -- [`ipfs.swarm.connect(addr, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/swarm#connect) -- [`ipfs.swarm.disconnect(addr, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/swarm#disconnect) -- [`ipfs.swarm.peers([opts] [, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/API/swarm#peers) - -### Utility functions +#### `Utility functions` Adding to the methods defined by [`interface-ipfs-core`](https://github.com/ipfs/interface-ipfs-core), `js-ipfs-api` exposes a set of extra utility methods. These utility functions are scoped behind the `ipfs.util`. Complete documentation for these methods is coming with: https://github.com/ipfs/js-ipfs-api/pull/305 - -#### Add files or entire directories from the FileSystem to IPFS +##### Add files or entire directories from the FileSystem to IPFS > `ipfs.util.addFromFs(path, option, callback)` @@ -321,9 +299,7 @@ Reads a file or folder from `path` on the filesystem and adds it to IPFS. Optio ```JavaScript ipfs.util.addFromFs('path/to/a/folder', { recursive: true , ignore: ['subfolder/to/ignore/**']}, (err, result) => { - if (err) { - throw err - } + if (err) { throw err } console.log(result) }) ``` @@ -340,7 +316,7 @@ ipfs.util.addFromFs('path/to/a/folder', { recursive: true , ignore: ['subfolder/ ] ``` -#### Add a file from a URL to IPFS +##### Add a file from a URL to IPFS > `ipfs.util.addFromURL(url, callback)` @@ -354,7 +330,7 @@ ipfs.util.addFromURL('http://example.com/', (err, result) => { ``` -#### Add a file from a stream to IPFS +##### Add a file from a stream to IPFS > `ipfs.util.addFromStream(stream, callback)` @@ -369,7 +345,7 @@ ipfs.util.addFromStream(, (err, result) => { }) ``` -### Callbacks and promises +### Callbacks and Promises If you do not pass in a callback all API functions will return a `Promise`. For example: @@ -383,8 +359,7 @@ ipfs.id() }) ``` -This relies on a global `Promise` object. If you are in an environment where that is not -yet available you need to bring your own polyfill. +This relies on a global `Promise` object. If you are in an environment where that is not yet available you need to bring your own polyfill. ## Development @@ -392,8 +367,6 @@ yet available you need to bring your own polyfill. We run tests by executing `npm test` in a terminal window. This will run both Node.js and Browser tests, both in Chrome and PhantomJS. To ensure that the module conforms with the [`interface-ipfs-core`](https://github.com/ipfs/interface-ipfs-core) spec, we run the batch of tests provided by the interface module, which can be found [here](https://github.com/ipfs/interface-ipfs-core/tree/master/src). - - ## Contribute The js-ipfs-api is a work in progress. As such, there's a few things you can do right now to help out: From e545562f0cdc7ab5447047da57cc27d11044d200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Tenorio-Forn=C3=A9s?= Date: Thu, 26 Oct 2017 14:36:48 +0200 Subject: [PATCH 2/8] change gulp for npm tasks in contributing file (#617) --- CONTRIBUTING.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c8675986..33fe54e07 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,14 +2,14 @@ ## Setup -You should have [node.js], [npm] and [gulp] installed. +You should have [node.js] and [npm] installed. ## Linting Linting is done using [eslint] and the rules are based on [standard]. ```bash -$ gulp lint +$ npm run lint ``` ## Tests @@ -17,19 +17,19 @@ $ gulp lint Tests in node ```bash -$ gulp test:node +$ npm run test:node ``` Tests in the browser ```bash -$ gulp test:browser +$ npm run test:browser ``` ## Building browser version ```bash -$ gulp build +$ npm run build ``` ## Releases @@ -45,15 +45,14 @@ The `release` task will ```bash # Major release -$ gulp release --major +$ npm run release-major # Minor relase -$ gulp release --minor +$ npm run release-minor # Patch release -$ gulp release +$ npm run release ``` [node.js]: https://nodejs.org/ [npm]: http://npmjs.org/ -[gulp]: http://gulpjs.com/ [eslint]: http://eslint.org/ [standard]: https://github.com/feross/standard From 92fb5a969ddacf4264da0d343aa4414ad4ed209f Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 30 Oct 2017 09:33:59 +0000 Subject: [PATCH 3/8] docs: update API docs section (#618) From 6a7d5ef5ca9afe6ec0579b9b6fa3ca3f7c00c3e0 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 30 Oct 2017 09:16:26 +0000 Subject: [PATCH 4/8] chore: update deps --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 24379691a..0fcd7f7fc 100644 --- a/package.json +++ b/package.json @@ -60,12 +60,12 @@ "url": "https://github.com/ipfs/js-ipfs-api" }, "devDependencies": { - "aegir": "^12.1.0", + "aegir": "^12.1.1", "chai": "^4.1.2", "dirty-chai": "^2.0.1", "eslint-plugin-react": "^7.4.0", "gulp": "^3.9.1", - "interface-ipfs-core": "~0.33.0", + "interface-ipfs-core": "~0.33.1", "hapi": "^16.6.2", "ipfsd-ctl": "~0.24.0", "pre-commit": "^1.2.2", From 853b6142776dd03983c84d93e7b5c9dca341f8c8 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 30 Oct 2017 09:37:27 +0000 Subject: [PATCH 5/8] docs: some nitpicks on the README --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7be48dc3e..727fc2147 100644 --- a/README.md +++ b/README.md @@ -307,12 +307,13 @@ ipfs.util.addFromFs('path/to/a/folder', { recursive: true , ignore: ['subfolder/ `result` is an array of objects describing the files that were added, such as: ``` -[{ - path: 'test-folder', - hash: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6', - size: 2278 -}, -// ... +[ + { + path: 'test-folder', + hash: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6', + size: 2278 + }, + // ... ] ``` @@ -351,11 +352,11 @@ If you do not pass in a callback all API functions will return a `Promise`. For ```js ipfs.id() - .then(function (id) { + .then((id) => { console.log('my id is: ', id) }) - .catch(function(err) { - console.log('Fail: ', err) + .catch((err) => { + console.log('Fail: ', err) }) ``` From 06d5683c9a209845e65a00a4605e6e8c758f440d Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 13 Nov 2017 09:37:06 +0000 Subject: [PATCH 6/8] chore: update deps --- package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 0fcd7f7fc..191503afe 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "coverage-publish": "aegir coverage --provider coveralls --no-parallel --timeout 100000" }, "dependencies": { - "async": "^2.5.0", + "async": "^2.6.0", "bs58": "^4.0.1", "cids": "~0.5.2", "concat-stream": "^1.6.0", @@ -30,9 +30,9 @@ "flatmap": "0.0.3", "glob": "^7.1.2", "glob-escape": "0.0.2", - "ipfs-block": "~0.6.0", - "ipfs-unixfs": "~0.1.13", - "ipld-dag-pb": "~0.11.2", + "ipfs-block": "~0.6.1", + "ipfs-unixfs": "~0.1.14", + "ipld-dag-pb": "~0.11.3", "is-ipfs": "^0.3.2", "is-stream": "^1.1.0", "lru-cache": "^4.1.1", @@ -42,7 +42,7 @@ "ndjson": "^1.5.0", "once": "^1.4.0", "peer-id": "~0.10.2", - "peer-info": "~0.11.0", + "peer-info": "~0.11.1", "promisify-es6": "^1.0.3", "pump": "^1.0.2", "qs": "^6.5.1", @@ -60,14 +60,14 @@ "url": "https://github.com/ipfs/js-ipfs-api" }, "devDependencies": { - "aegir": "^12.1.1", + "aegir": "^12.1.3", "chai": "^4.1.2", "dirty-chai": "^2.0.1", "eslint-plugin-react": "^7.4.0", "gulp": "^3.9.1", - "interface-ipfs-core": "~0.33.1", + "interface-ipfs-core": "~0.34.0", "hapi": "^16.6.2", - "ipfsd-ctl": "~0.24.0", + "ipfsd-ctl": "~0.24.1", "pre-commit": "^1.2.2", "socket.io": "^2.0.4", "socket.io-client": "^2.0.4", From 14e5e0e1fdb92fb7e2c3c36c67aa2789e632986e Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 13 Nov 2017 09:38:46 +0000 Subject: [PATCH 7/8] chore: update contributors --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 191503afe..2c892c984 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "contributors": [ "Alan Shaw ", "Alex Mingoia ", + "Antonio Tenorio-Fornés ", "Connor Keenan ", "Danny ", "David Braun ", From 797be7900ecf24ed387df40eae4df7fafb180271 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 13 Nov 2017 09:38:46 +0000 Subject: [PATCH 8/8] chore: release version v15.0.2 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56eee2757..e4342fb61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ + +## [15.0.2](https://github.com/ipfs/js-ipfs-api/compare/v15.0.1...v15.0.2) (2017-11-13) + + + ## [15.0.1](https://github.com/ipfs/js-ipfs-api/compare/v15.0.0...v15.0.1) (2017-10-22) diff --git a/package.json b/package.json index 2c892c984..f95cfb847 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ipfs-api", - "version": "15.0.1", + "version": "15.0.2", "description": "A client library for the IPFS HTTP API. Follows interface-ipfs-core spec", "main": "src/index.js", "browser": {