UNPKG

first-npm-package-nicule

Version:

This isi first npm package

23 lines (20 loc) 812 B
import { makePropDecorator } from '../../google-decorator-factories'; import { BindDecorator } from '../bind.decorator'; export interface BindLinksDecorator { (...relQueries: Array<Array<string>>): any; new(...relQueries: Array<Array<string>>): any; } export const Links: BindLinksDecorator = makePropDecorator('BindLinks', (...relQueries: Array<Array<string>>) => { return ({ binding: { priority: 1, bind: (({ links = [] }) => { return links.filter(({ rel: existingRels = [] }) => { return relQueries.some(relQuery => { return relQuery.every(rel => existingRels.includes(rel)); }); }); }) } as BindDecorator }) as any; });