Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 3e5967a

Browse files
author
Alan Shaw
authored
refactor: async await roundup (#1173)
This is a round up of the remaining async/await PRs along with some cleanup and docs fixes. resolves #1103 resolves #1122 resolves #1158 (hopefully!) closes #1164 closes #1165 closes #1166 closes #1169 closes #1170 closes #1172 BREAKING CHANGE: The `log.tail` method now returns an async iterator that yields log messages. Use it like: ```js for await (const message of ipfs.log.tail()) { console.log(message) } ``` BREAKING CHANGE: The response to a call to `log.level` now returns an object that has camel cased keys. i.e. `Message` and `Error` properties have changed to `message` and `error`. BREAKING CHANGE: Dropped support for go-ipfs <= 0.4.4 in `swarm.peers` response. BREAKING CHANGE: The signature for `ipfs.mount` has changed from `ipfs.mount([ipfsPath], [ipnsPath])` to `ipfs.mount([options])`. Where `options` is an optional object that may contain two boolean properties `ipfsPath` and `ipnsPath`. The response object has also changed to be camel case. See https://docs.ipfs.io/reference/api/http/#api-v0-mount. BREAKING CHANGE: Default ping `count` of 1 in client has been removed. The default ping count is now whatever the IPFS node defaults it to (currently 10). If you specifically need 1 ping message then please pass `count: 1` in options for `ipfs.ping()`. BREAKING CHANGE: Multi parameter constructor options are no longer supported. To create a new IPFS HTTP client, pass a single parameter to the constructor. The parameter can be one of: * String, formatted as one of: * Multiaddr e.g. /ip4/127.0.0.1/tcp/5001 * URL e.g. http://127.0.0.1:5001 * [Multiaddr](https://www.npmjs.com/package/multiaddr) instance * Object, in format of either: * Address and path e.g. `{ apiAddr: '/ip4/127.0.0.1/tcp/5001': apiPath: '/api/v0' }` (Note: `apiAddr` can also be a string in URL form or a Multiaddr instance) * Node.js style address e.g. `{ host: '127.0.0.1', port: 5001, protocol: 'http' }`
1 parent fc73da7 commit 3e5967a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1079
-2581
lines changed

README.md

Lines changed: 126 additions & 105 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
},
4343
"dependencies": {
4444
"abort-controller": "^3.0.0",
45-
"async": "^2.6.1",
4645
"async-iterator-all": "^1.0.0",
4746
"async-iterator-to-pull-stream": "^1.3.0",
4847
"bignumber.js": "^9.0.0",
@@ -51,58 +50,47 @@
5150
"buffer": "^5.4.2",
5251
"callbackify": "^1.1.0",
5352
"cids": "~0.7.1",
54-
"concat-stream": "github:hugomrdias/concat-stream#feat/smaller",
5553
"debug": "^4.1.0",
56-
"detect-node": "^2.0.4",
5754
"err-code": "^2.0.0",
5855
"explain-error": "^1.0.4",
59-
"flatmap": "0.0.3",
6056
"form-data": "^3.0.0",
61-
"glob": "^7.1.3",
6257
"ipfs-block": "~0.8.1",
6358
"ipfs-utils": "^0.4.0",
6459
"ipld-dag-cbor": "~0.15.0",
6560
"ipld-dag-pb": "^0.18.1",
6661
"ipld-raw": "^4.0.0",
6762
"is-ipfs": "~0.6.1",
68-
"is-pull-stream": "0.0.0",
69-
"is-stream": "^2.0.0",
70-
"iso-stream-http": "~0.1.2",
7163
"it-glob": "0.0.6",
72-
"it-tar": "^1.1.0",
64+
"it-tar": "^1.1.1",
7365
"it-to-stream": "^0.1.1",
7466
"iterable-ndjson": "^1.1.0",
75-
"kind-of": "^6.0.2",
7667
"ky": "^0.15.0",
7768
"ky-universal": "^0.3.0",
7869
"merge-options": "^2.0.0",
7970
"multiaddr": "^6.0.6",
71+
"multiaddr-to-uri": "^5.0.0",
8072
"multibase": "~0.6.0",
8173
"multicodec": "~0.5.1",
8274
"multihashes": "~0.4.14",
83-
"ndjson": "github:hugomrdias/ndjson#feat/readable-stream3",
84-
"once": "^1.4.0",
8575
"parse-duration": "^0.1.1",
8676
"peer-id": "~0.12.3",
8777
"peer-info": "~0.15.1",
88-
"promise-nodeify": "^3.0.1",
89-
"promisify-es6": "^1.0.3",
90-
"pull-defer": "~0.2.3",
91-
"pull-stream": "^3.6.9",
92-
"pull-to-stream": "~0.1.1",
93-
"pump": "^3.0.0",
94-
"qs": "^6.5.2",
95-
"readable-stream": "^3.1.1",
96-
"stream-to-pull-stream": "^1.7.2"
78+
"promise-nodeify": "^3.0.1"
9779
},
9880
"devDependencies": {
9981
"aegir": "^20.4.1",
82+
"async": "^3.1.0",
10083
"browser-process-platform": "~0.1.1",
10184
"cross-env": "^6.0.0",
85+
"detect-node": "^2.0.4",
10286
"go-ipfs-dep": "^0.4.22",
103-
"interface-ipfs-core": "^0.120.0",
87+
"interface-ipfs-core": "^0.121.0",
10488
"ipfsd-ctl": "^0.47.1",
89+
"ndjson": "^1.5.0",
10590
"nock": "^11.4.0",
91+
"promisify-es6": "^1.0.3",
92+
"pull-stream": "^3.6.14",
93+
"pump": "^3.0.0",
10694
"stream-equal": "^1.1.1"
10795
},
10896
"engines": {

src/add-from-url.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const toIterable = require('./lib/stream-to-iterable')
66
module.exports = (config) => {
77
const add = require('./add')(config)
88

9-
return (url, options) => (async function * () {
9+
return async function * addFromURL (url, options) {
1010
options = options || {}
1111

1212
const { body } = await kyDefault.get(url)
@@ -17,5 +17,5 @@ module.exports = (config) => {
1717
}
1818

1919
yield * add(input, options)
20-
})()
20+
}
2121
}

src/add/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { toFormData } = require('./form-data')
77
const toCamel = require('../lib/object-to-camel')
88

99
module.exports = configure(({ ky }) => {
10-
return (input, options) => (async function * () {
10+
return async function * add (input, options) {
1111
options = options || {}
1212

1313
const searchParams = new URLSearchParams(options.searchParams)
@@ -47,7 +47,7 @@ module.exports = configure(({ ky }) => {
4747
yield toCoreInterface(file)
4848
}
4949
}
50-
})()
50+
}
5151
})
5252

5353
function toCoreInterface ({ name, hash, size }) {

src/bitswap/stat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = configure(({ ky }) => {
77
return async (options) => {
88
options = options || {}
99

10-
const res = await ky.get('bitswap/stat', {
10+
const res = await ky.post('bitswap/stat', {
1111
timeout: options.timeout,
1212
signal: options.signal,
1313
headers: options.headers,

src/bitswap/unwant.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = configure(({ ky }) => {
1515
searchParams.set('arg', new CID(cid).toString())
1616
}
1717

18-
const res = await ky.get('bitswap/unwant', {
18+
const res = await ky.post('bitswap/unwant', {
1919
timeout: options.timeout,
2020
signal: options.signal,
2121
headers: options.headers,

src/bitswap/wantlist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = configure(({ ky }) => {
1717
}
1818
}
1919

20-
const res = await ky.get('bitswap/wantlist', {
20+
const res = await ky.post('bitswap/wantlist', {
2121
timeout: options.timeout,
2222
signal: options.signal,
2323
headers: options.headers,

src/block/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = configure(({ ky }) => {
1313
const searchParams = new URLSearchParams(options.searchParams)
1414
searchParams.set('arg', `${cid}`)
1515

16-
const data = await ky.get('block/get', {
16+
const data = await ky.post('block/get', {
1717
timeout: options.timeout,
1818
signal: options.signal,
1919
headers: options.headers,

src/block/rm-async-iterator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const toIterable = require('../lib/stream-to-iterable')
77
const toCamel = require('../lib/object-to-camel')
88

99
module.exports = configure(({ ky }) => {
10-
return async function * removeBlock (cid, options) {
10+
return async function * rm (cid, options) {
1111
options = options || {}
1212

1313
if (!Array.isArray(cid)) {

src/block/stat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = configure(({ ky }) => {
1616
const searchParams = new URLSearchParams(options.searchParams)
1717
searchParams.set('arg', `${cid}`)
1818

19-
const res = await ky.get('block/stat', {
19+
const res = await ky.post('block/stat', {
2020
timeout: options.timeout,
2121
signal: options.signal,
2222
headers: options.headers,

0 commit comments

Comments
 (0)