overmind
Version:
Frictionless state management
1 lines • 26 kB
Source Map (JSON)
{"version":3,"file":"operators.js","sourceRoot":"","sources":["../src/operators.ts"],"names":[],"mappings":";;;;AACA,yCAQmB;AAEnB,uDAAgC;AA6EhC,SAAgB,IAAI,CAAC,GAAG,SAAS;IAC/B,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,EAAE;QACpD,IAAI,GAAG;YAAE,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;aACtB;YACH,IAAI,aAAa,GAAG,CAAC,CAAA;YAErB,MAAM,GAAG,GAAG,CAAC,WAAW,EAAE,eAAe,EAAE,EAAE;gBAC3C,MAAM,QAAQ,GAAG,SAAS,CAAC,aAAa,EAAE,CAAC,CAAA;gBAC3C,MAAM,aAAa,GAAG,QAAQ;oBAC5B,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC;wBAC3B,CAAC,CAAC,QAAQ;wBACV,CAAC,CAAC,IAAA,iBAAM,EAAC,QAAQ,CAAC;oBACpB,CAAC,CAAC,IAAI,CAAA;gBACR,IAAI;oBACF,aAAa,CAAC,WAAW,EAAE,eAAe,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;iBACxD;gBAAC,OAAO,aAAa,EAAE;oBACtB,aAAa,CAAC,WAAW,EAAE,eAAe,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;iBACxD;YACH,CAAC,CAAA;YAED,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;SACnB;IACH,CAAC,CAAA;IACD,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,IAAI,CAAA;IAClC,OAAO,QAAQ,CAAA;AACjB,CAAC;AAzBD,oBAyBC;AA6ED,SAAgB,MAAM,CAAC,GAAG,SAAS;IACjC,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE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;gBAC1B,CAAC,EAAE,EAAE,CAAC,CAAA;aACP;YACD,aAAa,GAAG,KAAK,CAAA;YACrB,WAAW,GAAG,IAAI,CAAA;SACnB;IACH,CAAC,CACF,CAAA;AACH,CAAC;AAzBD,4BAyBC;AAED,SAAgB,SAAS,CACvB,SAAyC;IAEzC,OAAO,IAAA,yBAAc,EACnB,WAAW,EACX,SAAS,CAAC,IAAI,EACd,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC5B,IAAI,GAAG;YAAE,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;aACpB;YACH,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,iBAAiB,EAAE,CAAA;YAClD,MAAM,IAAI,GAAG,GAAG,EAAE;gBAChB,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;oBACzB,IAAI,CAAC,OAAO,EAAE,CAAA;oBACd,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;iBAClB;YACH,CAAC,CAAA;YACD,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;SAC5B;IACH,CAAC,CACF,CAAA;AACH,CAAC;AApBD,8BAoBC","sourcesContent":["import { OperatorContextFunction } from './internalTypes'\nimport {\n action,\n createContext,\n createMutationOperator,\n createNextPath,\n createOperator,\n operatorStarted,\n operatorStopped,\n} from './operator'\nimport { IContext, IOperator } from './types'\nimport * as utils from './utils'\n\nexport function pipe<AI, AO = AI>(\n a: OperatorContextFunction<AI, AO>\n): IOperator<AI, AO>\nexport function pipe<A, B, C>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>\n): IOperator<A, C>\nexport function pipe<A, B, C, D>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>\n): IOperator<A, D>\nexport function pipe<A, B, C, D, E>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>\n): IOperator<A, E>\nexport function pipe<A, B, C, D, E, F>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>,\n e: OperatorContextFunction<E, F>\n): IOperator<A, F>\nexport function pipe<A, B, C, D, E, F, G>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>,\n e: OperatorContextFunction<E, F>,\n f: OperatorContextFunction<F, G>\n): IOperator<A, G>\nexport function pipe<A, B, C, D, E, F, G, H>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>,\n e: OperatorContextFunction<E, F>,\n f: OperatorContextFunction<F, G>,\n g: OperatorContextFunction<G, H>\n): IOperator<A, H>\nexport function pipe<A, B, C, D, E, F, G, H, I>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>,\n e: OperatorContextFunction<E, F>,\n f: OperatorContextFunction<F, G>,\n g: OperatorContextFunction<G, H>,\n h: OperatorContextFunction<H, I>\n): IOperator<A, I>\nexport function pipe<A, B, C, D, E, F, G, H, I, J>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>,\n e: OperatorContextFunction<E, F>,\n f: OperatorContextFunction<F, G>,\n g: OperatorContextFunction<G, H>,\n h: OperatorContextFunction<H, I>,\n i: OperatorContextFunction<I, J>\n): IOperator<A, J>\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>,\n e: OperatorContextFunction<E, F>,\n f: OperatorContextFunction<F, G>,\n g: OperatorContextFunction<G, H>,\n h: OperatorContextFunction<H, I>,\n i: OperatorContextFunction<I, J>,\n j: OperatorContextFunction<J, K>\n): IOperator<A, K>\nexport function pipe(...operators) {\n const instance = (err, context, next, final = next) => {\n if (err) next(err, context)\n else {\n let operatorIndex = 0\n\n const run = (operatorErr, operatorContext) => {\n const operator = operators[operatorIndex++]\n const operatorToRun = operator\n ? operator[utils.IS_OPERATOR]\n ? operator\n : action(operator)\n : next\n try {\n operatorToRun(operatorErr, operatorContext, run, final)\n } catch (operatorError) {\n operatorToRun(operatorErr, operatorContext, run, final)\n }\n }\n\n run(null, context)\n }\n }\n instance[utils.IS_OPERATOR] = true\n return instance\n}\n\nexport function branch<AI, AO = AI>(\n a: OperatorContextFunction<AI, AO>\n): IOperator<AI, AI>\nexport function branch<A, B, C>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>\n): IOperator<A, A>\nexport function branch<A, B, C, D>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>\n): IOperator<A, A>\nexport function branch<A, B, C, D, E>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>\n): IOperator<A, A>\nexport function branch<A, B, C, D, E, F>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>,\n e: OperatorContextFunction<E, F>\n): IOperator<A, A>\nexport function branch<A, B, C, D, E, F, G>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>,\n e: OperatorContextFunction<E, F>,\n f: OperatorContextFunction<F, G>\n): IOperator<A, A>\nexport function branch<A, B, C, D, E, F, G, H>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>,\n e: OperatorContextFunction<E, F>,\n f: OperatorContextFunction<F, G>,\n g: OperatorContextFunction<G, H>\n): IOperator<A, A>\nexport function branch<A, B, C, D, E, F, G, H, I>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>,\n e: OperatorContextFunction<E, F>,\n f: OperatorContextFunction<F, G>,\n g: OperatorContextFunction<G, H>,\n h: OperatorContextFunction<H, I>\n): IOperator<A, A>\nexport function branch<A, B, C, D, E, F, G, H, I, J>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>,\n e: OperatorContextFunction<E, F>,\n f: OperatorContextFunction<F, G>,\n g: OperatorContextFunction<G, H>,\n h: OperatorContextFunction<H, I>,\n i: OperatorContextFunction<I, J>\n): IOperator<A, A>\nexport function branch<A, B, C, D, E, F, G, H, I, J, K>(\n a: OperatorContextFunction<A, B>,\n b: OperatorContextFunction<B, C>,\n c: OperatorContextFunction<C, D>,\n d: OperatorContextFunction<D, E>,\n e: OperatorContextFunction<E, F>,\n f: OperatorContextFunction<F, G>,\n g: OperatorContextFunction<G, H>,\n h: OperatorContextFunction<H, I>,\n i: OperatorContextFunction<I, J>,\n j: OperatorContextFunction<J, K>\n): IOperator<A, A>\nexport function branch(...operators) {\n const instance = (err, context, next, final = next) => {\n if (err) next(err, context)\n else {\n let operatorIndex = 0\n\n const run = (operatorErr, operatorContext) => {\n const operator = operators[operatorIndex++]\n const operatorToRun = operator\n ? operator[utils.IS_OPERATOR]\n ? operator\n : action(operator)\n : (err, finalContext, finalNext, finalFinal) => {\n next(\n err,\n {\n ...finalContext,\n value: context.value,\n },\n finalNext,\n finalFinal\n )\n }\n try {\n operatorToRun(operatorErr, operatorContext, run, final)\n } catch (operatorError) {\n operatorToRun(operatorErr, operatorContext, run, final)\n }\n }\n\n run(null, context)\n }\n }\n instance[utils.IS_OPERATOR] = true\n return instance\n}\n\n/*\n OPERATORS\n */\n\nexport function parallel<I, O1, O2>(\n a: OperatorContextFunction<I, O1>,\n b: OperatorContextFunction<I, O2>\n): IOperator<\n I,\n [\n O1 extends Promise<infer O1R> ? O1R : O1,\n O2 extends Promise<infer O2R> ? O2R : O2\n ]\n>\nexport function parallel<I, O1, O2, O3>(\n a: OperatorContextFunction<I, O1>,\n b: OperatorContextFunction<I, O2>,\n c: OperatorContextFunction<I, O3>\n): IOperator<\n I,\n [\n O1 extends Promise<infer O1R> ? O1R : O1,\n O2 extends Promise<infer O2R> ? O2R : O2,\n O3 extends Promise<infer O3R> ? O3R : O3\n ]\n>\nexport function parallel<I, O1, O2, O3, O4>(\n a: OperatorContextFunction<I, O1>,\n b: OperatorContextFunction<I, O2>,\n c: OperatorContextFunction<I, O3>,\n d: OperatorContextFunction<I, O4>\n): IOperator<\n I,\n [\n O1 extends Promise<infer O1R> ? O1R : O1,\n O2 extends Promise<infer O2R> ? O2R : O2,\n O3 extends Promise<infer O3R> ? O3R : O3,\n O4 extends Promise<infer O4R> ? O4R : O4\n ]\n>\nexport function parallel<I, O1, O2, O3, O4, O5>(\n a: OperatorContextFunction<I, O1>,\n b: OperatorContextFunction<I, O2>,\n c: OperatorContextFunction<I, O3>,\n d: OperatorContextFunction<I, O4>,\n e: OperatorContextFunction<I, O5>\n): IOperator<\n I,\n [\n O1 extends Promise<infer O1R> ? O1R : O1,\n O2 extends Promise<infer O2R> ? O2R : O2,\n O3 extends Promise<infer O3R> ? O3R : O3,\n O4 extends Promise<infer O4R> ? O4R : O4,\n O5 extends Promise<infer O5R> ? O5R : O5\n ]\n>\nexport function parallel<I, O1, O2, O3, O4, O5, O6>(\n a: OperatorContextFunction<I, O1>,\n b: OperatorContextFunction<I, O2>,\n c: OperatorContextFunction<I, O3>,\n d: OperatorContextFunction<I, O4>,\n e: OperatorContextFunction<I, O5>,\n f: OperatorContextFunction<I, O5>\n): IOperator<\n I,\n [\n O1 extends Promise<infer O1R> ? O1R : O1,\n O2 extends Promise<infer O2R> ? O2R : O2,\n O3 extends Promise<infer O3R> ? O3R : O3,\n O4 extends Promise<infer O4R> ? O4R : O4,\n O5 extends Promise<infer O5R> ? O5R : O5,\n O6 extends Promise<infer O6R> ? O6R : O6\n ]\n>\nexport function parallel<T extends OperatorContextFunction<any, any>>(\n ...operators: T[]\n): T {\n const instance = (err, context, next) => {\n if (err) next(err, context)\n else {\n let evaluatingCount = operators.length\n let lastContext\n let hasErrored = false\n const results: any[] = []\n const evaluate = (index, err, newContext) => {\n if (hasErrored) {\n return\n }\n if (err) {\n hasErrored = true\n return next(err, lastContext)\n }\n results[index] = newContext.value\n evaluatingCount--\n\n if (!evaluatingCount) {\n operatorStopped(context, results)\n next(\n null,\n createContext(\n lastContext,\n results,\n lastContext.execution.path &&\n lastContext.execution.path.slice(\n 0,\n lastContext.execution.path.length - 1\n )\n )\n )\n }\n }\n operatorStarted('parallel', '', context)\n\n operators.forEach((operator, index) => {\n lastContext = createContext(\n lastContext || context,\n context.value,\n context.execution.path && context.execution.path.concat(String(index))\n )\n const nextWithPath = createNextPath(evaluate.bind(undefined, index))\n\n const operatorToRun = operator[utils.IS_OPERATOR]\n ? operator\n : action(operator)\n // @ts-ignore\n operatorToRun(null, lastContext, nextWithPath)\n })\n }\n }\n instance[utils.IS_OPERATOR] = true\n\n return instance as any\n}\n\nexport function noop<T>(): IOperator<T, T> {\n return createOperator('noop', '', (err, context, value, next) => {\n if (err) next(err, value)\n else next(null, value)\n })\n}\n\nexport function filter<T>(\n operation: OperatorContextFunction<T, boolean>\n): IOperator<T, T> {\n return createOperator(\n 'filter',\n utils.getFunctionName(operation),\n (err, context, value, next, final) => {\n if (err) next(err, value)\n else if (operation(context, value)) next(null, value)\n else final(null, value)\n }\n )\n}\n\nexport function catchError<T>(\n operation: OperatorContextFunction<Error, T>\n): IOperator<T, T> {\n return createMutationOperator(\n 'catchError',\n utils.getFunctionName(operation),\n (err, context, value, next) => {\n if (err) next(null, operation(context, err))\n else\n next(null, value, {\n isSkipped: true,\n })\n }\n )\n}\n\nexport function tryCatch<T, K>(paths: {\n try: OperatorContextFunction<T, K>\n catch: OperatorContextFunction<Error, K>\n}): IOperator<T, K> {\n const instance = (err, context, next) => {\n if (err) next(err, context)\n else {\n const evaluateCatch = (err, catchContext) => {\n operatorStopped(context, context.value)\n next(err, createContext(catchContext, context.value))\n }\n const evaluateTry = (err, tryContext) => {\n if (err) {\n const newContext = createContext(\n tryContext,\n err,\n context.execution.path && context.execution.path.concat('catch')\n )\n const nextWithPath = createNextPath(evaluateCatch)\n const operatorToRun = paths.try[utils.IS_OPERATOR]\n ? paths.catch\n : action(paths.catch)\n\n // @ts-ignore\n operatorToRun(null, newContext, nextWithPath)\n } else {\n operatorStopped(context, context.value)\n next(null, createContext(tryContext, context.value))\n }\n }\n\n operatorStarted('tryCatch', '', context)\n\n const newContext = createContext(\n context,\n context.value,\n context.execution.path && context.execution.path.concat('try')\n )\n const nextWithPath = createNextPath(evaluateTry)\n\n const operatorToRun = paths.try[utils.IS_OPERATOR]\n ? paths.try\n : action(paths.try)\n // @ts-ignore\n operatorToRun(null, newContext, nextWithPath)\n }\n }\n instance[utils.IS_OPERATOR] = true\n\n return instance as any\n}\n\nexport function fork<T extends { [key: string]: any }, M extends keyof T, K>(\n key: M,\n paths: {\n [U in T[M]]: OperatorContextFunction<\n T extends { [key in M]: U } ? T : never,\n K\n >\n }\n): IOperator<T, K> {\n return createOperator('fork', String(key), (err, context, value, next) => {\n if (err) next(err, value)\n else {\n next(null, value, {\n path: {\n name: String(key),\n operator: (paths as any)[value[key]],\n },\n })\n }\n })\n}\n\nexport function when<T, K>(\n operation: OperatorContextFunction<T, boolean>,\n paths: {\n true: OperatorContextFunction<T, K>\n false: OperatorContextFunction<T, K>\n }\n): IOperator<T, K> {\n return createOperator(\n 'when',\n utils.getFunctionName(operation),\n (err, context, value, next) => {\n if (err) next(err, value)\n else if (operation(context, value))\n next(null, value, {\n path: {\n name: 'true',\n operator: paths.true,\n },\n })\n else\n next(null, value, {\n path: {\n name: 'false',\n operator: paths.false,\n },\n })\n }\n )\n}\n\nexport function wait<T>(ms: number): IOperator<T, T> {\n return createOperator('wait', String(ms), (err, context, value, next) => {\n if (err) next(err, value)\n else setTimeout(() => next(null, value), ms)\n })\n}\n\nexport function debounce<T>(ms: number): IOperator<T, T> {\n let timeout\n let previousFinal\n\n return createOperator(\n 'debounce',\n String(ms),\n (err, context, value, next, final) => {\n if (err) next(err, value)\n else {\n if (timeout) {\n clearTimeout(timeout)\n previousFinal(null, value)\n }\n previousFinal = final\n timeout = setTimeout(() => {\n timeout = null\n next(null, value)\n }, ms)\n }\n }\n )\n}\n\nexport function throttle<T>(ms: number): IOperator<T, T> {\n let timeout\n let previousFinal\n let currentNext\n\n return createOperator(\n 'throttle',\n String(ms),\n (err, context, value, next, final) => {\n if (err) next(err, value)\n else {\n if (timeout) {\n previousFinal(null, value)\n currentNext = next\n } else {\n timeout = setTimeout(() => {\n timeout = null\n currentNext(null, value)\n }, ms)\n }\n previousFinal = final\n currentNext = next\n }\n }\n )\n}\n\nexport function waitUntil<T, C extends IContext<{}>>(\n operation: (state: C['state']) => boolean\n): IOperator<T, T> {\n return createOperator(\n 'waitUntil',\n operation.name,\n (err, context, value, next) => {\n if (err) next(err, value)\n else {\n const tree = context.execution.getTrackStateTree()\n const test = () => {\n if (operation(tree.state)) {\n tree.dispose()\n next(null, value)\n }\n }\n tree.trackScope(test, test)\n }\n }\n )\n}\n"]}