/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
canary
packages/devlow-bench/src/interfaces/compose.ts
34 строки
933 B
Will Binns-Smith
Lint devlow-bench with the root eslint config (#96871)
07 авг 2026, 06:39
Не верифицирован
07 авг 2026, 06:39
007058e
Код
Авторство
О чём код?
import type { Interface } from '../index.js' export default function compose(...ifaces: Interface[]): Interface { const allKeys = new Set<keyof Interface>() for (const iface of ifaces) { for (const key of Object.keys(iface)) { allKeys.add(key as keyof Interface) } } const composed: any = {} for (const key of allKeys) { if (key.startsWith('filter')) { composed[key] = async (items: any, ...args: any[]) => { for (const iface of ifaces) { const anyIface = iface as any if (anyIface[key]) { items = await anyIface[key](items, ...args) } } return items } } else { composed[key] = async (...args: any[]) => { for (const iface of ifaces) { const anyIface = iface as any if (anyIface[key]) { await anyIface[key](...args) } } } } } return composed }