Socket
Socket
Sign inDemoInstall

stream-to-it

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-to-it - npm Package Compare versions

Comparing version 0.2.4 to 1.0.0

dist/index.min.js

179

package.json
{
"name": "stream-to-it",
"version": "0.2.4",
"version": "1.0.0",
"description": "Convert Node.js streams to streaming iterables",
"main": "index.js",
"files": [
"duplex.js",
"sink.js",
"source.js",
"transform.js"
],
"scripts": {
"test": "ava test/*.test.js --verbose",
"lint": "standard",
"coverage": "nyc --reporter=text --reporter=lcov npm test"
"author": "Alan Shaw",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/alanshaw/stream-to-it#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/alanshaw/stream-to-it.git"
},
"bugs": {
"url": "https://github.com/alanshaw/stream-to-it/issues"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"keywords": [
"stream",
"readablestream",
"async",
"iterable",
"iterator",
"async"
"readablestream",
"stream"
],
"author": "Alan Shaw",
"license": "MIT",
"dependencies": {
"get-iterator": "^1.0.2"
"type": "module",
"types": "./dist/src/index.d.ts",
"files": [
"src",
"dist",
"!dist/test",
"!**/*.tsbuildinfo"
],
"exports": {
".": {
"types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
}
},
"devDependencies": {
"ava": "^3.10.1",
"bl": "^5.0.0",
"delay": "^5.0.0",
"it-pipe": "^1.1.0",
"nyc": "^15.1.0",
"p-fifo": "^1.0.0",
"standard": "^16.0.3",
"streaming-iterables": "^6.0.0"
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
"project": true,
"sourceType": "module"
}
},
"directories": {
"test": "test"
"release": {
"branches": [
"master"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"breaking": true,
"release": "major"
},
{
"revert": true,
"release": "patch"
},
{
"type": "feat",
"release": "minor"
},
{
"type": "fix",
"release": "patch"
},
{
"type": "docs",
"release": "patch"
},
{
"type": "test",
"release": "patch"
},
{
"type": "deps",
"release": "patch"
},
{
"scope": "no-release",
"release": false
}
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"section": "Trivial Changes"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "deps",
"section": "Dependencies"
},
{
"type": "test",
"section": "Tests"
}
]
}
}
],
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/github",
"@semantic-release/git"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/alanshaw/stream-to-it.git"
"scripts": {
"clean": "aegir clean",
"lint": "aegir lint",
"docs": "aegir docs",
"dep-check": "aegir dep-check",
"doc-check": "aegir doc-check",
"build": "aegir build",
"test": "aegir test -t node -t electron-main",
"test:node": "aegir test -t node --cov",
"test:electron-main": "aegir test -t electron-main",
"release": "aegir release"
},
"bugs": {
"url": "https://github.com/alanshaw/stream-to-it/issues"
"dependencies": {
"it-stream-types": "^2.0.1"
},
"homepage": "https://github.com/alanshaw/stream-to-it#readme"
"devDependencies": {
"@types/p-fifo": "^1.0.2",
"aegir": "^42.2.4",
"bl": "^6.0.11",
"delay": "^6.0.0",
"it-all": "^3.0.4",
"it-pipe": "^3.0.1",
"p-fifo": "^1.0.0"
},
"sideEffects": false
}
# stream-to-it
[![Build Status](https://travis-ci.org/alanshaw/stream-to-it.svg?branch=master)](https://travis-ci.org/alanshaw/stream-to-it)
[![dependencies Status](https://status.david-dm.org/gh/alanshaw/stream-to-it.svg)](https://david-dm.org/alanshaw/stream-to-it)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![codecov](https://img.shields.io/codecov/c/github/alanshaw/stream-to-it.svg?style=flat-square)](https://codecov.io/gh/alanshaw/stream-to-it)
[![CI](https://img.shields.io/github/actions/workflow/status/alanshaw/stream-to-it/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/alanshaw/stream-to-it/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
> Convert Node.js streams to streaming iterables
## Install
# About
```sh
npm i stream-to-it
```
<!--
## Usage
!IMPORTANT!
```js
const toIterable = require('stream-to-it')
```
Everything in this README between "# About" and "# Install" is automatically
generated and will be overwritten the next time the doc generator is run.
### Convert readable stream to source iterable
To make changes to this section, please update the @packageDocumentation section
of src/index.js or src/index.ts
```js
To experiment with formatting, please run "npm run docs" from the root of this
repo and examine the changes made.
-->
Seamlessly use Node.js streams with `it-pipe` and friends.
## Example - Convert readable stream to source iterable
```TypeScript
import fs from 'node:fs'
import * as toIterable from 'stream-to-it'
const readable = fs.createReadStream('/path/to/file')
// Node.js streams are already async iterable so this is just s => s
const source = toIterable.source(readable)
const source = toIterable.source<Buffer>(readable)

@@ -35,5 +44,11 @@ for await (const chunk of source) {

```js
const res = fetch('http://example.org/file.jpg')
```TypeScript
import * as toIterable from 'stream-to-it'
const res = await fetch('http://example.org/file.jpg')
if (res.body == null) {
throw new Error('Body was not set')
}
for await (const chunk of toIterable.source(res.body)) {

@@ -44,6 +59,8 @@ console.log(chunk.toString())

### Convert writable stream to sink iterable
## Example - Convert writable stream to sink iterable
```js
const pipe = require('it-pipe')
```TypeScript
import fs from 'node:fs'
import { pipe } from 'it-pipe'
import * as toIterable from 'stream-to-it'

@@ -56,6 +73,9 @@ const source = [Buffer.from('Hello '), Buffer.from('World!')]

### Convert transform stream to transform iterable
## Example - Convert transform stream to transform iterable
```js
const { Transform } = require('stream')
```TypeScript
import fs from 'node:fs'
import { Transform } from 'node:stream'
import { pipe } from 'it-pipe'
import * as toIterable from 'stream-to-it'

@@ -70,5 +90,5 @@ const output = await pipe(

// Collect and return the chunks
source => {
async source => {
const chunks = []
for await (chunk of source) chunks.push(chunk)
for await (const chunk of source) chunks.push(chunk)
return chunks

@@ -81,35 +101,26 @@ }

## API
## Related
```js
const toIterable = require('stream-to-it')
```
- [`it-to-stream`](https://www.npmjs.com/package/it-to-stream) Convert streaming iterables to Node.js streams
- [`it-pipe`](https://www.npmjs.com/package/it-pipe) Utility to "pipe" async iterables together
### `toIterable.source(readable): Function`
# Install
Convert a [`Readable`](https://nodejs.org/dist/latest/docs/api/stream.html#stream_readable_streams) stream or a browser [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) to a [source](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#source-it) iterable.
```console
$ npm i stream-to-it
```
### `toIterable.sink(writable): Function`
# API Docs
Convert a [`Writable`](https://nodejs.org/dist/latest/docs/api/stream.html#stream_writable_streams) stream to a [sink](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#sink-it) iterable.
- <https://github.com.github.io/alanshaw>
### `toIterable.transform(transform): Function`
# License
Convert a [`Transform`](https://nodejs.org/dist/latest/docs/api/stream.html#stream_duplex_and_transform_streams) stream to a [transform](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#transform-it) iterable.
Licensed under either of
### `toIterable.duplex(duplex): { sink: Function, source: Function }`
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
Convert a [`Duplex`](https://nodejs.org/dist/latest/docs/api/stream.html#stream_duplex_and_transform_streams) stream to a [duplex](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#duplex-it) iterable.
# Contribution
## Related
* [`it-to-stream`](https://www.npmjs.com/package/it-to-stream) Convert streaming iterables to Node.js streams
* [`it-pipe`](https://www.npmjs.com/package/it-pipe) Utility to "pipe" async iterables together
## Contribute
Feel free to dive in! [Open an issue](https://github.com/alanshaw/stream-to-it/issues/new) or submit PRs.
## License
[MIT](LICENSE) © Alan Shaw
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc