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

overmind

Package Overview
Dependencies
Maintainers
4
Versions
886
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

overmind - npm Package Compare versions

Comparing version 28.0.0-1615151570586 to 28.0.0-1615444285085

10

es/operators.d.ts

@@ -13,2 +13,12 @@ import { OperatorContextFunction } from './internalTypes';

export declare function pipe<A, B, C, D, E, F, G, H, I, J, K>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>, f: OperatorContextFunction<F, G>, g: OperatorContextFunction<G, H>, h: OperatorContextFunction<H, I>, i: OperatorContextFunction<I, J>, j: OperatorContextFunction<J, K>): IOperator<A, K>;
export declare function branch<AI, AO = AI>(a: OperatorContextFunction<AI, AO>): IOperator<AI, AI>;
export declare function branch<A, B, C>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>): IOperator<A, A>;
export declare function branch<A, B, C, D>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>): IOperator<A, A>;
export declare function branch<A, B, C, D, E>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>): IOperator<A, A>;
export declare function branch<A, B, C, D, E, F>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>): IOperator<A, A>;
export declare function branch<A, B, C, D, E, F, G>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>, f: OperatorContextFunction<F, G>): IOperator<A, A>;
export declare function branch<A, B, C, D, E, F, G, H>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>, f: OperatorContextFunction<F, G>, g: OperatorContextFunction<G, H>): IOperator<A, A>;
export declare function branch<A, B, C, D, E, F, G, H, I>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>, f: OperatorContextFunction<F, G>, g: OperatorContextFunction<G, H>, h: OperatorContextFunction<H, I>): IOperator<A, A>;
export declare function branch<A, B, C, D, E, F, G, H, I, J>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>, f: OperatorContextFunction<F, G>, g: OperatorContextFunction<G, H>, h: OperatorContextFunction<H, I>, i: OperatorContextFunction<I, J>): IOperator<A, A>;
export declare function branch<A, B, C, D, E, F, G, H, I, J, K>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>, f: OperatorContextFunction<F, G>, g: OperatorContextFunction<G, H>, h: OperatorContextFunction<H, I>, i: OperatorContextFunction<I, J>, j: OperatorContextFunction<J, K>): IOperator<A, A>;
export declare function parallel<I, O1, O2>(a: OperatorContextFunction<I, O1>, b: OperatorContextFunction<I, O2>): IOperator<I, [

@@ -15,0 +25,0 @@ O1 extends Promise<infer O1R> ? O1R : O1,

@@ -29,2 +29,30 @@ import { action, createContext, createMutationOperator, createNextPath, createOperator, operatorStarted, operatorStopped, } from './operator';

}
export function branch(...operators) {
const instance = (err, context, next, final = next) => {
if (err)
next(err, context);
else {
let operatorIndex = 0;
const run = (operatorErr, operatorContext) => {
const operator = operators[operatorIndex++];
const operatorToRun = operator
? operator[utils.IS_OPERATOR]
? operator
: action(operator)
: (err, finalContext, finalNext, finalFinal) => {
next(err, Object.assign(Object.assign({}, finalContext), { value: context.value }), finalNext, finalFinal);
};
try {
operatorToRun(operatorErr, operatorContext, run, final);
}
catch (operatorError) {
operatorToRun(operatorErr, operatorContext, run, final);
}
};
run(null, context);
}
};
instance[utils.IS_OPERATOR] = true;
return instance;
}
export function parallel(...operators) {

@@ -31,0 +59,0 @@ const instance = (err, context, next) => {

20

es/operators.test.js
import { __awaiter } from "tslib";
import { Overmind, pipe, filter, fork, when, wait, debounce, parallel, catchError, tryCatch, throttle, waitUntil, } from './';
import { Overmind, pipe, branch, filter, fork, when, wait, debounce, parallel, catchError, tryCatch, throttle, waitUntil, } from './';
describe('OPERATORS', () => {
test('branch - passes input as output', () => __awaiter(void 0, void 0, void 0, function* () {
expect.assertions(1);
const state = {
foo: 'bar',
};
const actions = {
test: pipe(branch((_, value) => value.toUpperCase()), ({ state }, value) => {
state.foo = value;
}),
};
const config = {
state,
actions,
};
const overmind = new Overmind(config);
yield overmind.actions.test('foo');
expect(overmind.state.foo).toBe('foo');
}));
test('action - return value', () => __awaiter(void 0, void 0, void 0, function* () {

@@ -5,0 +23,0 @@ expect.assertions(1);

@@ -13,2 +13,12 @@ import { OperatorContextFunction } from './internalTypes';

export declare function pipe<A, B, C, D, E, F, G, H, I, J, K>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>, f: OperatorContextFunction<F, G>, g: OperatorContextFunction<G, H>, h: OperatorContextFunction<H, I>, i: OperatorContextFunction<I, J>, j: OperatorContextFunction<J, K>): IOperator<A, K>;
export declare function branch<AI, AO = AI>(a: OperatorContextFunction<AI, AO>): IOperator<AI, AI>;
export declare function branch<A, B, C>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>): IOperator<A, A>;
export declare function branch<A, B, C, D>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>): IOperator<A, A>;
export declare function branch<A, B, C, D, E>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>): IOperator<A, A>;
export declare function branch<A, B, C, D, E, F>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>): IOperator<A, A>;
export declare function branch<A, B, C, D, E, F, G>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>, f: OperatorContextFunction<F, G>): IOperator<A, A>;
export declare function branch<A, B, C, D, E, F, G, H>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>, f: OperatorContextFunction<F, G>, g: OperatorContextFunction<G, H>): IOperator<A, A>;
export declare function branch<A, B, C, D, E, F, G, H, I>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>, f: OperatorContextFunction<F, G>, g: OperatorContextFunction<G, H>, h: OperatorContextFunction<H, I>): IOperator<A, A>;
export declare function branch<A, B, C, D, E, F, G, H, I, J>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>, f: OperatorContextFunction<F, G>, g: OperatorContextFunction<G, H>, h: OperatorContextFunction<H, I>, i: OperatorContextFunction<I, J>): IOperator<A, A>;
export declare function branch<A, B, C, D, E, F, G, H, I, J, K>(a: OperatorContextFunction<A, B>, b: OperatorContextFunction<B, C>, c: OperatorContextFunction<C, D>, d: OperatorContextFunction<D, E>, e: OperatorContextFunction<E, F>, f: OperatorContextFunction<F, G>, g: OperatorContextFunction<G, H>, h: OperatorContextFunction<H, I>, i: OperatorContextFunction<I, J>, j: OperatorContextFunction<J, K>): IOperator<A, A>;
export declare function parallel<I, O1, O2>(a: OperatorContextFunction<I, O1>, b: OperatorContextFunction<I, O2>): IOperator<I, [

@@ -15,0 +25,0 @@ O1 extends Promise<infer O1R> ? O1R : O1,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.waitUntil = exports.throttle = exports.debounce = exports.wait = exports.when = exports.fork = exports.tryCatch = exports.catchError = exports.filter = exports.noop = exports.parallel = exports.pipe = void 0;
exports.waitUntil = exports.throttle = exports.debounce = exports.wait = exports.when = exports.fork = exports.tryCatch = exports.catchError = exports.filter = exports.noop = exports.parallel = exports.branch = exports.pipe = void 0;
const tslib_1 = require("tslib");

@@ -34,2 +34,31 @@ const operator_1 = require("./operator");

exports.pipe = pipe;
function branch(...operators) {
const instance = (err, context, next, final = next) => {
if (err)
next(err, context);
else {
let operatorIndex = 0;
const run = (operatorErr, operatorContext) => {
const operator = operators[operatorIndex++];
const operatorToRun = operator
? operator[utils.IS_OPERATOR]
? operator
: operator_1.action(operator)
: (err, finalContext, finalNext, finalFinal) => {
next(err, Object.assign(Object.assign({}, finalContext), { value: context.value }), finalNext, finalFinal);
};
try {
operatorToRun(operatorErr, operatorContext, run, final);
}
catch (operatorError) {
operatorToRun(operatorErr, operatorContext, run, final);
}
};
run(null, context);
}
};
instance[utils.IS_OPERATOR] = true;
return instance;
}
exports.branch = branch;
function parallel(...operators) {

@@ -36,0 +65,0 @@ const instance = (err, context, next) => {

@@ -6,2 +6,20 @@ "use strict";

describe('OPERATORS', () => {
test('branch - passes input as output', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
expect.assertions(1);
const state = {
foo: 'bar',
};
const actions = {
test: _1.pipe(_1.branch((_, value) => value.toUpperCase()), ({ state }, value) => {
state.foo = value;
}),
};
const config = {
state,
actions,
};
const overmind = new _1.Overmind(config);
yield overmind.actions.test('foo');
expect(overmind.state.foo).toBe('foo');
}));
test('action - return value', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {

@@ -8,0 +26,0 @@ expect.assertions(1);

8

package.json
{
"name": "overmind",
"version": "28.0.0-1615151570586",
"version": "28.0.0-1615444285085",
"description": "Frictionless state management",

@@ -38,6 +38,6 @@ "author": "Christian Alfoni <christianalfoni@gmail.com>",

"is-plain-obj": "^1.1.0",
"betsy": "1.0.2-1615151570586",
"non-blocking-json": "1.1.1-1615151570586",
"betsy": "1.0.2-1615444285085",
"non-blocking-json": "1.1.1-1615444285085",
"tslib": "^1.10.0",
"proxy-state-tree": "6.3.0-1615151570586"
"proxy-state-tree": "6.3.0-1615444285085"
},

@@ -44,0 +44,0 @@ "devDependencies": {

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