TypeScript tsfun includedIn示例

说明

typescript tsfun includedin示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: TypeScript

命名空间/包名称: tsfun

示例#1
文件: pre-preprocess-configuration-validator.ts 项目: dainst/idai-components-2

    private static checkForForbiddenTopLevelFields(appConfiguration: any): Array<Array<string>> {

        const allowedFields = ['identifier', 'types'];

        const result = Object.keys(appConfiguration).find(isNot(includedIn(allowedFields)));

        return result
            ? [['relations cannot be defined via external configuration']]
            : [];
    }

示例#2
文件: relations.ts 项目: dainst/idai-components-2

    export function getAllTargets(relations: Relations, allowedRelations?: string[]): Array<string> {

        const ownKeys = Object.keys(relations)
            .filter(prop => relations.hasOwnProperty(prop));

        const usableRelations = allowedRelations
            ? ownKeys.filter(includedIn(allowedRelations))
            : ownKeys;

        return flatMap((prop: string) => relations[prop as string])(usableRelations);
    }

展开阅读全文