ai-from-stream
Advanced tools
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); | ||
}); | ||
} |
{ | ||
"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 | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
3568
15
1
55
0
2
5
+ Addedasynciterable@^1.0.0
+ Addedis-stream@^1.1.0
+ Addedasynciterable@1.1.0(transitive)
+ Addedis-stream@1.1.0(transitive)