Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@comunica/mediator-number

Package Overview
Dependencies
Maintainers
5
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@comunica/mediator-number - npm Package Compare versions

Comparing version 3.2.4-alpha.47.0 to 3.3.0

16

lib/MediatorNumber.d.ts

@@ -1,2 +0,2 @@

import type { Actor, IAction, IActorOutput, IActorReply, IActorTest, IMediatorArgs, TestResult } from '@comunica/core';
import type { Actor, IAction, IActorOutput, IActorReply, IActorTest, IMediatorArgs } from '@comunica/core';
import { Mediator } from '@comunica/core';

@@ -10,8 +10,8 @@ /**

*/
export declare class MediatorNumber<A extends Actor<I, T, O, TS>, I extends IAction, T extends IActorTest, O extends IActorOutput, TS> extends Mediator<A, I, T, O, TS> implements IMediatorNumberArgs<A, I, T, O, TS> {
export declare class MediatorNumber<A extends Actor<I, T, O>, I extends IAction, T extends IActorTest, O extends IActorOutput> extends Mediator<A, I, T, O> implements IMediatorNumberArgs<A, I, T, O> {
readonly field: string;
readonly type: 'min' | 'max';
readonly ignoreFailures: boolean;
readonly ignoreErrors: boolean;
readonly indexPicker: (tests: T[]) => number;
constructor(args: IMediatorNumberArgs<A, I, T, O, TS>);
constructor(args: IMediatorNumberArgs<A, I, T, O>);
/**

@@ -23,5 +23,5 @@ * @return {(tests: T[]) => number} A function that returns the index of the test result

protected getOrDefault(value: number | undefined, defaultValue: number): number;
protected mediateWith(action: I, testResults: IActorReply<A, I, T, O, TS>[]): Promise<TestResult<A, TS>>;
protected mediateWith(action: I, testResults: IActorReply<A, I, T, O>[]): Promise<A>;
}
export interface IMediatorNumberArgs<A extends Actor<I, T, O, TS>, I extends IAction, T extends IActorTest, O extends IActorOutput, TS> extends IMediatorArgs<A, I, T, O, TS> {
export interface IMediatorNumberArgs<A extends Actor<I, T, O>, I extends IAction, T extends IActorTest, O extends IActorOutput> extends IMediatorArgs<A, I, T, O> {
/**

@@ -38,5 +38,5 @@ * The field name of the test result field over which must be mediated.

/**
* If actors that throw fail tests should be ignored
* If actors that throw test errors should be ignored
*/
ignoreFailures?: boolean;
ignoreErrors?: boolean;
}

@@ -43,29 +43,19 @@ "use strict";

async mediateWith(action, testResults) {
let wrappedResults = await Promise.all(testResults.map(({ reply }) => reply));
// Collect failures if we want to ignore them
const failures = [];
if (this.ignoreFailures) {
let promises = testResults.map(({ reply }) => reply);
const errors = [];
if (this.ignoreErrors) {
const dummy = {};
dummy[this.field] = null;
wrappedResults = wrappedResults.map((result) => {
if (result.isFailed()) {
failures.push(result.getFailMessage());
return (0, core_1.passTestWithSideData)(dummy, undefined);
}
return result;
});
// eslint-disable-next-line ts/no-floating-promises
promises = promises.map(promise => promise.catch((error) => {
errors.push(error);
return dummy;
}));
}
// Resolve values
const sideDatas = [];
const results = wrappedResults.map((result, i) => {
const value = result.getOrThrow();
sideDatas[i] = result.getSideData();
return value;
});
// Determine one value
const results = await Promise.all(promises);
const index = this.indexPicker(results);
if (index < 0) {
return (0, core_1.failTest)(this.constructFailureMessage(action, failures));
throw new Error(`All actors rejected their test in ${this.name}\n${errors.map(error => error.message).join('\n')}`);
}
return (0, core_1.passTestWithSideData)(testResults[index].actor, sideDatas[index]);
return testResults[index].actor;
}

@@ -72,0 +62,0 @@ }

{
"name": "@comunica/mediator-number",
"version": "3.2.4-alpha.47.0",
"version": "3.3.0",
"description": "A mediator for a single mediation number value",
"lsd:module": true,
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/comunica-association"
},
"homepage": "https://comunica.dev/",

@@ -42,5 +38,5 @@ "repository": {

"dependencies": {
"@comunica/core": "3.2.4-alpha.47.0"
"@comunica/core": "^3.3.0"
},
"gitHead": "85bd4c5cf07dfc293ebbc3a1416b70e2db8bfc48"
"gitHead": "02bde397d206f1f5a523643a6a604c89e792e2f9"
}

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