invokeflow 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ <div align="center">
2
+
3
+ # Invoke Flow
4
+
5
+ ### Composed multi-step invocation utilities for application flows.
6
+
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-3178c6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![Module](https://img.shields.io/badge/module-ESM-f7df1e?logo=javascript&logoColor=111827)](package.json) [![Status](https://img.shields.io/badge/status-in%20development-f5a623)](https://ai.mosa.sh)
8
+
9
+ [ai.mosa.sh](https://ai.mosa.sh) · [mosa.sh](https://mosa.sh)
10
+
11
+ </div>
12
+
13
+ Invoke Flow composes dependency-free synchronous or asynchronous steps into a
14
+ single reusable invocation.
15
+
16
+ ```sh
17
+ npm i invokeflow
18
+ ```
19
+
20
+ ```ts
21
+ import { invokeFlow } from "invokeflow";
22
+
23
+ await invokeFlow(1, [(value) => value + 1, (value) => value * 2]); // 4
24
+ ```
@@ -0,0 +1,5 @@
1
+ export type InvocationStep<Value> = (value: Value) => Value | Promise<Value>;
2
+ /** Runs invocation steps in order, passing each result to the next step. */
3
+ export declare function invokeFlow<Value>(value: Value, steps: readonly InvocationStep<Value>[]): Promise<Value>;
4
+ /** Creates a reusable composed invocation flow. */
5
+ export declare function createInvokeFlow<Value>(steps: readonly InvocationStep<Value>[]): (value: Value) => Promise<Value>;
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /** Runs invocation steps in order, passing each result to the next step. */
2
+ export async function invokeFlow(value, steps) {
3
+ let result = value;
4
+ for (const step of steps)
5
+ result = await step(result);
6
+ return result;
7
+ }
8
+ /** Creates a reusable composed invocation flow. */
9
+ export function createInvokeFlow(steps) {
10
+ return (value) => invokeFlow(value, steps);
11
+ }
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "invokeflow",
3
+ "version": "0.0.1",
4
+ "description": "Composed multi-step invocation utilities for application flows.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": { ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" } },
9
+ "files": ["dist", "README.md"],
10
+ "sideEffects": false,
11
+ "scripts": { "build": "tsc --project tsconfig.json", "prepublishOnly": "npm run build" },
12
+ "keywords": ["invocation", "workflow", "async", "composition"],
13
+ "homepage": "https://ai.mosa.sh",
14
+ "author": "Mosanic <dev@mosanic.io>",
15
+ "license": "MIT",
16
+ "engines": { "node": ">=20" },
17
+ "publishConfig": { "access": "public" },
18
+ "devDependencies": { "typescript": "^5.9.3" }
19
+ }