Socket
Socket
Sign inDemoInstall

match-stream

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.0 to 0.0.1

.idea/.name

19

match.js

@@ -37,7 +37,22 @@ 'use strict';

if (index >= 0) {
this._matchFn(this._bufs.splice(0, index).toBuffer(), pattern, this._bufs.toBuffer());
processMatches.call(this, index, pattern, callback);
} else {
this._matchFn(this._bufs.splice(0, this._bufs.length - chunk.length));
callback();
}
callback();
};
function processMatches(index, pattern, callback) {
var buf = this._bufs.splice(0, index).toBuffer();
if (this._opts.consume) {
this._bufs.splice(0, pattern.length);
}
this._matchFn(buf, pattern, this._bufs.toBuffer());
index = this._bufs.indexOf(pattern);
if (index > 0 || this._opts.consume && index === 0) {
process.nextTick(processMatches.bind(this, index, pattern, callback));
} else {
callback();
}
}

2

package.json
{
"name": "match-stream",
"version": "0.0.0",
"version": "0.0.1",
"description": "Match a pattern within a stream",

@@ -5,0 +5,0 @@ "main": "match.js",

@@ -12,4 +12,6 @@ match-stream [![Build Status](https://travis-ci.org/EvanOxfeld/match-stream.png)](https://travis-ci.org/EvanOxfeld/match-stream)

## Quick Example
## Quick Examples
### End stream on match
```javascript

@@ -44,2 +46,25 @@ var MatchStream = require('match-stream');

### Split stream
```javascript
var MatchStream = require('match-stream');
var fs = require('fs');
var line = "";
var loremLines = [];
var ms = new MatchStream({ pattern: '.', consume: true}, function (buf, matched, extra) {
line += buf.toString();
if (matched) {
loremLines.push(line.trim());
line = "";
}
});
fs.createReadStream('lorem.txt')
.pipe(ms)
.once('end', function() {
console.log(loremLines);
});
```
## License

@@ -46,0 +71,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc