本文整理汇总了TypeScript中@ephox/katamari.Arr.findIndex方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Arr.findIndex方法的具体用法?TypeScript Arr.findIndex怎么用?TypeScript Arr.findIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/katamari.Arr
的用法示例。
在下文中一共展示了Arr.findIndex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
Step.sync(function () {
const headStuff = editor.getDoc().head.querySelectorAll('link, style');
const linkIndex = Arr.findIndex(headStuff, function (elm) {
return Node.name(Element.fromDom(elm)) === 'link';
}).getOrDie('could not find link elemnt');
const styleIndex = Arr.findIndex(headStuff, function (elm) {
return elm.innerText === contentStyle;
}).getOrDie('could not find content style tag');
Assertions.assertEq('style tag should be after link tag', linkIndex < styleIndex, true);
})
示例2:
const getChildrenUntilBlockBoundary = (block: Element) => {
const children = Traverse.children(block);
return Arr.findIndex(children, ElementType.isBlock).fold(
() => children,
(index) => children.slice(0, index)
);
};
示例3: function
const getParentInlines = function (rootElm, startElm) {
const parents = Parents.parentsAndSelf(startElm, rootElm);
return Arr.findIndex(parents, ElementType.isBlock).fold(
Fun.constant(parents),
function (index) {
return parents.slice(0, index);
}
);
};
示例4: function
const closeNotification = function (notification) {
Arr.findIndex(notifications, function (otherNotification) {
return otherNotification === notification;
}).each(function (index) {
// Mutate here since third party might have stored away the window array
// TODO: Consider breaking this api
notifications.splice(index, 1);
});
};
示例5: function
const getChildrenUntilBlockBoundary = function (block) {
const children = Traverse.children(block);
return Arr.findIndex(children, ElementType.isBlock).fold(
function () {
return children;
},
function (index) {
return children.slice(0, index);
}
);
};
示例6: function
const closeWindow = function (win) {
Arr.findIndex(windows, function (otherWindow) {
return otherWindow === win;
}).each(function (index) {
// Mutate here since third party might have stored away the window array, consider breaking this api
windows.splice(index, 1);
fireCloseEvent(win);
// Move focus back to editor when the last window is closed
if (windows.length === 0) {
editor.focus();
}
});
};
示例7:
const detectSize = (comp: AlloyComponent, margin: number, selectorClass: string): Option<{ numColumns: number, numRows: number}> => {
const descendants = SelectorFilter.descendants(comp.element(), '.' + selectorClass);
// TODO: This seems to cause performance issues in the emoji dialog
if (descendants.length > 0) {
const columnLength = Arr.findIndex(descendants, (c) => {
const thisTop = c.dom().getBoundingClientRect().top;
const cTop = descendants[0].dom().getBoundingClientRect().top;
return Math.abs(thisTop - cTop) > margin;
}).getOr(descendants.length);
return Option.some({
numColumns: columnLength,
numRows: Math.ceil(descendants.length / columnLength)
});
} else {
return Option.none();
}
};
示例8:
const getCellIndex = (cells, cell) => {
return Arr.findIndex(cells, (x) => Compare.eq(x, cell));
};
示例9: function
const sizeToIndex = function (size) {
return Arr.findIndex(candidates, function (v) {
return v === size;
});
};
示例10: function
const hasItemName = function (namedMenuItems, name) {
return Arr.findIndex(namedMenuItems, function (namedMenuItem) {
return namedMenuItem.name === name;
}).isSome();
};