Socket
Socket
Sign inDemoInstall

qlobber

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qlobber - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

62

lib/qlobber.js

@@ -9,4 +9,4 @@ /**

```javascript
Qlobber = require('qlobber').Qlobber;
matcher = new Qlobber();
var Qlobber = require('qlobber').Qlobber;
var matcher = new Qlobber();
matcher.add('foo.*', 'it matched!');

@@ -31,3 +31,3 @@ assert.deepEqual(matcher.match('foo.bar'), ['it matched!']);

```javascript
matcher = new Qlobber({ remove_duplicates: true });
var matcher = new Qlobber({ remove_duplicates: true });
matcher.add('*.orange.*', 'Q1');

@@ -52,3 +52,3 @@ matcher.add('*.*.rabbit', 'Q2');

['Q2'],
['Q2'],
['Q2', 'Q2'],
[],

@@ -86,29 +86,2 @@ [],

// Polyfill Set if we don't have it. In the future when V8 implements Set fully,
// consider using it as the container in the trie instead of arrays.
var PSet;
if (typeof Set === 'undefined')
{
PSet = function ()
{
var values = [];
this.add = function (v)
{
values.push(v);
};
this.has = function (v)
{
return values.indexOf(v) >= 0;
};
};
}
else
{
PSet = Set;
}
/**

@@ -125,4 +98,2 @@ Creates a new qlobber.

- `{String} wildcard_some` The character to use for matching zero or more words in a topic. Defaults to '#'. MQTT uses '#' too.
- `{Boolean} remove_duplicates` qlobber's matching algorithm means values may be returned twice. Specify `true` to have qlobber remove duplicates from its results. Note this will incur a performance penalty. Defaults to `false`.
*/

@@ -136,3 +107,2 @@ function Qlobber (options)

this._wildcard_some = options.wildcard_some || '#';
this._remove_duplicates = options.remove_duplicates;
this._trie = {};

@@ -321,27 +291,7 @@ }

@param {String} topic The topic to match against.
@return {Array} List of values that matched the topic. This may contain duplicates unless you configured [Qlobber](#qlobberoptions) otherwise.
@return {Array} List of values that matched the topic. This may contain duplicates if more than one matcher matches the topic with the same value.
*/
Qlobber.prototype.match = function (topic)
{
var r = this._match([], 0, topic.split(this._separator), this._trie);
if (this._remove_duplicates)
{
var seen = new PSet(), r2 = [], i, v;
for (i = 0; i < r.length; i += 1)
{
v = r[i];
if (!seen.has(v))
{
r2.push(v);
seen.add(v);
}
}
return r2;
}
return r;
return this._match([], 0, topic.split(this._separator), this._trie);
};

@@ -348,0 +298,0 @@

2

package.json
{
"name": "qlobber",
"description": "Node.js globbing for amqp-like topics",
"version": "0.2.0",
"version": "0.3.0",
"homepage": "https://github.com/davedoesdev/qlobber",

@@ -6,0 +6,0 @@ "author": {

@@ -8,4 +8,4 @@ # qlobber&nbsp;&nbsp;&nbsp;[![Build Status](https://travis-ci.org/davedoesdev/qlobber.png)](https://travis-ci.org/davedoesdev/qlobber)

```javascript
Qlobber = require('qlobber').Qlobber;
matcher = new Qlobber();
var Qlobber = require('qlobber').Qlobber;
var matcher = new Qlobber();
matcher.add('foo.*', 'it matched!');

@@ -30,3 +30,3 @@ assert.deepEqual(matcher.match('foo.bar'), ['it matched!']);

```javascript
matcher = new Qlobber({ remove_duplicates: true });
var matcher = new Qlobber({ remove_duplicates: true });
matcher.add('*.orange.*', 'Q1');

@@ -51,3 +51,3 @@ matcher.add('*.*.rabbit', 'Q2');

['Q2'],
['Q2'],
['Q2', 'Q2'],
[],

@@ -106,4 +106,2 @@ [],

- `{Boolean} remove_duplicates` qlobber's matching algorithm means values may be returned twice. Specify `true` to have qlobber remove duplicates from its results. Note this will incur a performance penalty. Defaults to `false`.
<sub>Go: [TOC](#tableofcontents)</sub>

@@ -147,3 +145,3 @@

`{Array}` List of values that matched the topic. This may contain duplicates unless you configured [Qlobber](#qlobberoptions) otherwise.
`{Array}` List of values that matched the topic. This may contain duplicates if more than one matcher matches the topic with the same value.

@@ -150,0 +148,0 @@ <sub>Go: [TOC](#tableofcontents) | [Qlobber.prototype](#toc_qlobberprototype)</sub>

@@ -36,2 +36,12 @@ /*globals rabbitmq_test_bindings : false,

function remove_duplicates_filter(item, index, arr)
{
return item !== arr[index - 1];
}
Array.prototype.remove_duplicates = function ()
{
return this.sort().filter(remove_duplicates_filter);
};
it('should support adding bindings', function ()

@@ -50,3 +60,3 @@ {

{
expect(matcher.match(test[0]).sort(), test[0]).to.eql(test[1].sort());
expect(matcher.match(test[0]).remove_duplicates(), test[0]).to.eql(test[1].sort());
});

@@ -69,3 +79,3 @@ });

{
expect(matcher.match(test[0]).sort(), test[0]).to.eql(test[1].sort());
expect(matcher.match(test[0]).remove_duplicates(), test[0]).to.eql(test[1].sort());
});

@@ -89,3 +99,3 @@

{
expect(matcher.match(test[0]).sort(), test[0]).to.eql(test[1].sort());
expect(matcher.match(test[0]).remove_duplicates(), test[0]).to.eql(test[1].sort());
});

@@ -102,3 +112,3 @@ });

{
expect(matcher.match(test[0]).sort(), test[0]).to.eql(test[1].sort());
expect(matcher.match(test[0]).remove_duplicates(), test[0]).to.eql(test[1].sort());
});

@@ -120,3 +130,3 @@ });

{
expect(matcher.match(test[0]).sort(), test[0]).to.eql(test[1].sort());
expect(matcher.match(test[0]).remove_duplicates(), test[0]).to.eql(test[1].sort());
});

@@ -140,3 +150,3 @@ });

return f();
}).sort()).to.eql(test[1].sort());
}).remove_duplicates()).to.eql(test[1].sort());
});

@@ -172,3 +182,3 @@ });

['Q2'],
['Q2'],
['Q2', 'Q2'],
[],

@@ -175,0 +185,0 @@ [],

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