本文整理汇总了TypeScript中wherehows-web/utils/array.arrayMap函数的典型用法代码示例。如果您正苦于以下问题:TypeScript arrayMap函数的具体用法?TypeScript arrayMap怎么用?TypeScript arrayMap使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了arrayMap函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: formatAsCapitalizedStringWithSpaces
const getAccessControlTypeOptions = (
accessTypes: Array<AccessControlAccessType>
): Array<IAccessControlAccessTypeOption> => {
const getTypeOption = (value: AccessControlAccessType): IAccessControlAccessTypeOption => ({
value,
label: formatAsCapitalizedStringWithSpaces(value)
});
return arrayMap(getTypeOption)(accessTypes);
};
示例2: arrayMap
const keysMatchNames = (object: IObject<any>, typeMaps: Array<IMetadataType>): true => {
const objectKeys = Object.keys(object).sort();
const typeKeys = arrayMap((typeMap: IMetadataType) => typeMap['@name'])(typeMaps).sort();
const objectKeysSerialized = objectKeys.toString();
const typeKeysSerialized = typeKeys.toString();
const match = objectKeysSerialized === typeKeysSerialized;
if (!match) {
throw new Error(
`Expected attributes ${typeKeys.join(', ')} on object. Found additional attributes ${difference(
objectKeys,
typeKeys
).join(', ')}`
);
}
return match;
};
示例3: arrayMap
* @return {Pick<IDatasetColumn, "dataType" | "fieldName">}
*/
const columnDataTypeAndFieldName = ({
dataType,
fullFieldPath
}: IDatasetColumn | IDatasetColumnWithHtmlComments): Pick<IDatasetColumn, 'dataType' | 'fieldName'> => ({
dataType,
fieldName: fullFieldPath
});
/**
* Takes a list of objects with comments and returns an array of objects with comments or html comments
* @type {(array: Array<T extends { comment: string } & Object>) => Array<T | T extends { commentHtml: string }>}
*/
const augmentObjectsWithHtmlComments = arrayMap<IDatasetColumn, IDatasetColumnWithHtmlComments | IDatasetColumn>(
augmentWithHtmlComment
);
/**
* Takes a list of IDatasetColumn / IDatasetColumn with html comments and pulls the dataType and and fullFieldPath (as fieldName) attributes
* @type {(array: Array<IDatasetColumn | IDatasetColumnWithHtmlComments>) => Array<Pick<IDatasetColumn, "dataType" | "fieldName">>}
*/
const columnDataTypesAndFieldNames = arrayMap(columnDataTypeAndFieldName);
/**
* Gets the dataset columns for a dataset with the id specified and the schemaless flag
* @param {number} id the id of the dataset
* @return {(Promise<{schemaless: boolean; columns: Array<IDatasetColumn>}>)}
*/
const readDatasetColumns = async (id: number): Promise<{ schemaless: boolean; columns: Array<IDatasetColumn> }> => {
const { status, columns = [], schemaless, message = datasetColumnsException } = await getJSON<
示例4: arrayMap
const datasetsWithComplianceMetadata = (
datasets: Array<IDatasetView>
): Array<Promise<IUpstreamWithComplianceMetadata>> => arrayMap(datasetWithComplianceMetadata)(datasets);