New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prague

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prague - npm Package Compare versions

Comparing version 0.22.1 to 0.22.2

2

lib/src/actionReference.d.ts

@@ -16,3 +16,3 @@ import { Result } from './prague';

}
export declare type Actions = Record<string, (...args: any[]) => any>;
export declare type Actions = Record<string, Function>;
declare type Args<F extends Actions> = {

@@ -19,0 +19,0 @@ [P in keyof F]: F[P] extends (...args: infer ARGS) => any ? ARGS : never;

import { Observable } from 'rxjs';
export declare type BaseType<T> = T extends Observable<infer BASETYPE> ? BASETYPE : T extends Promise<infer BASETYPE> ? BASETYPE : T;
export declare type Observableable<T> = Observable<T> | Promise<T> | T;
export declare const toObservable: <T>(t: Observableable<T>) => Observable<T>;
export declare const toObservable: <T>(t: T) => Observable<any>;
export declare abstract class Result {

@@ -15,3 +14,3 @@ score: number;

export declare type Output = Result | null;
export declare type Nullable<T> = T extends null ? null : never;
export declare type NullIfNullable<T> = T extends null ? null : never;
export interface ResultClass<T extends Result> {

@@ -18,0 +17,0 @@ new (...args: any[]): T;

import { Result, Transform, Norm } from "./prague";
export declare function first(): Transform<[], null>;
export declare function first<ARGS extends any[] = [], R0 = never>(...args: [null | undefined | ((...args: ARGS) => R0)]): Transform<ARGS, Norm<R0>>;
export declare function first<ARGS extends any[] = [], R0 = never, R1 = never>(...args: [null | undefined | ((...args: ARGS) => R0), null | undefined | ((...args: ARGS) => R1)]): Transform<ARGS, Norm<NonNullable<R0> | R1>>;
export declare function first<ARGS extends any[] = [], R0 = never, R1 = never, R2 = never>(...args: [null | undefined | ((...args: ARGS) => R0), null | undefined | ((...args: ARGS) => R1), null | undefined | ((...args: ARGS) => R2)]): Transform<ARGS, Norm<NonNullable<R0 | R1> | R2>>;
export declare function first<ARGS extends any[] = [], R0 = never, R1 = never, R2 = never, R3 = never>(...args: [null | undefined | ((...args: ARGS) => R0), null | undefined | ((...args: ARGS) => R1), null | undefined | ((...args: ARGS) => R2), null | undefined | ((...args: ARGS) => R3)]): Transform<ARGS, Norm<NonNullable<R0 | R1 | R2> | R3>>;
export declare function first<ARGS extends any[] = [], R0 = never, R1 = never, R2 = never, R3 = never, R4 = never>(...args: [null | undefined | ((...args: ARGS) => R0), null | undefined | ((...args: ARGS) => R1), null | undefined | ((...args: ARGS) => R2), null | undefined | ((...args: ARGS) => R3), null | undefined | ((...args: ARGS) => R4)]): Transform<ARGS, Norm<NonNullable<R0 | R1 | R2 | R3> | R4>>;
export declare function first<ARGS extends any[] = []>(...args: (null | undefined | ((...args: ARGS) => any))[]): Transform<ARGS, Result>;
export declare function first<ARGS extends any[], R0>(...args: [(...args: ARGS) => R0]): Transform<ARGS, Norm<R0>>;
export declare function first<ARGS extends any[], R0, R1>(...args: [(...args: ARGS) => R0, (...args: ARGS) => R1]): Transform<ARGS, NonNullable<Norm<R0>> | Norm<R1>>;
export declare function first<ARGS extends any[], R0, R1, R2>(...args: [(...args: ARGS) => R0, (...args: ARGS) => R1, (...args: ARGS) => R2]): Transform<ARGS, NonNullable<Norm<R0 | R1>> | Norm<R2>>;
export declare function first<ARGS extends any[], R0, R1, R2, R3>(...args: [(...args: ARGS) => R0, (...args: ARGS) => R1, (...args: ARGS) => R2, (...args: ARGS) => R3]): Transform<ARGS, NonNullable<Norm<R0 | R1 | R2>> | Norm<R3>>;
export declare function first<ARGS extends any[], R0, R1, R2, R3, R4>(...args: [(...args: ARGS) => R0, (...args: ARGS) => R1, (...args: ARGS) => R2, (...args: ARGS) => R3, (...args: ARGS) => R4]): Transform<ARGS, NonNullable<Norm<R0 | R1 | R2 | R3>> | Norm<R4>>;
export declare function first<ARGS extends any[]>(...args: ((...args: ARGS) => any)[]): Transform<ARGS, Result>;

@@ -6,13 +6,11 @@ "use strict";

const operators_1 = require("rxjs/operators");
const core_1 = require("./core");
function first(...transforms) {
return transforms.length === 0
? core_1.transformToNull
: prague_1.from((...args) => rxjs_1.from(transforms.map(transform => prague_1.from(transform))).pipe(
// we put concatMap here because it forces everything to after it to execute serially
operators_1.concatMap(transform => transform(...args)), prague_1.filterOutNull,
// Stop when one emits a result
operators_1.take(1), prague_1.filterOutNull));
const _transforms = rxjs_1.from(transforms.map(transform => prague_1.from(transform)));
return prague_1.from((...args) => _transforms.pipe(
// we put concatMap here because it forces everything to after it to execute serially
operators_1.concatMap(transform => transform(...args)), prague_1.filterOutNull,
// Stop when one emits a result
operators_1.take(1), prague_1.filterOutNull));
}
exports.first = first;
//# sourceMappingURL=first.js.map

@@ -1,3 +0,5 @@

import { Observableable, Value } from './prague';
export declare function match<ARGS extends any[], VALUE, ONVALUE, ONNULL = null>(getValue: (...args: ARGS) => Observableable<null | undefined | VALUE | Value<VALUE>>, onValue: (value: Value<VALUE>) => ONVALUE, onNull?: () => ONNULL): import("./core").Transform<ARGS, (ONVALUE extends null | undefined ? null : ONVALUE extends import("./core").Result ? ONVALUE : ONVALUE extends () => any ? import("./core").Action : Value<ONVALUE>) | (ONNULL extends null | undefined ? null : ONNULL extends import("./core").Result ? ONNULL : ONNULL extends () => any ? import("./core").Action : Value<ONNULL>) | ((VALUE extends null | undefined ? null : VALUE extends import("./core").Result ? VALUE : VALUE extends () => any ? import("./core").Action : Value<VALUE>) extends null | undefined ? null : (VALUE extends null | undefined ? null : VALUE extends import("./core").Result ? VALUE : VALUE extends () => any ? import("./core").Action : Value<VALUE>) extends import("./core").Result ? VALUE extends null | undefined ? null : VALUE extends import("./core").Result ? VALUE : VALUE extends () => any ? import("./core").Action : Value<VALUE> : (VALUE extends null | undefined ? null : VALUE extends import("./core").Result ? VALUE : VALUE extends () => any ? import("./core").Action : Value<VALUE>) extends () => any ? import("./core").Action : Value<VALUE extends null | undefined ? null : VALUE extends import("./core").Result ? VALUE : VALUE extends () => any ? import("./core").Action : Value<VALUE>>) | ((import("./core").BaseType<VALUE> extends null | undefined ? null : import("./core").BaseType<VALUE> extends import("./core").Result ? import("./core").BaseType<VALUE> : import("./core").BaseType<VALUE> extends () => any ? import("./core").Action : Value<import("./core").BaseType<VALUE>>) extends null | undefined ? null : (import("./core").BaseType<VALUE> extends null | undefined ? null : import("./core").BaseType<VALUE> extends import("./core").Result ? import("./core").BaseType<VALUE> : import("./core").BaseType<VALUE> extends () => any ? import("./core").Action : Value<import("./core").BaseType<VALUE>>) extends import("./core").Result ? import("./core").BaseType<VALUE> extends null | undefined ? null : import("./core").BaseType<VALUE> extends import("./core").Result ? import("./core").BaseType<VALUE> : import("./core").BaseType<VALUE> extends () => any ? import("./core").Action : Value<import("./core").BaseType<VALUE>> : (import("./core").BaseType<VALUE> extends null | undefined ? null : import("./core").BaseType<VALUE> extends import("./core").Result ? import("./core").BaseType<VALUE> : import("./core").BaseType<VALUE> extends () => any ? import("./core").Action : Value<import("./core").BaseType<VALUE>>) extends () => any ? import("./core").Action : Value<import("./core").BaseType<VALUE> extends null | undefined ? null : import("./core").BaseType<VALUE> extends import("./core").Result ? import("./core").BaseType<VALUE> : import("./core").BaseType<VALUE> extends () => any ? import("./core").Action : Value<import("./core").BaseType<VALUE>>>) | null>;
export declare function matchIf<ARGS extends any[], ONTRUTHY, ONFALSEY>(predicate: (...args: ARGS) => any, onTruthy: () => ONTRUTHY, onFalsey?: () => ONFALSEY): import("./core").Transform<ARGS, (ONTRUTHY extends null | undefined ? null : ONTRUTHY extends import("./core").Result ? ONTRUTHY : ONTRUTHY extends () => any ? import("./core").Action : Value<ONTRUTHY>) | (ONFALSEY extends null | undefined ? null : ONFALSEY extends import("./core").Result ? ONFALSEY : ONFALSEY extends () => any ? import("./core").Action : Value<ONFALSEY>) | Value<false> | Value<true> | null>;
import { Value, Norm } from './prague';
declare type ValueType<T> = T extends Value<infer V> ? Value<V> : never;
export declare function match<ARGS extends any[], O, ONVALUE, ONNULL = null>(getValue: (...args: ARGS) => O, onValue: (value: ValueType<Norm<O>>) => ONVALUE, onNull?: () => ONNULL): import("./core").Transform<ARGS, (import("./core").BaseType<ONVALUE> extends null | undefined ? null : import("./core").BaseType<ONVALUE> extends import("./core").Result ? import("./core").BaseType<ONVALUE> : import("./core").BaseType<ONVALUE> extends () => any ? import("./core").Action : Value<import("./core").BaseType<ONVALUE>>) | (import("./core").BaseType<ONNULL> extends null | undefined ? null : import("./core").BaseType<ONNULL> extends import("./core").Result ? import("./core").BaseType<ONNULL> : import("./core").BaseType<ONNULL> extends () => any ? import("./core").Action : Value<import("./core").BaseType<ONNULL>>) | null>;
export declare function matchIf<ARGS extends any[], ONTRUTHY, ONFALSEY>(predicate: (...args: ARGS) => any, onTruthy: () => ONTRUTHY, onFalsey?: () => ONFALSEY): import("./core").Transform<ARGS, (import("./core").BaseType<ONTRUTHY> extends null | undefined ? null : import("./core").BaseType<ONTRUTHY> extends import("./core").Result ? import("./core").BaseType<ONTRUTHY> : import("./core").BaseType<ONTRUTHY> extends () => any ? import("./core").Action : Value<import("./core").BaseType<ONTRUTHY>>) | (import("./core").BaseType<ONFALSEY> extends null | undefined ? null : import("./core").BaseType<ONFALSEY> extends import("./core").Result ? import("./core").BaseType<ONFALSEY> : import("./core").BaseType<ONFALSEY> extends () => any ? import("./core").Action : Value<import("./core").BaseType<ONFALSEY>>) | null>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const prague_1 = require("./prague");
const getMatchError = new Error("getValue transform should only return Value or null");
function match(getValue, onValue, onNull) {
return prague_1.from((...args) => prague_1.from(getValue)(...args).pipe(operators_1.map(o => {
return prague_1.combine(getValue, o => {
if (o === null)
return onNull ? onNull() : null;
if (o instanceof prague_1.Value)
return onValue(o);
if (o === null)
return onNull ? onNull() : o;
throw getMatchError;
})));
throw "getValue transform should only return Value or null";
});
}

@@ -19,5 +16,5 @@ exports.match = match;

function matchIf(predicate, onTruthy, onFalsey) {
return match((...args) => rxjs_1.of(args).pipe(operators_1.map(args => predicate(...args)), operators_1.flatMap(prague_1.toObservable), operators_1.map(o => o instanceof prague_1.Value && !o.value || !o ? null : trueValue)), onTruthy, onFalsey);
return match(prague_1.combine(predicate, o => o instanceof prague_1.Value && !o.value || !o ? null : trueValue), onTruthy, onFalsey);
}
exports.matchIf = matchIf;
//# sourceMappingURL=matching.js.map

@@ -1,7 +0,7 @@

import { Result, Transform, Norm, Action, ResultClass, Output, Nullable } from "./prague";
import { Result, Transform, Norm, Action, ResultClass, Output, NullIfNullable } from "./prague";
export declare function pipe<ARGS extends any[], R0>(...args: [(...args: ARGS) => R0]): Transform<ARGS, Norm<R0>>;
export declare function pipe<ARGS extends any[], R0, R1>(...args: [(...args: ARGS) => R0, (arg: NonNullable<Norm<R0>>) => R1]): Transform<ARGS, Nullable<Norm<R0>> | Norm<R1>>;
export declare function pipe<ARGS extends any[], R0, R1, R2>(...args: [(...args: ARGS) => R0, (arg: NonNullable<Norm<R0>>) => R1, (arg: NonNullable<Norm<R1>>) => R2]): Transform<ARGS, Nullable<Norm<R0 | R1>> | Norm<R2>>;
export declare function pipe<ARGS extends any[], R0, R1, R2, R3>(...args: [(...args: ARGS) => R0, (arg: NonNullable<Norm<R0>>) => R1, (arg: NonNullable<Norm<R1>>) => R2, (arg: NonNullable<Norm<R2>>) => R3]): Transform<ARGS, Nullable<Norm<R0 | R1 | R2>> | Norm<R3>>;
export declare function pipe<ARGS extends any[], R0, R1, R2, R3, R4>(...args: [(...args: ARGS) => R0, (arg: NonNullable<Norm<R0>>) => R1, (arg: NonNullable<Norm<R1>>) => R2, (arg: NonNullable<Norm<R2>>) => R3, (arg: NonNullable<Norm<R2>>) => R4]): Transform<ARGS, Nullable<Norm<R0 | R1 | R2 | R3>> | Norm<R4>>;
export declare function pipe<ARGS extends any[], R0, R1>(...args: [(...args: ARGS) => R0, (arg: NonNullable<Norm<R0>>) => R1]): Transform<ARGS, NullIfNullable<Norm<R0>> | Norm<R1>>;
export declare function pipe<ARGS extends any[], R0, R1, R2>(...args: [(...args: ARGS) => R0, (arg: NonNullable<Norm<R0>>) => R1, (arg: NonNullable<Norm<R1>>) => R2]): Transform<ARGS, NullIfNullable<Norm<R0 | R1>> | Norm<R2>>;
export declare function pipe<ARGS extends any[], R0, R1, R2, R3>(...args: [(...args: ARGS) => R0, (arg: NonNullable<Norm<R0>>) => R1, (arg: NonNullable<Norm<R1>>) => R2, (arg: NonNullable<Norm<R2>>) => R3]): Transform<ARGS, NullIfNullable<Norm<R0 | R1 | R2>> | Norm<R3>>;
export declare function pipe<ARGS extends any[], R0, R1, R2, R3, R4>(...args: [(...args: ARGS) => R0, (arg: NonNullable<Norm<R0>>) => R1, (arg: NonNullable<Norm<R1>>) => R2, (arg: NonNullable<Norm<R2>>) => R3, (arg: NonNullable<Norm<R2>>) => R4]): Transform<ARGS, NullIfNullable<Norm<R0 | R1 | R2 | R3>> | Norm<R4>>;
export declare function pipe<ARGS extends any[]>(transform: (...args: ARGS) => any, ...transforms: ((result: Result) => any)[]): Transform<ARGS, Output>;

@@ -13,1 +13,7 @@ export declare const tap: <RESULT extends Result>(fn: (result: RESULT) => any) => Transform<[RESULT], RESULT>;

export declare const run: Transform<[Result], Result>;
export declare function combine<ARGS extends any[], R0>(...args: [(...args: ARGS) => R0]): Transform<ARGS, Norm<R0>>;
export declare function combine<ARGS extends any[], R0, R1>(...args: [(...args: ARGS) => R0, (arg: Norm<R0>) => R1]): Transform<ARGS, Norm<R1>>;
export declare function combine<ARGS extends any[], R0, R1, R2>(...args: [(...args: ARGS) => R0, (arg: Norm<R0>) => R1, (arg: Norm<R1>) => R2]): Transform<ARGS, Norm<R2>>;
export declare function combine<ARGS extends any[], R0, R1, R2, R3>(...args: [(...args: ARGS) => R0, (arg: Norm<R0>) => R1, (arg: Norm<R1>) => R2, (arg: Norm<R2>) => R3]): Transform<ARGS, Norm<R3>>;
export declare function combine<ARGS extends any[], R0, R1, R2, R3, R4>(...args: [(...args: ARGS) => R0, (arg: Norm<R0>) => R1, (arg: Norm<R1>) => R2, (arg: Norm<R2>) => R3, (arg: Norm<R2>) => R4]): Transform<ARGS, Norm<R4>>;
export declare function combine<ARGS extends any[]>(transform: (...args: ARGS) => any, ...transforms: ((result: Output) => any)[]): Transform<ARGS, Output>;

@@ -6,4 +6,6 @@ "use strict";

const operators_1 = require("rxjs/operators");
function pipe(transform, ...transforms) {
return prague_1.from((...args) => rxjs_1.from(transforms.map(_transform => prague_1.from(_transform))).pipe(operators_1.reduce((result$, _transform) => result$.pipe(operators_1.flatMap(result => _transform(result)), prague_1.filterOutNull), prague_1.from(transform)(...args).pipe(prague_1.filterOutNull)), operators_1.mergeAll(), prague_1.nullIfEmpty));
function pipe(...transforms) {
const [_transform, ..._transforms] = transforms.map(_transform => prague_1.from(_transform));
const __transforms = rxjs_1.from(_transforms);
return prague_1.from((...args) => __transforms.pipe(operators_1.reduce((result$, _transform) => result$.pipe(operators_1.flatMap(result => _transform(result)), prague_1.filterOutNull), _transform(...args).pipe(prague_1.filterOutNull)), operators_1.mergeAll(), prague_1.nullIfEmpty));
}

@@ -16,2 +18,8 @@ exports.pipe = pipe;

exports.run = exports.tap(exports.transformResult(prague_1.Action, action => action.action()));
function combine(...transforms) {
const [_transform, ..._transforms] = transforms.map(_transform => prague_1.from(_transform));
const __transforms = rxjs_1.from(_transforms);
return prague_1.from((...args) => __transforms.pipe(operators_1.reduce((result$, _transform) => result$.pipe(operators_1.flatMap(result => _transform(result))), _transform(...args)), operators_1.mergeAll()));
}
exports.combine = combine;
//# sourceMappingURL=pipe.js.map

@@ -14,3 +14,4 @@ "use strict";

function sorted(...transforms) {
return prague_1.from((...args) => rxjs_1.from(transforms.map(transform => prague_1.from(transform))).pipe(operators_1.flatMap(transform => transform(...args)), prague_1.filterOutNull, operators_1.flatMap(result => result instanceof Multiple ? rxjs_1.from(result.results) : rxjs_1.of(result)), operators_1.toArray(), operators_1.map(results => results.length === 0 ? null :
const _transforms = rxjs_1.from(transforms.map(transform => prague_1.from(transform)));
return prague_1.from((...args) => _transforms.pipe(operators_1.flatMap(transform => transform(...args)), prague_1.filterOutNull, operators_1.flatMap(result => result instanceof Multiple ? rxjs_1.from(result.results) : rxjs_1.of(result)), operators_1.toArray(), operators_1.map(results => results.length === 0 ? null :
results.length === 1 ? results[0] :

@@ -17,0 +18,0 @@ new Multiple(results.sort((a, b) => b.score - a.score)))));

{
"name": "prague",
"version": "0.22.1",
"version": "0.22.2",
"description": "EDSL for rules",

@@ -5,0 +5,0 @@ "main": "lib/src/prague.js",

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

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