@readable-js/core
Version:
ReadableJS is a toolkit for teachers to craft small demos that can be explored interactively.
53 lines (52 loc) • 1.5 kB
JavaScript
export const is = {
"VariableDeclaration": (node) => {
return node.type === "VariableDeclaration";
},
"IfStatement": (node) => {
return node.type === "IfStatement";
},
"WhileStatement": (node) => {
return node.type === "WhileStatement";
},
"ExpressionStatement": (node) => {
return node.type === "ExpressionStatement";
},
"BlockStatement": (node) => {
return node.type === "BlockStatement";
},
"ReturnStatement": (node) => {
return node.type === "ReturnStatement";
},
"CallExpression": (a) => {
return a.type === "CallExpression";
},
"Identifier": (a) => {
return a.type === "Identifier";
},
"Literal": (a) => {
return a.type === "Literal";
},
"MemberExpression": (a) => {
return a.type === "MemberExpression";
},
"Super": (a) => {
return a.type === "Super";
},
"ExpressionWithProperty": (a) => {
return a.type === "MemberExpression" || a.type === "MetaProperty";
},
"FunctionExpression": (a) => {
return a.type === "FunctionExpression";
},
"AssignmentExpression": (a) => {
return a.type === "AssignmentExpression";
},
"UpdateExpression": (a) => {
return a.type === "UpdateExpression";
},
};
export const isPattern = {
"Identifier": (pattern) => {
return pattern.type === 'Identifier';
}
};