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.12.2 to 1.0.0

test/true.js

68

lib/qlobber.js

@@ -410,3 +410,3 @@ /**

@param {String} topic The topic to match against.
@param {Any} val The value to return if the topic is matched. `undefined` is not supported.
@param {Any} val The value to return if the topic is matched.
@return {Qlobber} The qlobber (for chaining).

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

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.

@@ -473,2 +474,3 @@ @param {Any} val The value being tested for.

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.

@@ -547,2 +549,3 @@ @param {Any} val The value being tested for.

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)).

@@ -568,4 +571,67 @@ @param {Any} val The value being tested for.

/**
Creates a new qlobber which only stores the value `true`.
Whatever value you [`add`](#qlobberprototypeaddtopic-val) to this qlobber
(even `undefined`), a single, de-duplicated `true` will be stored. Use this
qlobber if you only need to test whether topics match, not about the values
they match to.
Inherits from Qlobber.
@constructor
@param {Object} [options] Same options as Qlobber.
*/
function QlobberTrue (options)
{
Qlobber.call(this, options);
}
util.inherits(QlobberTrue, Qlobber);
QlobberTrue.prototype._initial_value = function ()
{
return true;
};
QlobberTrue.prototype._add_value = function ()
{
};
QlobberTrue.prototype._remove_value = function ()
{
return true;
};
/**
This override of [`test_values`](#qlobberprototypetest_valuesvals-val) always
returns `true`. When you call [`test`](#qlobberprototypetesttopic-val) on a
`QlobberTrue` instance, the value you pass is ignored since it only cares
whether a topic is matched.
@return {Boolean} Always `true`.
*/
QlobberTrue.prototype.test_values = function ()
{
return true;
};
/**
Match a topic.
Since `QlobberTrue` only cares whether a topic is matched and not about values
it matches to, this override of [`match`](#qlobberprototypematchtopic) just
calls [`test`](#qlobberprototypetesttopic-val) (with value `undefined`).
@param {String} topic The topic to match against.
@return {Boolean} Whether the `QlobberTrue` instance matches the topic.
*/
QlobberTrue.prototype.match = function (topic)
{
return this.test(topic);
};
exports.Qlobber = Qlobber;
exports.QlobberDedup = QlobberDedup;
exports.QlobberTrue = QlobberTrue;

2

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

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

@@ -111,2 +111,5 @@ # qlobber   [![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)

- <a name="toc_qlobberdedupprototypematchtopic"></a>[QlobberDedup.prototype.match](#qlobberdedupprototypematchtopic)
- <a name="toc_qlobbertrueoptions"></a>[QlobberTrue](#qlobbertrueoptions)
- <a name="toc_qlobbertrueprototypetest_values"></a><a name="toc_qlobbertrueprototype"></a>[QlobberTrue.prototype.test_values](#qlobbertrueprototypetest_values)
- <a name="toc_qlobbertrueprototypematchtopic"></a>[QlobberTrue.prototype.match](#qlobbertrueprototypematchtopic)

@@ -141,3 +144,3 @@ ## Qlobber([options])

- `{String} topic` The topic to match against.
- `{Any} val` The value to return if the topic is matched. `undefined` is not supported.
- `{Any} val` The value to return if the topic is matched.

@@ -264,2 +267,52 @@ **Return:**

## QlobberTrue([options])
> Creates a new qlobber which only stores the value `true`.
Whatever value you [`add`](#qlobberprototypeaddtopic-val) to this qlobber
(even `undefined`), a single, de-duplicated `true` will be stored. Use this
qlobber if you only need to test whether topics match, not about the values
they match to.
Inherits from [Qlobber](#qlobberoptions).
**Parameters:**
- `{Object} [options]` Same options as [Qlobber](#qlobberoptions).
<sub>Go: [TOC](#tableofcontents)</sub>
<a name="qlobbertrueprototype"></a>
## QlobberTrue.prototype.test_values()
> This override of [`test_values`](#qlobberprototypetest_valuesvals-val) always
returns `true`. When you call [`test`](#qlobberprototypetesttopic-val) on a
`QlobberTrue` instance, the value you pass is ignored since it only cares
whether a topic is matched.
**Return:**
`{Boolean}` Always `true`.
<sub>Go: [TOC](#tableofcontents) | [QlobberTrue.prototype](#toc_qlobbertrueprototype)</sub>
## QlobberTrue.prototype.match(topic)
> Match a topic.
Since `QlobberTrue` only cares whether a topic is matched and not about values
it matches to, this override of [`match`](#qlobberprototypematchtopic) just
calls [`test`](#qlobberprototypetesttopic-val) (with value `undefined`).
**Parameters:**
- `{String} topic` The topic to match against.
**Return:**
`{Boolean}` Whether the `QlobberTrue` instance matches the topic.
<sub>Go: [TOC](#tableofcontents) | [QlobberTrue.prototype](#toc_qlobbertrueprototype)</sub>
_&mdash;generated by [apidox](https://github.com/codeactual/apidox)&mdash;_

@@ -217,2 +217,10 @@ /*globals rabbitmq_test_bindings : false,

it('should support undefined as a value', function ()
{
matcher.add('foo.bar');
matcher.add('foo.*');
expect(Array.from(matcher.match('foo.bar'))).to.eql([undefined]);
expect(matcher.test('foo.bar')).to.equal(true);
});
it('should pass example in README', function ()

@@ -219,0 +227,0 @@ {

@@ -214,2 +214,10 @@ /*globals rabbitmq_test_bindings : false,

it('should support undefined as a value', function ()
{
matcher.add('foo.bar');
matcher.add('foo.*');
expect(matcher.match('foo.bar')).to.eql([undefined, undefined]);
expect(matcher.test('foo.bar')).to.equal(true);
});
it('should pass example in README', function ()

@@ -216,0 +224,0 @@ {

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