Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

stream-match

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-match - npm Package Compare versions

Comparing version
4.0.1
to
4.1.0
+7
-2
index.js

@@ -1,2 +0,4 @@

const streamMatch = async (stream, pattern) => {
import { abortableSource } from 'abortable-iterator'
const streamMatch = async (stream, pattern, { signal } = {}) => {
const match =

@@ -7,3 +9,6 @@ typeof pattern === 'string'

let buf = ''
for await (const data of stream) {
const it = signal
? abortableSource(stream, signal)
: stream
for await (const data of it) {
buf += data

@@ -10,0 +15,0 @@ const res = match(buf)

{
"name": "stream-match",
"version": "4.0.1",
"version": "4.1.0",
"license": "MIT",

@@ -17,3 +17,6 @@ "description": "Match a string in a stream. Zero dependencies",

"test": "^3.2.1"
},
"dependencies": {
"abortable-iterator": "^5.0.1"
}
}
# stream-match
Match a regexp or string in a stream. Zero dependencies.
Match a regexp or string in a stream.

@@ -26,6 +26,9 @@ ## Usage

### res = await match(stream, pattern || string)
### res = await match(stream, pattern || string, { signal? })
Pass the optional `{ signal }` with an `AbortController#signal` to abort early.
In this case, an `Error` with `.code = 'ABORT_ERR'` will be thrown.
## License
MIT
+10
-0

@@ -90,1 +90,11 @@ import test from 'test'

})
test('signal', async () => {
const stream = new PassThrough()
const signal = AbortSignal.timeout(1)
assert.rejects(
match(stream, 'beep', { signal }),
{ code: 'ABORT_ERR' }
)
})