本文整理汇总了TypeScript中@ephox/katamari.Arr类的典型用法代码示例。如果您正苦于以下问题:TypeScript Arr类的具体用法?TypeScript Arr怎么用?TypeScript Arr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Arr类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
return Chain.mapper(function (parents: Element[]) {
const names = Arr.map(parents, Node.name);
Assertions.assertEq('Should be expected names', expectedNames, names);
return {};
});
示例2: normalizeDeep
const normalizeEntries = (entries: Entry[]): void => {
Arr.foldl(entries, (outline: Array<Option<Entry>>, entry) => {
return entry.depth > outline.length ? normalizeDeep(outline, entry) : normalizeShallow(outline, entry);
}, []);
};
示例3: function
//.........这里部分代码省略.........
};
};
const callback = function () {
eventUtils.unbind(window, 'click', callback);
data += 'b';
};
data = '';
eventUtils.bind(window, 'click', append('a'));
eventUtils.bind(window, 'click', callback);
eventUtils.bind(window, 'click', append('c'));
eventUtils.fire(window, 'click', {});
LegacyUnit.equal(data, 'abc');
data = '';
eventUtils.fire(window, 'click', {});
LegacyUnit.equal(data, 'ac');
});
suite.test('ready/DOMContentLoaded (domLoaded = true)', function () {
let evt;
eventUtils.bind(window, 'ready', function (e) {
evt = e;
});
LegacyUnit.equal(evt.type, 'ready');
});
suite.test('ready/DOMContentLoaded (document.readyState check)', function () {
let evt;
try {
document.readyState = 'loading';
} catch (e) {
LegacyUnit.equal(true, true, 'IE doesn\'t allow us to set document.readyState');
return;
}
eventUtils.domLoaded = false;
document.readyState = 'loading';
eventUtils.bind(window, 'ready', function (e) {
evt = e;
});
LegacyUnit.equal(true, typeof (evt) !== 'undefined');
eventUtils.domLoaded = false;
document.readyState = 'complete';
eventUtils.bind(window, 'ready', function (e) {
evt = e;
});
LegacyUnit.equal(evt.type, 'ready');
});
suite.test('isDefaultPrevented', function () {
const testObj: any = {};
const testCallback = function () {
return 'hello';
};
testObj.isDefaultPrevented = testCallback;
eventUtils.fire(window, 'testEvent', testObj);
LegacyUnit.equal(testObj.isDefaultPrevented !== testCallback, true, 'Is overwritten by our isDefaultPrevented');
LegacyUnit.equal(typeof testObj.isPropagationStopped, 'function', 'Has our isPropagationStopped');
LegacyUnit.equal(typeof testObj.isImmediatePropagationStopped, 'function', 'Has our isImmediatePropagationStopped');
});
const sAddTestDiv = Step.sync(function () {
const testDiv = document.createElement('div');
testDiv.id = 'testDiv';
testDiv.innerHTML = (
'<div id="content" tabindex="0">' +
'<div id="inner" tabindex="0"></div>' +
'</div>'
);
document.body.appendChild(testDiv);
});
const sRemoveTestDiv = Step.sync(function () {
const testDiv = document.querySelector('#testDiv');
testDiv.parentNode.removeChild(testDiv);
});
let steps = Arr.bind(suite.toSteps({}), function (step) {
return [
step,
Step.sync(function () {
eventUtils.clean(window);
})
];
});
steps = [sAddTestDiv].concat(steps).concat(sRemoveTestDiv);
Pipeline.async({}, steps, function () {
success();
}, failure);
});
示例4:
parser.addNodeFilter('p', (nodes) => {
Arr.each(nodes, (node) => {
node.attr('class', 'x');
});
});
示例5: function
const update = function () {
clear();
const rectangles = Rectangles.getRectangles(win);
const spans = Arr.map(rectangles, make);
InsertAll.append(container, spans);
};
示例6: function
Arr.each(SelectorFilter.descendants(tableElm, 'tr'), function (tr, y) {
Arr.each(SelectorFilter.descendants(tr, 'td,th'), function (td, x) {
fillout(table, skipCellsX(table, x, y), y, tr, td);
});
});
示例7: function
const join = function (items) {
return Arr.foldl(items, function (a, b) {
const bothEmpty = a.length === 0 || b.length === 0;
return bothEmpty ? a.concat(b) : a.concat(separator, b);
}, []);
};
示例8: function
const getParentCell = function (rootElm, elm) {
return Arr.find(Parents.parentsAndSelf(elm, rootElm), ElementType.isTableCell);
};
示例9: function
const isRoot = function (element) {
const name = Node.name(element);
return Compare.eq(element, body) || Arr.contains(rootElements, name);
};