16
import * as webidl2 from "webidl2"
17
import { ExtendedAttribute } from "webidl2";
19
export function isEnum(node: webidl2.IDLRootType): node is webidl2.EnumType {
20
return node.type === "enum"
23
export function isInterface(node: webidl2.IDLRootType): node is webidl2.InterfaceType {
24
return node.type === "interface"
27
export function isClass(node: webidl2.IDLRootType): node is webidl2.InterfaceType {
28
return isInterface(node)
30
.map((it: ExtendedAttribute) => it.name)
31
.map((it) => it.toLowerCase())
35
export function isCallback(node: webidl2.IDLRootType): node is webidl2.CallbackType {
36
return node.type === "callback"
39
export function isTypedef(node: webidl2.IDLRootType): node is webidl2.TypedefType {
40
return node.type === "typedef"
43
export function isDictionary(node: webidl2.IDLRootType): node is webidl2.DictionaryType {
44
return node.type === "dictionary"
47
export function isAttribute(node: webidl2.IDLInterfaceMemberType): node is webidl2.AttributeMemberType {
48
return node.type === "attribute"
51
export function isOperation(node: webidl2.IDLInterfaceMemberType): node is webidl2.OperationMemberType {
52
return node.type === "operation"
55
export function isConstructor(node: webidl2.IDLInterfaceMemberType): node is webidl2.ConstructorMemberType {
56
return node.type === "constructor"
59
export function isUnionTypeDescription(node: webidl2.IDLTypeDescription): node is webidl2.UnionTypeDescription {
63
export function isSingleTypeDescription(node: webidl2.IDLTypeDescription): node is webidl2.SingleTypeDescription {
64
return (typeof node.idlType === "string")
67
export function isSequenceTypeDescription(node: webidl2.IDLTypeDescription): node is webidl2.SequenceTypeDescription {
68
return node.generic === "sequence"
71
export function isPromiseTypeDescription(node: webidl2.IDLTypeDescription): node is webidl2.PromiseTypeDescription {
72
return node.generic === "Promise"
75
export function isRecordTypeDescription(node: webidl2.IDLTypeDescription): node is webidl2.RecordTypeDescription {
76
return node.generic === "record"
79
export function isOptional(node: webidl2.AttributeMemberType): boolean {
81
.map((it: ExtendedAttribute) => it.name)
82
.map((it) => it.toLowerCase())