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

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.11.0 to 0.12.0

bench/add_shortcut_many.js

11

bench/add_many.js

@@ -13,4 +13,3 @@ /*globals options: false */

separator: "/",
wildcard_one: "+",
cache_adds: true
wildcard_one: "+"
}), i, j;

@@ -22,10 +21,10 @@

{
if (options.Matcher === qlobber.Qlobber)
if ((options.Matcher !== qlobber.Qlobber) ||
// mosca pre-dedup checks whether already added
(matcher.match('app/test/user/behrad/testTopic-' + j).indexOf(i) < 0))
{
// mosca pre-dedup checks whether already added
matcher.match('app/test/user/behrad/testTopic-' + j).indexOf(i);
matcher.add('app/test/user/behrad/testTopic-' + j, i);
}
matcher.add('app/test/user/behrad/testTopic-' + j, i);
}
}
};

@@ -9,2 +9,3 @@ /*globals rabbitmq_test_bindings: false,

var assert = require('assert');
var qlobber = require('../..');

@@ -38,2 +39,37 @@ var MapValQlobber = require('../options/_mapval').MapValQlobber;

exports.remove_bindings = function(matcher)
{
var i, r, test, vals;
for (i = 0; i < rabbitmq_bindings_to_remove.length; i += 1)
{
r = rabbitmq_test_bindings[rabbitmq_bindings_to_remove[i] - 1];
matcher.remove(r[0], r[1]);
}
if (options.check)
{
for (i = 0; i < rabbitmq_expected_results_after_remove.length; i += 1)
{
test = rabbitmq_expected_results_after_remove[i];
vals = matcher.match(test[0]);
if (options.Matcher === qlobber.QlobberDedup)
{
vals = Array.from(vals).sort();
}
else if (options.Matcher === MapValQlobber)
{
vals = Array.from(vals.keys()).sort();
}
else
{
vals = remove_duplicates(vals);
}
expect(vals).to.eql(test[1].sort());
}
}
};
exports.match = function(matcher)

@@ -69,36 +105,41 @@ {

exports.remove_bindings = function(matcher)
exports.match_search = function(matcher)
{
var i, r, test, vals;
var i, j, test, vals;
for (i = 0; i < rabbitmq_bindings_to_remove.length; i += 1)
for (i = 0; i < rabbitmq_expected_results_before_remove.length; i += 1)
{
r = rabbitmq_test_bindings[rabbitmq_bindings_to_remove[i] - 1];
matcher.remove(r[0], r[1]);
}
test = rabbitmq_expected_results_before_remove[i];
if (options.check)
{
for (i = 0; i < rabbitmq_expected_results_after_remove.length; i += 1)
for (j = 0; j < test[1].length; j += 1)
{
test = rabbitmq_expected_results_after_remove[i];
// Typically app would match and search each time
vals = matcher.match(test[0]);
if (options.Matcher === qlobber.QlobberDedup)
if ((options.Matcher === qlobber.QlobberDedup) ||
(options.Matcher === MapValQlobber))
{
vals = Array.from(vals).sort();
assert(vals.has(test[1][j]));
}
else if (options.Matcher === MapValQlobber)
{
vals = Array.from(vals.keys()).sort();
}
else
{
vals = remove_duplicates(vals);
assert(vals.indexOf(test[1][j]) >= 0);
}
}
}
};
expect(vals).to.eql(test[1].sort());
exports.test = function(matcher)
{
var i, j, test, vals;
for (i = 0; i < rabbitmq_expected_results_before_remove.length; i += 1)
{
test = rabbitmq_expected_results_before_remove[i];
for (j = 0; j < test[1].length; j += 1)
{
assert(matcher.test(test[0], test[1][j]));
}
}
};

@@ -6,13 +6,14 @@ /*globals options: false */

var qlobber = require('..'),
util = require("util"),
MapValQlobber = require('./options/_mapval').MapValQlobber,
common = require('./common');
module.exports = function ()
var matcher_options = {
separator: "/",
wildcard_one: "+",
cache_adds: true
};
function add_bindings(matcher)
{
var matcher = new options.Matcher(
{
separator: "/",
wildcard_one: "+"
}), i, j, vals;
var i, j;
for (i = 0; i < 60000; i += 1)

@@ -26,9 +27,34 @@ {

}
vals = matcher.match('app/test/user/behrad/testTopic-0');
}
if (options.Matcher === qlobber.Qlobber)
{
common.remove_duplicates(vals);
}
var matcher_default = new qlobber.Qlobber(matcher_options);
add_bindings(matcher_default);
var matcher_dedup = new qlobber.QlobberDedup(matcher_options);
add_bindings(matcher_dedup);
var matcher_mapval = new MapValQlobber(matcher_options);
add_bindings(matcher_mapval);
module.exports = function ()
{
var j;
for (j = 0; j < 100; j += 1)
{
switch (options.Matcher)
{
case qlobber.QlobberDedup:
matcher_dedup.match('app/test/user/behrad/testTopic-' + j);
break;
case MapValQlobber:
matcher_mapval.match('app/test/user/behrad/testTopic-' + j);
break;
default:
common.remove_duplicates(matcher_default.match('app/test/user/behrad/testTopic-' + j));
break;
}
}
};

@@ -6,2 +6,3 @@ /*globals options: false */

var qlobber = require('..'),
MapValQlobber = require('./options/_mapval').MapValQlobber,
common = require('./common');

@@ -15,6 +16,21 @@

var matcher_mapval = new MapValQlobber();
common.add_bindings(matcher_mapval);
module.exports = function ()
{
common.match(options.Matcher === qlobber.Qlobber ? matcher_default : matcher_dedup);
switch (options.Matcher)
{
case qlobber.QlobberDedup:
common.match(matcher_dedup);
break;
case MapValQlobber:
common.match(matcher_mapval);
break;
default:
common.match(matcher_default);
break;
}
};

@@ -37,2 +37,7 @@ /*jslint node: true */

MapValQlobber.prototype.test_values = function (vals, val)
{
return vals.has(val);
};
MapValQlobber.prototype.match = function (topic)

@@ -39,0 +44,0 @@ {

@@ -44,15 +44,11 @@ /*jslint node: true */

bench: {
cmd: './node_modules/.bin/bench -c 20000 -i bench/options/default.js,bench/options/dedup.js,bench/options/mapval.js -k options bench/add_match_remove bench/match bench/add'
cmd: './node_modules/.bin/bench -c 20000 -i bench/options/default.js,bench/options/dedup.js,bench/options/mapval.js -k options bench/add bench/add_match_remove bench/match bench/match_search bench/test'
},
'bench-check': {
cmd: './node_modules/.bin/bench -c 20000 -i bench/options/check.js,bench/options/check-dedup.js,bench/options/check-mapval.js -k options bench/add_match_remove bench/match bench/add'
cmd: './node_modules/.bin/bench -c 20000 -i bench/options/check.js,bench/options/check-dedup.js,bench/options/check-mapval.js -k options bench/add bench/add_match_remove bench/match bench/match_search bench/test'
},
'bench-add-many': {
cmd: './node_modules/.bin/bench -c 1 -i bench/options/default.js,bench/options/dedup.js,bench/options/mapval.js -k options bench/add_many.js'
},
'bench-match-many': {
cmd: './node_modules/.bin/bench -c 1 -i bench/options/default.js,bench/options/dedup.js,bench/options/mapval.js -k options bench/match_many.js'
'bench-many': {
cmd: './node_modules/.bin/bench -c 1 -i bench/options/default.js,bench/options/dedup.js,bench/options/mapval.js -k options bench/add_many bench/add_shortcut_many bench/match_many bench/match_search_many bench/test_many'
}

@@ -75,8 +71,5 @@ }

grunt.registerTask('bench', ['exec:bench',
'exec:bench-add-many',
'exec:bench-match-many']);
'exec:bench-many']);
grunt.registerTask('bench-check', 'exec:bench-check');
grunt.registerTask('bench-add-many', 'exec:bench-add-many');
grunt.registerTask('bench-match-many', 'exec:bench-match-many');
grunt.registerTask('default', ['lint', 'test']);
};

@@ -13,2 +13,3 @@ /**

assert.deepEqual(matcher.match('foo.bar'), ['it matched!']);
assert(matcher.test('foo.bar', 'it matched!'));
```

@@ -199,3 +200,3 @@

{
var st, word;
var st, word, r;

@@ -211,5 +212,6 @@ if (i === words.length)

sub_trie.delete(this._separator);
return true;
}
return;
return false;
}

@@ -222,6 +224,6 @@

{
return;
return false;
}
this._remove(val, i + 1, words, st);
r = this._remove(val, i + 1, words, st);

@@ -232,5 +234,7 @@ if (st.size === 0)

}
return r;
};
Qlobber.prototype._some = function (v, i, words, st)
Qlobber.prototype._match_some = function (v, i, words, st)
{

@@ -263,3 +267,3 @@ var j, w;

// in the common case there will be no more levels...
v = this._some(v, i, words, st);
v = this._match_some(v, i, words, st);
// and we'll end up matching the rest of the words:

@@ -330,2 +334,78 @@ v = this._match(v, words.length, words, st);

Qlobber.prototype._test_some = function (v, i, words, st)
{
var j, w;
for (w of st.keys())
{
if (w !== this._separator)
{
for (j = i; j < words.length; j += 1)
{
if (this._test(v, j, words, st))
{
return true;
}
}
break;
}
}
return false;
};
Qlobber.prototype._test = function (v, i, words, sub_trie)
{
var word, st;
st = sub_trie.get(this._wildcard_some);
if (st)
{
// in the common case there will be no more levels...
if (this._test_some(v, i, words, st) ||
// and we'll end up matching the rest of the words:
this._test(v, words.length, words, st))
{
return true;
}
}
if (i === words.length)
{
st = sub_trie.get(this._separator);
if (st && this.test_values(st, v))
{
return true;
}
}
else
{
word = words[i];
if ((word !== this._wildcard_one) && (word !== this._wildcard_some))
{
st = sub_trie.get(word);
if (st && this._test(v, i + 1, words, st))
{
return true;
}
}
if (word)
{
st = sub_trie.get(this._wildcard_one);
if (st && this._test(v, i + 1, words, st))
{
return true;
}
}
}
return false;
};
/**

@@ -367,4 +447,3 @@ Add a topic matcher to the qlobber.

{
this._remove(val, 0, topic.split(this._separator), this._trie);
if (this._shortcuts)
if (this._remove(val, 0, topic.split(this._separator), this._trie) && this._shortcuts)
{

@@ -388,2 +467,24 @@ this._shortcuts.delete(topic);

/**
Test whether a topic match contains a value. Faster than calling [`match`](#qlobberprototypematchtopic) and searching the result for the value. Values are tested using [`test_values`](#qlobberprototypetest_valuesvals_val).
@param {String} topic The topic to match against.
@param {Any} [val] The value being tested for.
@return {Boolean} Whether matching against `topic` contains `val`.
*/
Qlobber.prototype.test = function (topic, val)
{
return this._test(val, 0, topic.split(this._separator), this._trie);
};
/**
Test whether values found in a match contain a value passed to [`test`](#qlobberprototypetesttopic_val). You can override this to provide a custom implementation. Defaults to using `indexOf`.
@param {Array} vals The values found while matching.
@param {Any} val The value being tested for.
@return {Boolean} Whether `vals` contains `val`.
*/
Qlobber.prototype.test_values = function (vals, val)
{
return vals.indexOf(val) >= 0;
};
/**
Reset the qlobber.

@@ -451,2 +552,13 @@

/**
Test whether values found in a match contain a value passed to [`test`](#qlobberprototypetesttopic_val). You can override this to provide a custom implementation. Defaults to using `has`.
@param {Set} vals The values found while matching ([ES6 Set](http://www.ecma-international.org/ecma-262/6.0/#sec-set-objects)).
@param {Any} val The value being tested for.
@return {Boolean} Whether `vals` contains `val`.
*/
QlobberDedup.prototype.test_values = function (vals, val)
{
return vals.has(val);
};
/**
Match a topic.

@@ -453,0 +565,0 @@

{
"name": "qlobber",
"description": "Node.js globbing for amqp-like topics",
"version": "0.11.0",
"version": "0.12.0",
"homepage": "https://github.com/davedoesdev/qlobber",

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

@@ -12,2 +12,3 @@ # qlobber&nbsp;&nbsp;&nbsp;[![Build Status](https://travis-ci.org/davedoesdev/qlobber.png)](https://travis-ci.org/davedoesdev/qlobber) [![Coverage Status](https://coveralls.io/repos/davedoesdev/qlobber/badge.png?branch=master)](https://coveralls.io/r/davedoesdev/qlobber?branch=master) [![NPM version](https://badge.fury.io/js/qlobber.png)](http://badge.fury.io/js/qlobber)

assert.deepEqual(matcher.match('foo.bar'), ['it matched!']);
assert(matcher.test('foo.bar', 'it matched!'));
```

@@ -105,5 +106,8 @@

- <a name="toc_qlobberprototypematchtopic"></a>[Qlobber.prototype.match](#qlobberprototypematchtopic)
- <a name="toc_qlobberprototypetesttopic-val"></a>[Qlobber.prototype.test](#qlobberprototypetesttopic-val)
- <a name="toc_qlobberprototypetest_valuesvals-val"></a>[Qlobber.prototype.test_values](#qlobberprototypetest_valuesvals-val)
- <a name="toc_qlobberprototypeclear"></a>[Qlobber.prototype.clear](#qlobberprototypeclear)
- <a name="toc_qlobberdedupoptions"></a>[QlobberDedup](#qlobberdedupoptions)
- <a name="toc_qlobberdedupprototypematchtopic"></a><a name="toc_qlobberdedupprototype"></a>[QlobberDedup.prototype.match](#qlobberdedupprototypematchtopic)
- <a name="toc_qlobberdedupprototypetest_valuesvals-val"></a><a name="toc_qlobberdedupprototype"></a>[QlobberDedup.prototype.test_values](#qlobberdedupprototypetest_valuesvals-val)
- <a name="toc_qlobberdedupprototypematchtopic"></a>[QlobberDedup.prototype.match](#qlobberdedupprototypematchtopic)

@@ -175,2 +179,32 @@ ## Qlobber([options])

## Qlobber.prototype.test(topic, [val])
> Test whether a topic match contains a value. Faster than calling [`match`](#qlobberprototypematchtopic) and searching the result for the value. Values are tested using [`test_values`](#qlobberprototypetest_valuesvals_val).
**Parameters:**
- `{String} topic` The topic to match against.
- `{Any} [val]` The value being tested for.
**Return:**
`{Boolean}` Whether matching against `topic` contains `val`.
<sub>Go: [TOC](#tableofcontents) | [Qlobber.prototype](#toc_qlobberprototype)</sub>
## Qlobber.prototype.test_values(vals, val)
> Test whether values found in a match contain a value passed to [`test`](#qlobberprototypetesttopic_val). You can override this to provide a custom implementation. Defaults to using `indexOf`.
**Parameters:**
- `{Array} vals` The values found while matching.
- `{Any} val` The value being tested for.
**Return:**
`{Boolean}` Whether `vals` contains `val`.
<sub>Go: [TOC](#tableofcontents) | [Qlobber.prototype](#toc_qlobberprototype)</sub>
## Qlobber.prototype.clear()

@@ -202,2 +236,17 @@

## QlobberDedup.prototype.test_values(vals, val)
> Test whether values found in a match contain a value passed to [`test`](#qlobberprototypetesttopic_val). You can override this to provide a custom implementation. Defaults to using `has`.
**Parameters:**
- `{Set} vals` The values found while matching ([ES6 Set](http://www.ecma-international.org/ecma-262/6.0/#sec-set-objects)).
- `{Any} val` The value being tested for.
**Return:**
`{Boolean}` Whether `vals` contains `val`.
<sub>Go: [TOC](#tableofcontents) | [QlobberDedup.prototype](#toc_qlobberdedupprototype)</sub>
## QlobberDedup.prototype.match(topic)

@@ -204,0 +253,0 @@

@@ -36,5 +36,10 @@ /*jshint node: true, mocha: true */

{
vals.delete(val.clientId);
vals.delete(val);
};
QosQlobber.prototype.test_values = function (vals, val)
{
return vals.has(val);
};
QosQlobber.prototype.match = function (topic)

@@ -56,2 +61,4 @@ {

]));
expect(matcher.test('foo.bar', 'test1')).to.equal(true);
expect(matcher.test('foo.bar', 'test2')).to.equal(false);
});

@@ -67,2 +74,4 @@

]));
expect(matcher.test('foo.bar', 'test1')).to.equal(true);
expect(matcher.test('foo.bar', 'test2')).to.equal(false);
});

@@ -79,2 +88,4 @@

]));
expect(matcher.test('foo.bar', 'test1')).to.equal(true);
expect(matcher.test('foo.bar', 'test2')).to.equal(true);
});

@@ -90,4 +101,19 @@

]));
expect(matcher.test('foo.bar', 'test1')).to.equal(true);
expect(matcher.test('foo.bar', 'test2')).to.equal(false);
});
it('should remove value', function ()
{
var matcher = new QosQlobber();
matcher.add('foo.bar', { clientId: 'test1', qos: 10 });
matcher.add('foo.bar', { clientId: 'test2', qos: 20 });
matcher.remove('foo.bar', 'test1');
expect(matcher.match('foo.bar')).to.eql(new Map([
[ 'test2', { clientId: 'test2', qos: 20 } ]
]));
expect(matcher.test('foo.bar', 'test1')).to.equal(false);
expect(matcher.test('foo.bar', 'test2')).to.equal(true);
});
});
});

@@ -82,2 +82,7 @@ /*globals rabbitmq_test_bindings : false,

test[1].sort());
for (var v of test[1])
{
expect(matcher.test(test[0], v)).to.equal(true);
}
expect(matcher.test(test[0], 'xyzfoo')).to.equal(false);
});

@@ -102,2 +107,7 @@ });

test[1].sort());
for (var v of test[1])
{
expect(matcher.test(test[0], v)).to.equal(true);
}
expect(matcher.test(test[0], 'xyzfoo')).to.equal(false);
});

@@ -123,2 +133,7 @@

test[1].sort());
for (var v of test[1])
{
expect(matcher.test(test[0], v)).to.equal(true);
}
expect(matcher.test(test[0], 'xyzfoo')).to.equal(false);
});

@@ -137,2 +152,7 @@ });

test[1].sort());
for (var v of test[1])
{
expect(matcher.test(test[0], v)).to.equal(true);
}
expect(matcher.test(test[0], 'xyzfoo')).to.equal(false);
});

@@ -156,2 +176,7 @@ });

test[1].sort());
for (var v of test[1])
{
expect(matcher.test(test[0], v)).to.equal(true);
}
expect(matcher.test(test[0], 'xyzfoo')).to.equal(false);
});

@@ -170,2 +195,15 @@ });

matcher.test_values = function (vals, val)
{
for (var v of vals)
{
if (v() === val)
{
return true;
}
}
return false;
};
rabbitmq_expected_results_before_remove.forEach(function (test)

@@ -177,2 +215,7 @@ {

}).sort()).to.eql(test[1].sort());
for (var v of test[1])
{
expect(matcher.test(test[0], v)).to.equal(true);
}
expect(matcher.test(test[0], 'xyzfoo')).to.equal(false);
});

@@ -185,2 +228,3 @@ });

expect(Array.from(matcher.match('foo.bar'))).to.eql(['it matched!']);
expect(matcher.test('foo.bar', 'it matched!')).to.equal(true);
});

@@ -203,13 +247,15 @@

{
return Array.from(matcher.match(topic)).sort();
return [Array.from(matcher.match(topic)).sort(),
matcher.test(topic, 'Q1'),
matcher.test(topic, 'Q2')];
})).to.eql(
[['Q1', 'Q2'],
['Q1', 'Q2'],
['Q1'],
['Q2'],
['Q2'],
[],
[],
[],
['Q2']]);
[[['Q1', 'Q2'], true, true],
[['Q1', 'Q2'], true, true],
[['Q1'], true, false],
[['Q2'], false, true],
[['Q2'], false, true],
[[], false, false],
[[], false, false],
[[], false, false],
[['Q2'], false, true]]);
});

@@ -224,2 +270,3 @@

expect(Array.from(matcher.match('foo.bar'))).to.eql(['it matched!']);
expect(matcher.test('foo.bar', 'it matched!')).to.equal(true);
});

@@ -235,2 +282,6 @@

['it matched too!', 'it matched!']);
expect(matcher.test('foo.*', 'it matched!')).to.equal(true);
expect(matcher.test('foo.*', 'it matched too!')).to.equal(true);
expect(matcher.test('foo.#', 'it matched!')).to.equal(true);
expect(matcher.test('foo.#', 'it matched too!')).to.equal(true);
});

@@ -252,2 +303,5 @@

['it matched too!']);
expect(matcher.test('foo/bar', 'it matched!')).to.equal(true);
expect(matcher.test('foo/bar', 'it matched too!')).to.equal(true);
expect(matcher.test('foo/bar/end', 'it matched too!')).to.equal(true);
});

@@ -262,2 +316,3 @@

expect(Array.from(matcher.match('a.b'))).to.eql(['foo']);
expect(matcher.test('a.b', 'foo')).to.equal(true);
});

@@ -282,6 +337,9 @@

vals = matcher.match('app.test.user.behrad.testTopic-0');
expect(vals.size).to.equal(60000);
expect(matcher.test('app.test.user.behrad.testTopic-0', 0)).to.equal(true);
expect(matcher.test('app.test.user.behrad.testTopic-0', 59999)).to.equal(true);
expect(matcher.test('app.test.user.behrad.testTopic-0', 60000)).to.equal(false);
});
});

@@ -18,2 +18,3 @@ /*jshint node: true, mocha: true */

expect(Array.from(matcher.match('a.b.c.d'))).to.eql([90]);
expect(matcher.test('a.b.c.d', 90)).to.equal(true);
});

@@ -30,2 +31,4 @@

expect(Array.from(matcher.match('a.b.c.d')).sort()).to.eql([90, 91]);
expect(matcher.test('a.b.c.d', 90)).to.equal(true);
expect(matcher.test('a.b.c.d', 91)).to.equal(true);
});

@@ -41,4 +44,16 @@

expect(Array.from(matcher.match('a.b.c.d'))).to.eql([]);
expect(matcher.test('a.b.c.d', 90)).to.equal(false);
});
it('should remove shortcut when removing all', function ()
{
var matcher = new QlobberDedup({ cache_adds: true });
expect(matcher._shortcuts.size).to.equal(0);
matcher.add('a.b.c.d', 90);
matcher.remove('a.b.c.d');
expect(matcher._shortcuts.size).to.equal(0);
expect(Array.from(matcher.match('a.b.c.d'))).to.eql([]);
expect(matcher.test('a.b.c.d', 90)).to.equal(false);
});
it('should clear shortcuts when matcher is cleared', function ()

@@ -52,3 +67,4 @@ {

expect(Array.from(matcher.match('a.b.c.d'))).to.eql([]);
expect(matcher.test('a.b.c.d', 90)).to.equal(false);
});
});

@@ -78,2 +78,7 @@ /*globals rabbitmq_test_bindings : false,

expect(matcher.match(test[0]).remove_duplicates(), test[0]).to.eql(test[1].sort());
for (var v of test[1])
{
expect(matcher.test(test[0], v)).to.equal(true);
}
expect(matcher.test(test[0], 'xyzfoo')).to.equal(false);
});

@@ -97,2 +102,7 @@ });

expect(matcher.match(test[0]).remove_duplicates(), test[0]).to.eql(test[1].sort());
for (var v of test[1])
{
expect(matcher.test(test[0], v)).to.equal(true);
}
expect(matcher.test(test[0], 'xyzfoo')).to.equal(false);
});

@@ -117,2 +127,7 @@

expect(matcher.match(test[0]).remove_duplicates(), test[0]).to.eql(test[1].sort());
for (var v of test[1])
{
expect(matcher.test(test[0], v)).to.equal(true);
}
expect(matcher.test(test[0], 'xyzfoo')).to.equal(false);
});

@@ -130,2 +145,7 @@ });

expect(matcher.match(test[0]).remove_duplicates(), test[0]).to.eql(test[1].sort());
for (var v of test[1])
{
expect(matcher.test(test[0], v)).to.equal(true);
}
expect(matcher.test(test[0], 'xyzfoo')).to.equal(false);
});

@@ -148,2 +168,7 @@ });

expect(matcher.match(test[0]).remove_duplicates(), test[0]).to.eql(test[1].sort());
for (var v of test[1])
{
expect(matcher.test(test[0], v)).to.equal(true);
}
expect(matcher.test(test[0], 'xyzfoo')).to.equal(false);
});

@@ -162,2 +187,20 @@ });

matcher.test_values = function (vals, val)
{
for (var v of vals)
{
if (v() === val)
{
return true;
}
}
return false;
};
matcher.equals_value = function (matched_value, test_value)
{
return matched_value() === test_value;
};
rabbitmq_expected_results_before_remove.forEach(function (test)

@@ -169,2 +212,7 @@ {

}).remove_duplicates()).to.eql(test[1].sort());
for (var v of test[1])
{
expect(matcher.test(test[0], v)).to.equal(true);
}
expect(matcher.test(test[0], 'xyzfoo')).to.equal(false);
});

@@ -177,2 +225,3 @@ });

expect(matcher.match('foo.bar')).to.eql(['it matched!']);
expect(matcher.test('foo.bar', 'it matched!')).to.equal(true);
});

@@ -195,13 +244,15 @@

{
return matcher.match(topic).sort();
return [matcher.match(topic).sort(),
matcher.test(topic, 'Q1'),
matcher.test(topic, 'Q2')];
})).to.eql(
[['Q1', 'Q2'],
['Q1', 'Q2'],
['Q1'],
['Q2'],
['Q2', 'Q2'],
[],
[],
[],
['Q2']]);
[[['Q1', 'Q2'], true, true],
[['Q1', 'Q2'], true, true],
[['Q1'], true, false],
[['Q2'], false, true],
[['Q2', 'Q2'], false, true],
[[], false, false],
[[], false, false],
[[], false, false],
[['Q2'], false, true]]);
});

@@ -216,2 +267,3 @@

expect(matcher.match('foo.bar')).to.eql(['it matched!']);
expect(matcher.test('foo.bar', 'it matched!')).to.equal(true);
});

@@ -225,2 +277,6 @@

expect(matcher.match('foo.#').sort()).to.eql(['it matched too!', 'it matched!']);
expect(matcher.test('foo.*', 'it matched!')).to.equal(true);
expect(matcher.test('foo.*', 'it matched too!')).to.equal(true);
expect(matcher.test('foo.#', 'it matched!')).to.equal(true);
expect(matcher.test('foo.#', 'it matched too!')).to.equal(true);
});

@@ -240,3 +296,5 @@

expect(matcher.match('foo/bar/end').sort()).to.eql(['it matched too!']);
expect(matcher.test('foo/bar', 'it matched!')).to.equal(true);
expect(matcher.test('foo/bar', 'it matched too!')).to.equal(true);
expect(matcher.test('foo/bar/end', 'it matched too!')).to.equal(true);
});

@@ -261,7 +319,10 @@

vals = matcher.match('app.test.user.behrad.testTopic-0');
expect(vals.length).to.equal(120000);
expect(vals.remove_duplicates().length).to.equal(60000);
expect(matcher.test('app.test.user.behrad.testTopic-0', 0)).to.equal(true);
expect(matcher.test('app.test.user.behrad.testTopic-0', 59999)).to.equal(true);
expect(matcher.test('app.test.user.behrad.testTopic-0', 60000)).to.equal(false);
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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