Comparing version 4.2.0 to 5.0.0
@@ -125,11 +125,17 @@ /*jslint node: true */ | ||
try | ||
QlobberSub.set_native = function (qlobber_native) | ||
{ | ||
const binding = require('bindings')('qlobber.node'); | ||
QlobberSub.native = qlobber.wrap_native(binding.QlobberSub, QlobberSub); | ||
} | ||
catch (ex) | ||
{ | ||
} | ||
// wrap_native.js uses 'async *' which isn't available on Node 8 | ||
try | ||
{ | ||
const wrap_native = require('../lib/wrap_native.js'); | ||
QlobberSub.native = wrap_native(qlobber_native.QlobberSub, QlobberSub); | ||
} | ||
catch (ex) | ||
{ | ||
} | ||
return module.exports; | ||
}; | ||
module.exports = QlobberSub; |
@@ -28,14 +28,2 @@ /*jslint node: true */ | ||
exec: { | ||
build: { | ||
cmd: function () { | ||
return `node-gyp build ${grunt.option('debug') ? '--debug' : ''}`; | ||
} | ||
}, | ||
rebuild: { | ||
cmd: function () { | ||
return `node-gyp rebuild ${grunt.option('debug') ? '--debug' : ''}`; | ||
} | ||
}, | ||
cover: { | ||
@@ -77,4 +65,2 @@ cmd: "./node_modules/.bin/nyc -x Gruntfile.js -x 'test/**' node --expose-gc ./node_modules/.bin/grunt test" | ||
grunt.registerTask('lint', 'jshint'); | ||
grunt.registerTask('build', 'exec:build'); | ||
grunt.registerTask('rebuild', 'exec:rebuild'); | ||
grunt.registerTask('test', 'mochaTest'); | ||
@@ -81,0 +67,0 @@ grunt.registerTask('docs', 'apidox'); |
@@ -6,3 +6,3 @@ /** | ||
__Note:__ Version 4.2.0 adds async and worker thread support when used on Node 12+. | ||
__Note:__ Version 5.0.0 adds async and worker thread support when used on Node 12+. | ||
@@ -12,2 +12,3 @@ Example: | ||
```javascript | ||
var assert = require('assert'); | ||
var Qlobber = require('qlobber').Qlobber; | ||
@@ -69,5 +70,5 @@ var matcher = new Qlobber(); | ||
```javascript | ||
var assert = require('assert'); | ||
var Qlobber = require('qlobber').Qlobber.nativeString; | ||
var matcher = new Qlobber(); | ||
const assert = require('assert'); | ||
const { Qlobber } = require('qlobber').set_native(require('qlobber-native')); | ||
const matcher = new Qlobber.nativeString(); | ||
@@ -86,3 +87,3 @@ (async () => { | ||
``` | ||
const Qlobber = require('qlobber').Qlobber.nativeString; | ||
const { Qlobber } = require('qlobber').set_native(require('qlobber-native')); | ||
const { | ||
@@ -93,3 +94,3 @@ Worker, isMainThread, parentPort, workerData | ||
if (isMainThread) { | ||
const matcher = new Qlobber(); | ||
const matcher = new Qlobber.nativeString(); | ||
matcher.add('foo.*', 'it matched!'); | ||
@@ -104,3 +105,3 @@ const worker = new Worker(__filename, { | ||
} else { | ||
const matcher = new Qlobber(workerData); | ||
const matcher = new Qlobber.nativeString(workerData); | ||
parentPort.postMessage([ | ||
@@ -157,8 +158,24 @@ matcher.match('foo.bar'), | ||
In order to support asynchronous calls and worker threads, a native C++ | ||
implementation is included. If you have Gnu C++ version 9+ and Boost 1.70+ | ||
then the native version will be compiled when you install the module. | ||
implementation is available in the | ||
[qlobber-native](https://www.npmjs.com/package/qlobber-native) module. | ||
If compilation succeeds then the following classes will be available alongside | ||
the Javascript classes: | ||
Add qlobber-native as a dependency to your project and then add it to qlobber | ||
like this: | ||
```javascript | ||
require('qlobber').set_native(require('qlobber-native')); | ||
``` | ||
Note that [`set_native`](#set_nativeqlobber_native) returns qlobber's exports so you can do something like | ||
this: | ||
```javascript | ||
const { Qlobber } = require('qlobber').set_native(require('qlobber-native')); | ||
``` | ||
Note that qlobber-native requires Gnu C++ version 9+ and Boost 1.70+. | ||
Once's you've added it to qlobber, the following classes will be available | ||
alongside the Javascript classes: | ||
- `Qlobber.nativeString` | ||
@@ -172,9 +189,2 @@ - `Qlobber.nativeNumber` | ||
You can also build the native implemention using one of these commands: | ||
```shell | ||
grunt build [--debug] | ||
grunt rebuild [--debug] | ||
``` | ||
### Asynchronous calls | ||
@@ -1058,17 +1068,31 @@ | ||
var wrap_native; | ||
/** | ||
Add [qlobber-native](https://www.npmjs.com/package/qlobber-native) to qlobber. | ||
try | ||
@param {Object} qlobber_native The qlobber-native module, obtained using `require('qlobber-native')`. | ||
@return {Object} The qlobber exports with the following native classes added: | ||
- `Qlobber.nativeString` | ||
- `Qlobber.nativeNumber` | ||
- `QlobberDedup.nativeString` | ||
- `QlobberDedup.nativeNumber` | ||
- `QlobberTrue.native` | ||
*/ | ||
function set_native(qlobber_native) | ||
{ | ||
wrap_native = require('./wrap_native.js'); | ||
const binding = require('bindings')('qlobber.node'); | ||
Qlobber.nativeString = wrap_native(binding.QlobberString, Qlobber); | ||
Qlobber.nativeNumber = wrap_native(binding.QlobberNumber, Qlobber); | ||
QlobberDedup.nativeString = wrap_native(binding.QlobberDedupString, QlobberDedup); | ||
QlobberDedup.nativeNumber = wrap_native(binding.QlobberDedupNumber, QlobberDedup); | ||
QlobberTrue.native = wrap_native(binding.QlobberTrue, QlobberTrue); | ||
// wrap_native.js uses 'async *' which isn't available on Node 8 | ||
try | ||
{ | ||
const wrap_native = require('./wrap_native.js'); | ||
Qlobber.nativeString = wrap_native(qlobber_native.QlobberString, Qlobber); | ||
Qlobber.nativeNumber = wrap_native(qlobber_native.QlobberNumber, Qlobber); | ||
QlobberDedup.nativeString = wrap_native(qlobber_native.QlobberDedupString, QlobberDedup); | ||
QlobberDedup.nativeNumber = wrap_native(qlobber_native.QlobberDedupNumber, QlobberDedup); | ||
QlobberTrue.native = wrap_native(qlobber_native.QlobberTrue, QlobberTrue); | ||
} | ||
catch (ex) | ||
{ | ||
} | ||
return exports; | ||
} | ||
catch (ex) | ||
{ | ||
} | ||
@@ -1080,2 +1104,2 @@ exports.Qlobber = Qlobber; | ||
exports.RestorerStream = RestorerStream; | ||
exports.wrap_native = wrap_native; | ||
exports.set_native = set_native; |
{ | ||
"name": "qlobber", | ||
"description": "Node.js globbing for amqp-like topics", | ||
"version": "4.2.0", | ||
"version": "5.0.0", | ||
"homepage": "https://github.com/davedoesdev/qlobber", | ||
@@ -21,5 +21,4 @@ "author": { | ||
"scripts": { | ||
"install": "node-gyp rebuild || true", | ||
"test": "node-gyp rebuild --debug && node --expose-gc ./node_modules/.bin/grunt lint test", | ||
"coverage": "node-gyp rebuild --debug && grunt lint coverage", | ||
"test": "(cd native && npm install && node-gyp rebuild --debug) && node --expose-gc ./node_modules/.bin/grunt lint test", | ||
"coverage": "(cd native && npm install && node-gyp rebuild --debug) && grunt lint coverage", | ||
"coveralls": "grunt coveralls", | ||
@@ -46,5 +45,5 @@ "lint": "grunt lint" | ||
"grunt-mocha-test": "^0.13.3", | ||
"grunt-apidox": "^2.0.7", | ||
"grunt-apidox": "^2.0.8", | ||
"grunt-exec": "^3.0.0", | ||
"mocha": "^7.0.0", | ||
"mocha": "^7.0.1", | ||
"chai": "^4.2.0", | ||
@@ -56,7 +55,3 @@ "nyc": "^15.0.0", | ||
"stream-buffers": "^3.0.2" | ||
}, | ||
"dependencies": { | ||
"bindings": "^1.5.0", | ||
"node-addon-api": "^2.0.0" | ||
} | ||
} |
@@ -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.2.0 adds async and worker thread support when used on Node 12+. | ||
__Note:__ Version 5.0.0 adds async and worker thread support when used on Node 12+. | ||
@@ -11,2 +11,3 @@ Example: | ||
```javascript | ||
var assert = require('assert'); | ||
var Qlobber = require('qlobber').Qlobber; | ||
@@ -68,5 +69,5 @@ var matcher = new Qlobber(); | ||
```javascript | ||
var assert = require('assert'); | ||
var Qlobber = require('qlobber').Qlobber.nativeString; | ||
var matcher = new Qlobber(); | ||
const assert = require('assert'); | ||
const { Qlobber } = require('qlobber').set_native(require('qlobber-native')); | ||
const matcher = new Qlobber.nativeString(); | ||
@@ -85,3 +86,3 @@ (async () => { | ||
``` | ||
const Qlobber = require('qlobber').Qlobber.nativeString; | ||
const { Qlobber } = require('qlobber').set_native(require('qlobber-native')); | ||
const { | ||
@@ -92,3 +93,3 @@ Worker, isMainThread, parentPort, workerData | ||
if (isMainThread) { | ||
const matcher = new Qlobber(); | ||
const matcher = new Qlobber.nativeString(); | ||
matcher.add('foo.*', 'it matched!'); | ||
@@ -103,3 +104,3 @@ const worker = new Worker(__filename, { | ||
} else { | ||
const matcher = new Qlobber(workerData); | ||
const matcher = new Qlobber.nativeString(workerData); | ||
parentPort.postMessage([ | ||
@@ -156,8 +157,24 @@ matcher.match('foo.bar'), | ||
In order to support asynchronous calls and worker threads, a native C++ | ||
implementation is included. If you have Gnu C++ version 9+ and Boost 1.70+ | ||
then the native version will be compiled when you install the module. | ||
implementation is available in the | ||
[qlobber-native](https://www.npmjs.com/package/qlobber-native) module. | ||
If compilation succeeds then the following classes will be available alongside | ||
the Javascript classes: | ||
Add qlobber-native as a dependency to your project and then add it to qlobber | ||
like this: | ||
```javascript | ||
require('qlobber').set_native(require('qlobber-native')); | ||
``` | ||
Note that [`set_native`](#set_nativeqlobber_native) returns qlobber's exports so you can do something like | ||
this: | ||
```javascript | ||
const { Qlobber } = require('qlobber').set_native(require('qlobber-native')); | ||
``` | ||
Note that qlobber-native requires Gnu C++ version 9+ and Boost 1.70+. | ||
Once's you've added it to qlobber, the following classes will be available | ||
alongside the Javascript classes: | ||
- `Qlobber.nativeString` | ||
@@ -171,9 +188,2 @@ - `Qlobber.nativeNumber` | ||
You can also build the native implemention using one of these commands: | ||
```shell | ||
grunt build [--debug] | ||
grunt rebuild [--debug] | ||
``` | ||
### Asynchronous calls | ||
@@ -220,2 +230,3 @@ | ||
- <a name="toc_restorerstreamqlobber"></a>[RestorerStream](#restorerstreamqlobber) | ||
- <a name="toc_set_nativeqlobber_native"></a>[set_native](#set_nativeqlobber_native) | ||
@@ -492,2 +503,22 @@ ## Qlobber([options]) | ||
## set_native(qlobber_native) | ||
> Add [qlobber-native](https://www.npmjs.com/package/qlobber-native) to qlobber. | ||
**Parameters:** | ||
- `{Object} qlobber_native` The qlobber-native module, obtained using `require('qlobber-native')`. | ||
**Return:** | ||
`{Object}` The qlobber exports with the following native classes added: | ||
- `Qlobber.nativeString` | ||
- `Qlobber.nativeNumber` | ||
- `QlobberDedup.nativeString` | ||
- `QlobberDedup.nativeNumber` | ||
- `QlobberTrue.native` | ||
<sub>Go: [TOC](#tableofcontents)</sub> | ||
_—generated by [apidox](https://github.com/codeactual/apidox)—_ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Native code
Supply chain riskContains native code which could be a vector to obscure malicious code, and generally decrease the likelihood of reproducible or reliable installs.
Found 1 instance in 1 package
0
515
59087
8
1172
- Removedbindings@^1.5.0
- Removednode-addon-api@^2.0.0
- Removedbindings@1.5.0(transitive)
- Removedfile-uri-to-path@1.0.0(transitive)
- Removednode-addon-api@2.0.2(transitive)