INNER CODE UNIT · TypeScript

Composer

grammyjs/grammY · src/composer.ts:188

export class Composer<C extends Context> implements MiddlewareObj<C> {
    private handler: MiddlewareFn<C>;

    /**
     * Constructs a new composer based on the provided middleware. If no
     * middleware is given, the composer instance will simply make all context
     * objects pass through without touching them.
     *
     * @param middleware The middleware to compose
     */
    constructor(...middleware: Array<Middleware<C>>) {
        this.handler = middleware.length === 0
            ? pass
            : middleware.map(flatten).reduce(concat);
    }

    middleware() {
        return this.handler;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…