本文整理汇总了TypeScript中eez-studio-shared/algorithm._map函数的典型用法代码示例。如果您正苦于以下问题:TypeScript _map函数的具体用法?TypeScript _map怎么用?TypeScript _map使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_map函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: dumpData
export function dumpData(data: number[] | Buffer) {
let result = "";
_map(data, value => "0x" + formatNumber(value, 16, 2)).forEach((value, index) => {
if (result.length > 0) {
result += ",";
}
if (index % 16 == 0) {
result += "\n" + TAB;
} else {
result += " ";
}
result += value;
});
result += "\n";
return result;
}
示例2: _map
return _map(sdl.find("GlobalDefinitions>Enum"), (element: HTMLElement, index: number) => {
const name = $(element).attr("name") || "";
const members: IEnumMember[] = _map(
$(element).find("Member"),
(element: HTMLElement, index: number) => {
const name = $(element).attr("mnemonic") || "";
const value = $(element).attr("value") || "";
return {
name,
value
};
}
);
return {
name,
members
};
});
示例3: buildParameters
function buildParameters(dom: JQuery): IParameter[] {
return _map(dom.find("Parameters>Parameter"), (element: HTMLElement, index: number) => {
const name = element.getAttribute("name") || index.toString();
let isOptional;
try {
isOptional = !!JSON.parse(element.getAttribute("optional") || "false");
} catch (err) {
console.error(err);
isOptional = false;
}
let type: IParameterType[] = [];
if ($(element).find("Any").length) {
type.push({
type: "any"
});
} else {
if ($(element).find("NonDecimalNumeric").length) {
type.push({
type: "nr1"
});
} else if ($(element).find("DecimalNumeric").length) {
type.push({
type: "nr2"
});
}
if ($(element).find("String").length) {
type.push({
type: "quoted-string"
});
}
if ($(element).find("DataBlock").length) {
type.push({
type: "data-block"
});
}
if ($(element).find("Character>EnumRef").length) {
type.push({
type: "discrete",
enumeration: $(element)
.find("Character>EnumRef")
.attr("name")
});
}
if ($(element).find("Expression>ChannelList").length) {
type.push({
type: "channel-list"
});
}
if ($(element).find("ArbitraryBlock").length) {
type.push({
type: "data-block"
});
}
}
const description = element.getAttribute("description") || "";
return {
name,
type,
isOptional,
description
};
});
}