ember-legacy-class-transform
Version:
The default blueprint for ember-cli addons.
63 lines • 2.6 kB
JavaScript
import { Opcodes } from './lib/opcodes';
export { Opcodes as Ops } from './lib/opcodes';
export function is(variant) {
return function (value) {
return Array.isArray(value) && value[0] === variant;
};
}
export var Expressions;
(function (Expressions) {
Expressions.isUnknown = is(Opcodes.Unknown);
Expressions.isGet = is(Opcodes.Get);
Expressions.isConcat = is(Opcodes.Concat);
Expressions.isHelper = is(Opcodes.Helper);
Expressions.isHasBlock = is(Opcodes.HasBlock);
Expressions.isHasBlockParams = is(Opcodes.HasBlockParams);
Expressions.isUndefined = is(Opcodes.Undefined);
Expressions.isClientSide = is(Opcodes.ClientSideExpression);
Expressions.isMaybeLocal = is(Opcodes.MaybeLocal);
function isPrimitiveValue(value) {
if (value === null) {
return true;
}
return typeof value !== 'object';
}
Expressions.isPrimitiveValue = isPrimitiveValue;
})(Expressions || (Expressions = {}));
export var Statements;
(function (Statements) {
Statements.isText = is(Opcodes.Text);
Statements.isAppend = is(Opcodes.Append);
Statements.isComment = is(Opcodes.Comment);
Statements.isModifier = is(Opcodes.Modifier);
Statements.isBlock = is(Opcodes.Block);
Statements.isComponent = is(Opcodes.Component);
Statements.isOpenElement = is(Opcodes.OpenElement);
Statements.isFlushElement = is(Opcodes.FlushElement);
Statements.isCloseElement = is(Opcodes.CloseElement);
Statements.isStaticAttr = is(Opcodes.StaticAttr);
Statements.isDynamicAttr = is(Opcodes.DynamicAttr);
Statements.isYield = is(Opcodes.Yield);
Statements.isPartial = is(Opcodes.Partial);
Statements.isDynamicArg = is(Opcodes.DynamicArg);
Statements.isStaticArg = is(Opcodes.StaticArg);
Statements.isTrustingAttr = is(Opcodes.TrustingAttr);
Statements.isDebugger = is(Opcodes.Debugger);
Statements.isClientSide = is(Opcodes.ClientSideStatement);
function isAttribute(val) {
return val[0] === Opcodes.StaticAttr || val[0] === Opcodes.DynamicAttr || val[0] === Opcodes.TrustingAttr;
}
Statements.isAttribute = isAttribute;
function isArgument(val) {
return val[0] === Opcodes.StaticArg || val[0] === Opcodes.DynamicArg;
}
Statements.isArgument = isArgument;
function isParameter(val) {
return isAttribute(val) || isArgument(val);
}
Statements.isParameter = isParameter;
function getParameterName(s) {
return s[1];
}
Statements.getParameterName = getParameterName;
})(Statements || (Statements = {}));