本文整理汇总了TypeScript中angular2/src/core/change_detection/coalesce.coalesce函数的典型用法代码示例。如果您正苦于以下问题:TypeScript coalesce函数的具体用法?TypeScript coalesce怎么用?TypeScript coalesce使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了coalesce函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should optimize skips', () => {
var rs = coalesce([
// skipIfNot(1) + skip(N) -> skipIf(+N)
r("sknot", [], 0, 1, {mode: RecordType.SkipRecordsIfNot, fixedArgs: [2]}),
r("sk", [], 0, 2, {mode: RecordType.SkipRecords, fixedArgs: [3]}),
r("a", [], 0, 3),
// skipIf(1) + skip(N) -> skipIfNot(N)
r("skif", [], 0, 4, {mode: RecordType.SkipRecordsIf, fixedArgs: [5]}),
r("sk", [], 0, 5, {mode: RecordType.SkipRecords, fixedArgs: [6]}),
r("b", [], 0, 6),
// remove empty skips
r("sknot", [], 0, 7, {mode: RecordType.SkipRecordsIfNot, fixedArgs: [7]}),
r("skif", [], 0, 8, {mode: RecordType.SkipRecordsIf, fixedArgs: [8]}),
r("sk", [], 0, 9, {mode: RecordType.SkipRecords, fixedArgs: [9]}),
r("end", [], 0, 10),
]);
expect(rs).toEqual([
r("sknot", [], 0, 1, {mode: RecordType.SkipRecordsIf, fixedArgs: [2]}),
r("a", [], 0, 2),
r("skif", [], 0, 3, {mode: RecordType.SkipRecordsIfNot, fixedArgs: [4]}),
r("b", [], 0, 4),
r("end", [], 0, 5),
]);
});
示例2: it
it('should preserve the argumentToPureFunction property', () => {
var rs = coalesce([
r('user', [], 0, 1), r('user', [], 0, 2, {argumentToPureFunction: true}),
r('user', [], 0, 3), r('name', [], 3, 4)
]);
expect(rs).toEqual(
[r('user', [], 0, 1, {argumentToPureFunction: true}), r('name', [], 1, 2)]);
});
示例3: coalesce
() => {
var rs = coalesce([
r('user1', [], 0, 1), r('user2', [], 0, 2), r('hi', [1], 0, 3), r('hi', [1], 0, 4),
r('hi', [2], 0, 5)
]);
expect(rs).toEqual(
[r('user1', [], 0, 1), r('user2', [], 0, 2), r('hi', [1], 0, 3), r('hi', [2], 0, 4)]);
});
示例4: coalesce
() => {
var nullFunc = () => {};
var rs = coalesce([
r(nullFunc, [], 0, 1, {directiveIndex: new DirectiveIndex(0, 0)}),
r(nullFunc, [], 0, 1, {directiveIndex: new DirectiveIndex(0, 1)}),
r(nullFunc, [], 0, 1, {directiveIndex: new DirectiveIndex(1, 0)}),
r(nullFunc, [], 0, 1, {directiveIndex: null}),
]);
expect(rs.length).toEqual(4);
});