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.1 to 3.2.4-alpha.47.0

16

lib/MediatorNumber.d.ts

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

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

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

*/
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> {
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> {
readonly field: string;
readonly type: 'min' | 'max';
readonly ignoreErrors: boolean;
readonly ignoreFailures: boolean;
readonly indexPicker: (tests: T[]) => number;
constructor(args: IMediatorNumberArgs<A, I, T, O>);
constructor(args: IMediatorNumberArgs<A, I, T, O, TS>);
/**

@@ -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>[]): Promise<A>;
protected mediateWith(action: I, testResults: IActorReply<A, I, T, O, TS>[]): Promise<TestResult<A, 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> {
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> {
/**

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

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

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

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

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

{
"name": "@comunica/mediator-number",
"version": "3.2.1",
"version": "3.2.4-alpha.47.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/",

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

"dependencies": {
"@comunica/core": "^3.2.1"
"@comunica/core": "3.2.4-alpha.47.0"
},
"gitHead": "f558377c3cefbd1606c51ede80440b862e7dda4f"
"gitHead": "85bd4c5cf07dfc293ebbc3a1416b70e2db8bfc48"
}

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