feat(core): support 'read' option for ngIvy queries (#20855)

PR Close #20855
This commit is contained in:
Pawel Kozlowski
2017-12-18 15:14:09 +01:00
committed by Igor Minar
parent 5df343169e
commit 4f05d022c1
6 changed files with 263 additions and 24 deletions

View File

@ -14,6 +14,17 @@ export function assertNodeType(node: LNode, type: LNodeFlags) {
assertEqual(node.flags & LNodeFlags.TYPE_MASK, type, 'Node.type', typeSerializer);
}
export function assertNodeOfPossibleTypes(node: LNode, ...types: LNodeFlags[]) {
assertNotEqual(node, null, 'node');
const nodeType = (node.flags & LNodeFlags.TYPE_MASK);
for (let i = 0; i < types.length; i++) {
if (nodeType === types[i]) {
return;
}
}
throw new Error(
`Expected node of possible types: ${types.map(typeSerializer).join(', ')} but got ${typeSerializer(nodeType)}`);
}
function typeSerializer(type: LNodeFlags): string {
if (type == LNodeFlags.Projection) return 'Projection';