Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ai-from-stream

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ai-from-stream - npm Package Compare versions

Comparing version 0.0.1 to 1.0.0

15

index.js

@@ -1,3 +0,14 @@

export default function aiFromStream() {
return 42;
import AsyncIterable from "asynciterable";
/**
* Create an async iterable from a stream
* @param {ReadableStream} stream the stream to transform
* @return {AsyncIterable} converted iterator
*/
export default function aiFromStream(stream) {
return new AsyncIterable((write, end, error) => {
stream.on("data", write);
stream.on("end", end);
stream.on("error", error);
});
}

22

package.json
{
"name": "ai-from-stream",
"version": "0.0.1",
"version": "1.0.0",
"description": "create an async iterable from a stream",

@@ -13,17 +13,10 @@ "repository": "parro-it/ai-from-stream",

"scripts": {
"test": "ava && linterjs .",
"dev": "ava --watch & linterjs . --watch",
"start": "node -r @std/esm ./index.js",
"test": "node --harmony_async_iteration -r @std/esm test.js | tap-colorize - && linterjs .",
"doc": "documentation readme index.js --section=API"
},
"engines": {
"node": ">8.8"
"node": ">9"
},
"keywords": [],
"tonicExampleFilename": "example.js",
"ava": {
"require": [
"@std/esm"
]
},
"@std/esm": {

@@ -35,6 +28,11 @@ "esm": "js",

"@std/esm": "^0.16.0",
"ava": "^0.23.0",
"documentation": "^5.3.3",
"linterjs": "^1.11.0"
"linterjs": "^1.11.0",
"tap-colorize": "^1.2.0",
"tape-async": "^2.3.0"
},
"dependencies": {
"asynciterable": "^1.0.0",
"is-stream": "^1.1.0"
}
}

@@ -8,21 +8,34 @@ # ai-from-stream

background details relevant to understanding what this module does
This module convert an instance of readable node Stream into an async iterable.
## Usage
description of the example
Write content of a file in a for loop:
```js
const aiFromStream = require('ai-from-stream');
import fromStream from ".";
import { createReadStream } from "fs";
console.log({aiFromStream});
const stream = createReadStream(`file.txt`, "utf8");
for await (const chunk of fromStream(stream)) {
console.log(chunk);
}
```
This will output
This will output the content of `file.txt` file
```
```
## API
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
### aiFromStream
Create an async iterable from a stream
**Parameters**
* `stream` **ReadableStream** the stream to transform
Returns **AsyncIterable** converted iterator
## Install

@@ -38,3 +51,3 @@

- [`noffle/common-readme`](https://github.com/noffle/common-readme)
* [`noffle/common-readme`](https://github.com/noffle/common-readme)

@@ -44,2 +57,1 @@ ## License

MIT
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