本文整理匯總了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);