Comparing version 0.0.1 to 1.0.0
24
index.js
@@ -1,3 +0,23 @@ | ||
export default function aiLines() { | ||
return 42; | ||
export default async function* aiLines(stream, separator = /\n/) { | ||
let buff = { concat: s => s }; | ||
for await (const chunk of stream) { | ||
const lines = chunk.split(separator); | ||
const firstLine = lines.shift(); | ||
const lastLine = lines.pop(); | ||
buff = buff.concat(firstLine); | ||
if (typeof lastLine === "string") { | ||
yield buff; | ||
buff = lastLine; | ||
for (const otherPart of lines) { | ||
yield otherPart; | ||
} | ||
} | ||
} | ||
if (typeof buff === "string") { | ||
yield buff; | ||
} | ||
} |
{ | ||
"name": "ai-lines", | ||
"version": "0.0.1", | ||
"version": "1.0.0", | ||
"description": "Split an async iterable into lines", | ||
@@ -13,3 +13,3 @@ "repository": "parro-it/ai-lines", | ||
"scripts": { | ||
"test": "node --harmony_async_iteration -r @std/esm test.js | tap-prettify - && linterjs .", | ||
"test": "node --harmony_async_iteration -r @std/esm test.js | tap-colorize - && linterjs .", | ||
"doc": "documentation readme index.js --section=API" | ||
@@ -28,2 +28,5 @@ }, | ||
"@std/esm": "^0.16.0", | ||
"ai-concat": "^1.0.0", | ||
"ai-from-stream": "^1.0.0", | ||
"asynciterable": "^1.0.1", | ||
"documentation": "^5.3.3", | ||
@@ -30,0 +33,0 @@ "linterjs": "^1.11.0", |
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
3398
21
1
0
8