Last active
December 7, 2020 23:02
-
-
Save lcanady/d4230fd4e156783d5a3d87bb0d9afa6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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