You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

ipfs-utils

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.4 to 2.0.0

35

CHANGELOG.md

@@ -0,1 +1,36 @@

<a name="2.0.0"></a>
# [2.0.0](https://github.com/ipfs/js-ipfs-utils/compare/v1.2.4...v2.0.0) (2020-04-09)
### Bug Fixes
* simplify http client ([#35](https://github.com/ipfs/js-ipfs-utils/issues/35)) ([05c4c5d](https://github.com/ipfs/js-ipfs-utils/commit/05c4c5d))
### BREAKING CHANGES
* - The `.ndjson`, `.stream` and `.iterator` methods have been removed
- An `.ndjson` async generator function has been added to the response which
does the same thing the `.ndjson` instance method used to
Old:
```javascript
for await (const datum of http.ndjson('http://...')) {
}
```
New:
```javascript
const response = await http.post('http://...')
for await (const datum of response.ndjson()) {
}
```
<a name="1.2.4"></a>

@@ -2,0 +37,0 @@ ## [1.2.4](https://github.com/ipfs/js-ipfs-utils/compare/v1.2.3...v1.2.4) (2020-04-08)

2

package.json
{
"name": "ipfs-utils",
"version": "1.2.4",
"version": "2.0.0",
"description": "Package to aggregate shared logic and dependencies for the IPFS ecosystem",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -139,2 +139,18 @@ /* eslint-disable no-undef */

response.ndjson = async function * () {
const it = streamToAsyncIterator(response.body)
if (!isAsyncIterator(it)) {
throw new Error('Can\'t convert fetch body into a Async Iterator:')
}
for await (const chunk of ndjson(it)) {
if (options.transform) {
yield options.transform(chunk)
} else {
yield chunk
}
}
}
return response

@@ -187,48 +203,2 @@ }

}
/**
* @param {string | URL | Request} resource
* @param {APIOptions} options
* @returns {Promise<ReadableStream<Uint8Array>>}
*/
async stream (resource, options = {}) {
const res = await this.fetch(resource, merge(this.opts, options))
return res.body
}
/**
* @param {string | URL | Request} resource
* @param {APIOptions} options
* @returns {AsyncGenerator<Uint8Array, void, any>}
*/
async * iterator (resource, options = {}) {
const res = await this.fetch(resource, merge(this.opts, options))
const it = streamToAsyncIterator(res.body)
if (!isAsyncIterator(it)) {
throw new Error('Can\'t convert fetch body into a Async Iterator:')
}
for await (const chunk of it) {
yield chunk
}
}
/**
* @param {string | URL | Request} resource
* @param {APIOptions} options
* @returns {AsyncGenerator<Object, void, any>}
*/
ndjson (resource, options = {}) {
const source = ndjson(this.iterator(resource, merge(this.opts, options)))
if (options.transform) {
return (async function * () {
for await (const chunk of source) {
yield options.transform(chunk)
}
})()
}
return source
}
}

@@ -314,3 +284,2 @@

HTTP.TimeoutError = TimeoutError
HTTP.ndjson = ndjson
HTTP.streamToAsyncIterator = streamToAsyncIterator

@@ -317,0 +286,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc