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

streamsearch

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

streamsearch - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

2

package.json
{ "name": "streamsearch",
"version": "0.0.2",
"version": "0.1.0",
"author": "Brian White <mscdex@mscdex.net>",

@@ -4,0 +4,0 @@ "description": "Streaming Boyer-Moore-Horspool searching for node.js",

@@ -38,8 +38,8 @@ Description

];
s.on('data', function(data, start, end) {
console.log('data: ' + inspect(data.toString('ascii', start, end)));
s.on('info', function(isMatch, data, start, end) {
if (data)
console.log('data: ' + inspect(data.toString('ascii', start, end)));
if (isMatch)
console.log('match!');
});
s.on('match', function() {
console.log('match!');
});
for (var i = 0, len = chunks.length; i < len; ++i)

@@ -70,7 +70,5 @@ s.push(chunks[i]);

* **data**(< _Buffer_ >chunk, < _integer_ >start, < _integer_ >end) - Emitted when non-needle data is available. This data is in `chunk` between `start` (inclusive) and `end` (exclusive).
* **info**(< _boolean_ >isMatch[, < _Buffer_ >chunk, < _integer_ >start, < _integer_ >end]) - A match _may_ or _may not_ have been made. In either case, a preceding `chunk` of data _may_ be available that did not match the needle. Data (if available) is in `chunk` between `start` (inclusive) and `end` (exclusive).
* **match**() - Emitted when the needle has been found in the stream.
Properties

@@ -87,3 +85,3 @@ ----------

* **(constructor)**(< _Buffer_ >needle) - Creates and returns a new instance for searching for `needle`.
* **(constructor)**(< _mixed_ >needle) - Creates and returns a new instance for searching for a _Buffer_ or _string_ `needle`.

@@ -90,0 +88,0 @@ * **push**(< _Buffer_ >chunk) - _integer_ - Processes `chunk`. The return value is the last processed index in `chunk` + 1.

@@ -16,2 +16,4 @@ /*

function SBMH(needle) {
if (typeof needle === 'string')
needle = new Buffer(needle);
var i, j, needle_len = needle.length;

@@ -60,3 +62,3 @@

// Positive: points to a position in 'data'
// Positive: points to a position in `data`
// pos == 3 points to data[3]

@@ -89,6 +91,7 @@ // Negative: points to a position in the lookbehind buffer

this._lookbehind_size = 0;
++this.matches;
if (pos > -this._lookbehind_size)
this.emit('data', lookbehind, 0, this._lookbehind_size + pos);
++this.matches;
this.emit('match');
this.emit('info', true, lookbehind, 0, this._lookbehind_size + pos);
else
this.emit('info', true);

@@ -118,3 +121,3 @@ data.bmhpos = pos + needle_len;

// Discard lookbehind buffer.
this.emit('data', lookbehind, 0, this._lookbehind_size);
this.emit('info', false, lookbehind, 0, this._lookbehind_size);
this._lookbehind_size = 0;

@@ -129,3 +132,3 @@ } else {

// The cut off data is guaranteed not to contain the needle.
this.emit('data', lookbehind, 0, bytesToCutOff);
this.emit('info', false, lookbehind, 0, bytesToCutOff);
}

@@ -157,6 +160,7 @@

&& jsmemcmp(needle, 0, data, pos, needle_len - 1)) {
++this.matches;
if (pos > 0)
this.emit('data', data, data.bmhpos, pos);
++this.matches;
this.emit('match');
this.emit('info', true, data, data.bmhpos, pos);
else
this.emit('info', true);

@@ -188,3 +192,3 @@ data.bmhpos = pos + needle_len;

if (pos > 0)
this.emit('data', data, data.bmhpos, pos < len ? pos : len);
this.emit('info', false, data, data.bmhpos, pos < len ? pos : len);

@@ -191,0 +195,0 @@ data.bmhpos = len;

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