@comunica/mediator-number
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -14,2 +14,3 @@ import { Actor, IAction, IActorOutput, IActorReply, IActorTest, IMediatorArgs, Mediator } from "@comunica/core"; | ||
readonly type: string; | ||
readonly ignoreErrors: boolean; | ||
readonly indexPicker: (tests: T[]) => number; | ||
@@ -36,2 +37,6 @@ constructor(args: IMediatorNumberArgs<A, I, T, O>); | ||
type: string; | ||
/** | ||
* If actors that throw test errors should be ignored | ||
*/ | ||
ignoreErrors?: boolean; | ||
} |
@@ -40,3 +40,9 @@ "use strict"; | ||
async mediateWith(action, testResults) { | ||
const results = await Promise.all(require('lodash.map')(testResults, 'reply')); | ||
let promises = require('lodash.map')(testResults, 'reply'); | ||
if (this.ignoreErrors) { | ||
const dummy = {}; | ||
dummy[this.field] = null; | ||
promises = promises.map((p) => p.catch(() => dummy)); | ||
} | ||
const results = await Promise.all(promises); | ||
return testResults[this.indexPicker(results)].actor; | ||
@@ -43,0 +49,0 @@ } |
{ | ||
"name": "@comunica/mediator-number", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A mediator for a single mediation number value", | ||
@@ -39,3 +39,3 @@ "lsd:module": "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/mediator-number", | ||
"devDependencies": { | ||
"@comunica/core": "^1.0.0" | ||
"@comunica/core": "^1.1.0" | ||
}, | ||
@@ -42,0 +42,0 @@ "jest": { |
# Comunica Number Mediator | ||
[![npm version](https://badge.fury.io/js/%40comunica%2Fmediator-number.svg)](https://www.npmjs.com/package/@comunica/mediator-number) | ||
A mediator that can mediate over a single number field. | ||
@@ -4,0 +6,0 @@ It can either choose the actor with the maximum or with the minimum value. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
17673
101
19