当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript array.forEach函数代码示例

本文整理汇总了TypeScript中dojo/_base/array.forEach函数的典型用法代码示例。如果您正苦于以下问题:TypeScript forEach函数的具体用法?TypeScript forEach怎么用?TypeScript forEach使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了forEach函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

        load: function (response) {
            if (lang.exists("WUActionResponse.ActionResults.WUActionResult", response)) {
                var wuMap = {};
                arrayUtil.forEach(workunits, function (item, index) {
                    wuMap[item.Wuid] = item;
                });
                arrayUtil.forEach(response.WUActionResponse.ActionResults.WUActionResult, function (item, index) {
                    if (item.Result.indexOf("Failed:") === 0) {
                        topic.publish("hpcc/brToaster", {
                            Severity: "Error",
                            Source: "WsWorkunits.WUAction",
                            Exceptions: [{ Source: item.Action + " " + item.Wuid, Message: item.Result }]
                        });
                    } else {
                        var wu = wuMap[item.Wuid];
                        if (actionType === "delete" && item.Result === "Success") {
                            wu.set("StateID", 999);
                            wu.set("State", "not found");
                        } else if (wu.refresh) {
                            wu.refresh();
                        }
                    }
                });
            }

            if (callback && callback.load) {
                callback.load(response);
            }
        },
开发者ID:GordonSmith,项目名称:HPCC-Platform,代码行数:29,代码来源:WsWorkunits.ts

示例2: function

        ]).then(lang.hitch(this, function (response) {
            var accountPermissions = {};
            arrayUtil.forEach(response[1], function (item, idx) {
                accountPermissions[item.PermissionName] = item;
            }, this);

            var data = [];
            arrayUtil.forEach(response[0], function (item, idx) {
                var accountPermission = accountPermissions[item.name];
                data.push(lang.mixin(item, {
                    __hpcc_type: "Resources",
                    __hpcc_id: this.parentRow.__hpcc_id + CONCAT_SYMBOL + item.name,
                    __hpcc_parent: this.parentRow,
                    DisplayName: item.description ? item.description : item.name,
                    AccountName: this.groupname,
                    allow_access: accountPermission ? accountPermission.allow_access : false,
                    allow_read: accountPermission ? accountPermission.allow_read : false,
                    allow_write: accountPermission ? accountPermission.allow_write : false,
                    allow_full: accountPermission ? accountPermission.allow_full : false,
                    deny_access: accountPermission ? accountPermission.deny_access : false,
                    deny_read: accountPermission ? accountPermission.deny_read : false,
                    deny_write: accountPermission ? accountPermission.deny_write : false,
                    deny_full: accountPermission ? accountPermission.deny_full : false
                }));
            }, this);
            options = options || {};
            this.setData(SimpleQueryEngine({}, { sort: options.sort })(data));
            return this.data;
        }));
开发者ID:GordonSmith,项目名称:HPCC-Platform,代码行数:29,代码来源:ws_access.ts

示例3: function

RowFormatter.prototype.formatRow = function (columns, row, rowIdx) {
    rowIdx = rowIdx || 0;
    row = row || {};
    var context = this;
    var maxChildLen = 0;
    var colLenBefore = {};
    arrayUtil.forEach(columns, function (column) {
        if (!column.children && context._formattedRow[column.field] !== undefined) {
            colLenBefore[column.field] = ("" + context._formattedRow[column.field]).split(LINE_SPLITTER).length;
        }
        var rowArr = row instanceof Array ? row : [row];
        for (var colIdx = 0; colIdx < rowArr.length; ++colIdx) {
            var r = rowArr[colIdx];
            maxChildLen = Math.max(maxChildLen, context.formatCell(column, column.isRawHTML ? r[column.leafID] : safeEncode(r[column.leafID]), rowIdx));
        }
    });
    arrayUtil.forEach(columns, function (column) {
        if (!column.children) {
            var cellLength = ("" + context._formattedRow[column.field]).split(LINE_SPLITTER).length - (colLenBefore[column.field] || 0);
            var delta = maxChildLen - cellLength;
            if (delta > 0) {
                var paddingArr = [];
                paddingArr.length = delta + 1;
                var padding = paddingArr.join(LINE_SPLITTER2);
                context._formattedRow[column.field] += padding;
            }
        }
    });
    return maxChildLen;
};
开发者ID:richardkchapman,项目名称:HPCC-Platform,代码行数:30,代码来源:ESPResult.ts

示例4: function

    calcSubgraphVisibility: function (subgraph, localisationDepth) {
        if (localisationDepth < 0) {
            return;
        }

        if (localisationDepth > 0) {
            arrayUtil.forEach(subgraph.__hpcc_subgraphs, function (subgraph, idx) {
                this.calcSubgraphVisibility(subgraph, localisationDepth - 1);
            }, this);
        }

        arrayUtil.forEach(subgraph.__hpcc_subgraphs, function (subgraph, idx) {
            this.m_visibleSubgraphs[subgraph.__hpcc_id] = subgraph;
        }, this);
        arrayUtil.forEach(subgraph.__hpcc_vertices, function (vertex, idx) {
            this.m_visibleVertices[vertex.__hpcc_id] = vertex;
        }, this);

        //  Calculate edges that pass through the subgraph  ---
        var dedupEdges = {};
        arrayUtil.forEach(this.graph.edges, function (edge, idx) {
            if (edge.getSource().__hpcc_parent !== edge.getTarget().__hpcc_parent && subgraph === this.getCommonAncestor(edge)) {
                //  Only include one unique edge between subgraphs  ---
                if (!dedupEdges[edge.getSource().__hpcc_parent.__hpcc_id + "::" + edge.getTarget().__hpcc_parent.__hpcc_id]) {
                    dedupEdges[edge.getSource().__hpcc_parent.__hpcc_id + "::" + edge.getTarget().__hpcc_parent.__hpcc_id] = true;
                    this.m_visibleEdges[edge.__hpcc_id] = edge;
                }
            }
        }, this);
    },
开发者ID:AttilaVamos,项目名称:HPCC-Platform,代码行数:30,代码来源:ESPGraph.ts

示例5: function

 arrayUtil.forEach(treeNode.__hpcc_treeItem.__hpcc_children, function (child) {
     var serviceNode = this.createTreeNode(treeNode, child);
     var machines = [];
     var bindings = [];
     arrayUtil.forEach(child.__hpcc_children, function (gchild) {
         if (gchild instanceof TpMachine) {
             machines.push(gchild);
         } else if (gchild instanceof TpBinding) {
             bindings.push(gchild);
         }
     }, this);
     arrayUtil.forEach(bindings, function (binding) {
         var bindingNode = this.createTreeNode(serviceNode, binding);
         arrayUtil.forEach(machines, function (machine) {
             this.createTreeNode(bindingNode, machine);
         }, this);
     }, this);
     arrayUtil.forEach(machines, function (machine) {
         var machineNode = this.createTreeNode(serviceNode, machine);
         arrayUtil.forEach(bindings, function (binding) {
             this.createTreeNode(machineNode, binding);
         }, this);
     }, this);
     data.push(serviceNode);
 }, this);
开发者ID:AttilaVamos,项目名称:HPCC-Platform,代码行数:25,代码来源:ESPTopology.ts

示例6: downloadToCSV

export function downloadToCSV(grid, rows, fileName) {
    var csvContent = "";
    var headers = grid.columns;
    var container = [];
    var headerNames = [];

    for (var key in headers) {
        if (headers[key].selectorType !== 'checkbox') {
            if (!headers[key].label) {
                var str = csvEncode(headers[key].field);
                headerNames.push(str);
            } else {
                var str = csvEncode(headers[key].label);
                headerNames.push(str);
            }
        }
    }
    container.push(headerNames);

    arrayUtil.forEach(rows, function (cells, idx) {
        container.push(cells);
    });

    arrayUtil.forEach(container, function (header, idx) {
        var dataString = header.join(",");
        csvContent += dataString + "\n";
    });

    var download = function (content, fileName, mimeType) {
        var a = document.createElement('a');
        mimeType = mimeType || 'application/octet-stream';

        if (navigator.msSaveBlob) { // IE10
            return navigator.msSaveBlob(new Blob([content], { type: mimeType }), fileName);
        } else if ('download' in a) {
            a.href = 'data:' + mimeType + ',' + encodeURIComponent(content);
            a.setAttribute('download', fileName);
            document.body.appendChild(a);
            setTimeout(function () {
                a.click();
                document.body.removeChild(a);
            }, 66);
            return true;
        } else {
            var f = document.createElement('iframe');
            document.body.appendChild(f);
            f.src = 'data:' + mimeType + ',' + encodeURIComponent(content);

            setTimeout(function () {
                document.body.removeChild(f);
            }, 333);
            return true;
        }
    }
    download(csvContent, fileName, 'text/csv');
}
开发者ID:GordonSmith,项目名称:HPCC-Platform,代码行数:56,代码来源:Utility.ts

示例7: function

 load: function (response) {
     arrayUtil.forEach(workunits, function (item, index) {
         item.refresh();
     });
     /*  TODO:  Revisit after HPCC-9241 is fixed
     if (lang.exists("DFUWorkunitsActionResponse.ActionResults.WUActionResult", response)) {
         arrayUtil.forEach(response.WUActionResponse.ActionResults.WUActionResult, function (item, index) {
             if (item.Result.indexOf("Failed:") === 0) {
                 dojo.publish("hpcc/brToaster", {
                     message: "<h4>" + item.Action + " " + item.Wuid + "</h4>" + "<p>" + item.Result + "</p>",
                     type: "error",
                     duration: -1
                 });
             } else {
                 dojo.publish("hpcc/brToaster", {
                     message: "<h4>" + item.Action + " " + item.Wuid + "</h4>" + "<p>" + item.Result + "</p>",
                     type: "message"
                 });
             }
         });
     }
     */
     if (callback && callback.load) {
         callback.load(response);
     }
 },
开发者ID:richardkchapman,项目名称:HPCC-Platform,代码行数:26,代码来源:FileSpray.ts


注:本文中的dojo/_base/array.forEach函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。