silverwolf-x's picture
download
raw
928 Bytes
import { 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
}

Xet Storage Details

Size:
928 Bytes
·
Xet hash:
f0a2c9f76fe5a647c32305f5d4b7f0d9f780cd18e81d8f8eacce46629a9a1a7e

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.