Comparing version 4.1.0 to 4.2.0
@@ -6,3 +6,3 @@ /** | ||
__Note:__ Version 4.0.0 adds async and worker thread support but requires Node 12+. | ||
__Note:__ Version 4.2.0 adds async and worker thread support when used on Node 12+. | ||
@@ -1051,117 +1051,7 @@ Example: | ||
function wrap_native(QlobberNative, Qlobber) | ||
{ | ||
class WrappedQlobberNative extends QlobberNative | ||
{ | ||
constructor(options) { | ||
super(options); | ||
this.addP = util.promisify(this.add_async); | ||
this.removeP = util.promisify(this.remove_async); | ||
this.matchP = util.promisify(this.match_async); | ||
this.testP = util.promisify(this.test_async); | ||
this.clearP = util.promisify(this.clear_async); | ||
this._get_visitorP = util.promisify(this.get_visitor_async); | ||
this._visit_nextP = util.promisify(this.visit_next_async); | ||
this._get_restorerP = util.promisify(this.get_restorer_async); | ||
this._restore_nextP = util.promisify(this.restore_next_async); | ||
this._match_iterP = util.promisify(this.match_iter_async); | ||
this._match_nextP = util.promisify(this.match_next_async); | ||
} | ||
var wrap_native; | ||
*visit() | ||
{ | ||
const visitor = this.get_visitor(); | ||
while (true) | ||
{ | ||
const v = this.visit_next(visitor); | ||
if (v === undefined) | ||
{ | ||
break; | ||
} | ||
yield v; | ||
} | ||
} | ||
async *visitP() | ||
{ | ||
const visitor = await this._get_visitorP(); | ||
while (true) | ||
{ | ||
const v = await this._visit_nextP(visitor); | ||
if (v === undefined) | ||
{ | ||
break; | ||
} | ||
yield v; | ||
} | ||
} | ||
*match_iter(topic, ctx) { | ||
const iterator = super.match_iter(topic, ctx); | ||
while (true) | ||
{ | ||
const v = this.match_next(iterator); | ||
if (v === undefined) | ||
{ | ||
break; | ||
} | ||
yield v.value; | ||
} | ||
} | ||
async *match_iterP(topic, ctx) { | ||
const iterator = await this._match_iterP(topic, ctx); | ||
while (true) | ||
{ | ||
const v = await this._match_nextP(iterator); | ||
if (v === undefined) | ||
{ | ||
break; | ||
} | ||
yield v.value; | ||
} | ||
} | ||
get_trie() | ||
{ | ||
const qlobber = new Qlobber(this.options); | ||
const restorer = qlobber.get_restorer(); | ||
for (let v of this.visit()) | ||
{ | ||
restorer(v); | ||
} | ||
return qlobber.get_trie(); | ||
} | ||
get_restorer(options) | ||
{ | ||
const restorer = super.get_restorer(options); | ||
return obj => { | ||
super.restore_next(restorer, obj); | ||
}; | ||
} | ||
async get_restorerP(options) | ||
{ | ||
const restorer = await this._get_restorerP(options); | ||
return async obj => { | ||
await this._restore_nextP(restorer, obj); | ||
}; | ||
} | ||
} | ||
WrappedQlobberNative.is_native = true; | ||
WrappedQlobberNative.nonNative = Qlobber; | ||
return WrappedQlobberNative; | ||
} | ||
try | ||
{ | ||
wrap_native = require('./wrap_native.js'); | ||
const binding = require('bindings')('qlobber.node'); | ||
@@ -1168,0 +1058,0 @@ Qlobber.nativeString = wrap_native(binding.QlobberString, Qlobber); |
{ | ||
"name": "qlobber", | ||
"description": "Node.js globbing for amqp-like topics", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"homepage": "https://github.com/davedoesdev/qlobber", | ||
@@ -39,3 +39,3 @@ "author": { | ||
"engines": { | ||
"node": ">= 12" | ||
"node": ">= 8" | ||
}, | ||
@@ -42,0 +42,0 @@ "devDependencies": { |
@@ -5,3 +5,3 @@ # 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) | ||
__Note:__ Version 4.0.0 adds async and worker thread support but requires Node 12+. | ||
__Note:__ Version 4.2.0 adds async and worker thread support when used on Node 12+. | ||
@@ -8,0 +8,0 @@ Example: |
@@ -11,3 +11,3 @@ /*jshint node: true, mocha: true */ | ||
describe(`qlobber-sub (${type})`, function () | ||
(QlobberSub ? describe : describe.skip)(`qlobber-sub (${type})`, function () | ||
{ | ||
@@ -14,0 +14,0 @@ it('should add and match a single value', function () |
@@ -17,3 +17,2 @@ /*globals rabbitmq_test_bindings : false, | ||
common = require('./common'), | ||
{ Worker } = require('worker_threads'), | ||
{ promisify } = require('util'); | ||
@@ -33,4 +32,14 @@ | ||
describe('qlobber-threads', function () | ||
var Worker; | ||
try | ||
{ | ||
({ Worker } = require('worker_threads')); | ||
} | ||
catch (ex) | ||
{ | ||
} | ||
(Worker ? describe : describe.skip)('qlobber-threads', function () | ||
{ | ||
var matcher; | ||
@@ -37,0 +46,0 @@ |
@@ -20,3 +20,3 @@ /*globals rabbitmq_test_bindings : false, | ||
describe(`qlobber-dedup (${type})`, function () | ||
(QlobberDedup ? describe : describe.skip)(`qlobber-dedup (${type})`, function () | ||
{ | ||
@@ -153,3 +153,3 @@ var matcher; | ||
if (!QlobberDedup.is_native) | ||
if (QlobberDedup && !QlobberDedup.is_native) | ||
{ | ||
@@ -156,0 +156,0 @@ it('should support functions as values', function () |
@@ -17,4 +17,14 @@ /*globals rabbitmq_test_bindings : false, | ||
describe('qlobber-async', function () | ||
var async_helpers; | ||
try | ||
{ | ||
async_helpers = require('./fixtures/async_helpers.js'); | ||
} | ||
catch (ex) | ||
{ | ||
} | ||
(async_helpers ? describe : describe.skip)('qlobber-async', function () | ||
{ | ||
var matcher; | ||
@@ -24,10 +34,8 @@ | ||
{ | ||
let r = []; | ||
return await async_helpers.match(matcher, topic); | ||
} | ||
for await (let v of matcher.match_iterP(topic)) | ||
{ | ||
r.push(v); | ||
} | ||
return r; | ||
async function visit() | ||
{ | ||
return await async_helpers.visit(matcher); | ||
} | ||
@@ -288,8 +296,3 @@ | ||
let objs = []; | ||
for await (let v of matcher.visitP()) | ||
{ | ||
objs.push(v); | ||
} | ||
const objs = await visit(); | ||
@@ -355,7 +358,3 @@ expect(common.ordered_sort(objs)).to.eql(common.ordered_sort(common.expected_visits)); | ||
let objs = []; | ||
for await (let v of matcher.visitP()) | ||
{ | ||
objs.push(v); | ||
} | ||
const objs = await visit(); | ||
expect(common.ordered_sort(objs)).to.eql(common.ordered_sort(common.expected_visits)); | ||
@@ -415,3 +414,3 @@ | ||
await expect_throw(async () => { | ||
for await (let v of matcher.match_iterP(topic)) {} | ||
await match(topic); | ||
}, 'too many words', 'match_iterP'); | ||
@@ -427,3 +426,3 @@ await expect_throw(async () => await matcher.testP(topic, 'foo'), 'too many words', 'testP'); | ||
await expect_throw(async () => { | ||
for await (let v of matcher.match_iterP(topic)) {} | ||
await match(topic); | ||
}, 'too many words', 'match_iterP'); | ||
@@ -436,3 +435,3 @@ await expect_throw(async () => await matcher.testP(topic, 'foo'), 'too many words', 'testP'); | ||
await matcher.matchP(topic); | ||
for await (let v of matcher.match_iterP(topic)) {} | ||
await match(topic); | ||
await matcher.testP(topic, 'foo'); | ||
@@ -446,3 +445,3 @@ }); | ||
await matcher.matchP(topic); | ||
for await (let v of matcher.match_iterP(topic)) {} | ||
await match(topic); | ||
await matcher.testP(topic, 'foo'); | ||
@@ -526,3 +525,3 @@ }); | ||
for await (let v of matcher.match_iterP(topic)) {} | ||
await match(topic); | ||
expect(matcher._counters.match_iter).to.equal(ematch); | ||
@@ -529,0 +528,0 @@ expect(matcher._counters.match_some_iter).to.equal(ematch_some); |
@@ -20,3 +20,3 @@ /*globals rabbitmq_test_bindings : false, | ||
describe(`qlobber (${type})`, function () | ||
(Qlobber ? describe : describe.skip)(`qlobber (${type})`, function () | ||
{ | ||
@@ -180,3 +180,3 @@ var matcher; | ||
if (!Qlobber.is_native) | ||
if (Qlobber && !Qlobber.is_native) | ||
{ | ||
@@ -494,3 +494,3 @@ it('should support functions as values', function () | ||
if (!Qlobber.is_native) | ||
if (Qlobber && !Qlobber.is_native) | ||
{ | ||
@@ -497,0 +497,0 @@ it('should add shortcuts to passed in Map', function () |
@@ -13,3 +13,3 @@ /*globals rabbitmq_test_bindings: false, | ||
describe(`true (${type})`, function () | ||
(QlobberTrue ? describe : describe.skip)(`true (${type})`, function () | ||
{ | ||
@@ -16,0 +16,0 @@ it('should add and test', function () |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
536988
89
5671