@comunica/mediator-number
Advanced tools
Comparing version 1.15.0 to 1.17.0
@@ -10,3 +10,3 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
@@ -13,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -1,2 +0,3 @@ | ||
import { Actor, IAction, IActorOutput, IActorReply, IActorTest, Mediator, IMediatorArgs } from '@comunica/core'; | ||
import type { Actor, IAction, IActorOutput, IActorReply, IActorTest, IMediatorArgs } from '@comunica/core'; | ||
import { Mediator } from '@comunica/core'; | ||
/** | ||
@@ -3,0 +4,0 @@ * A mediator that can mediate over a single number field. |
@@ -26,9 +26,9 @@ "use strict"; | ||
const val = this.getOrDefault(curr[this.field], Infinity); | ||
return val !== null && (isNaN(prev[0]) || prev[0] > val) ? [val, i] : prev; | ||
}, [NaN, -1])[1]; | ||
return val !== null && (Number.isNaN(prev[0]) || prev[0] > val) ? [val, i] : prev; | ||
}, [Number.NaN, -1])[1]; | ||
case MediatorNumber.MAX: | ||
return (tests) => tests.reduce((prev, curr, i) => { | ||
const val = this.getOrDefault(curr[this.field], -Infinity); | ||
return val !== null && (isNaN(prev[0]) || prev[0] < val) ? [val, i] : prev; | ||
}, [NaN, -1])[1]; | ||
return val !== null && (Number.isNaN(prev[0]) || prev[0] < val) ? [val, i] : prev; | ||
}, [Number.NaN, -1])[1]; | ||
default: | ||
@@ -35,0 +35,0 @@ throw new Error(`No valid "type" value was given, must be either ${MediatorNumber.MIN} or ${MediatorNumber.MAX}, but got: ${this.type}`); |
{ | ||
"name": "@comunica/mediator-number", | ||
"version": "1.15.0", | ||
"version": "1.17.0", | ||
"description": "A mediator for a single mediation number value", | ||
@@ -15,3 +15,7 @@ "lsd:module": "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/mediator-number", | ||
"typings": "index", | ||
"repository": "https://github.com/comunica/comunica/tree/master/packages/mediator-number", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/comunica/comunica.git", | ||
"directory": "packages/mediator-number" | ||
}, | ||
"publishConfig": { | ||
@@ -28,3 +32,3 @@ "access": "public" | ||
}, | ||
"homepage": "https://github.com/comunica/comunica#readme", | ||
"homepage": "https://comunica.dev/", | ||
"files": [ | ||
@@ -41,3 +45,3 @@ "components", | ||
"devDependencies": { | ||
"@comunica/core": "^1.15.0" | ||
"@comunica/core": "^1.17.0" | ||
}, | ||
@@ -66,3 +70,3 @@ "jest": { | ||
}, | ||
"gitHead": "d71011b99f9fb5d125822fd42e75db6868ef4a64" | ||
"gitHead": "cea13b435ebbda09e0ad359f54d3c62077fe3bba" | ||
} |
@@ -8,4 +8,7 @@ # Comunica Number Mediator | ||
This module is part of the [Comunica framework](https://github.com/comunica/comunica). | ||
This module is part of the [Comunica framework](https://github.com/comunica/comunica), | ||
and should only be used by [developers that want to build their own query engine](https://comunica.dev/docs/modify/). | ||
[Click here if you just want to query with Comunica](https://comunica.dev/docs/query/). | ||
## Install | ||
@@ -17,4 +20,33 @@ | ||
## Usage | ||
## Configure | ||
TODO | ||
After installing, this mediator can be instantiated as follows: | ||
```text | ||
{ | ||
"@context": [ | ||
... | ||
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/mediator-number/^1.0.0/components/context.jsonld" | ||
], | ||
"actors": [ | ||
... | ||
{ | ||
"@type": "SomeActor", | ||
"someMediator": { | ||
"@id": "config-sets:sparql-queryoperators.json#mediatorQueryOperation", | ||
"@type": "MediatorNumberMin", | ||
"cmn:Mediator/Number/field": "httpRequests", | ||
"ignoreErrors": true, | ||
"cc:Mediator/bus": { "@id": "cbqo:Bus/QueryOperation" } | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
Instead of `MediatorNumberMin`, `MediatorNumberMax` could also be used to resolve to the maximum value. | ||
### Config Parameters | ||
* `cc:Mediator/bus`: Identifier of the bus to mediate over. | ||
* `cmn:Mediator/Number/field`: The field name to mediate over. | ||
* `cmn:Mediator/Number/ignoreErrors`: Optional flag to indicate if actors that throw test errors should be ignored, defaults to false. |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
15163
118
51
0