Skip to content

Instantly share code, notes, and snippets.

@lcanady
Last active December 7, 2020 23:02
Show Gist options
  • Save lcanady/d4230fd4e156783d5a3d87bb0d9afa6c to your computer and use it in GitHub Desktop.
Save lcanady/d4230fd4e156783d5a3d87bb0d9afa6c to your computer and use it in GitHub Desktop.
interface Context {
[key: string]: any
}
const engine = pipeline<Context>((ctx, next) => {
ctx.foobar="baz";
next();
})
engine.use((ctx, next) => {
ctx.another = 123;
next();
});
(async () => {
const context: Context = {};
await engine.exec(context);
console.log(context);
})();
// => { foobar: "baz", another: 123 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment