MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / resolve

Method resolve

tools/common/_hyperscript.iife.js:4430–4471  ·  view source on GitHub ↗
(context, { lhs: lhsVal, rhs: rhsVal, rhs2: rhs2Val })

Source from the content-addressed store, hash-verified

4428 return expr;
4429 }
4430 resolve(context, { lhs: lhsVal, rhs: rhsVal, rhs2: rhs2Val }) {
4431 const operator = this.operator;
4432 const lhs = this.lhs;
4433 const rhs = this.rhs;
4434 const typeName = this.typeName;
4435 const nullOk = this.nullOk;
4436 if (this.ignoringCase) {
4437 if (typeof lhsVal === "string") lhsVal = lhsVal.toLowerCase();
4438 if (typeof rhsVal === "string") rhsVal = rhsVal.toLowerCase();
4439 }
4440 if (operator === "==") return lhsVal == rhsVal;
4441 if (operator === "!=") return lhsVal != rhsVal;
4442 if (operator === "===") return lhsVal === rhsVal;
4443 if (operator === "!==") return lhsVal !== rhsVal;
4444 if (operator === "<") return lhsVal < rhsVal;
4445 if (operator === ">") return lhsVal > rhsVal;
4446 if (operator === "<=") return lhsVal <= rhsVal;
4447 if (operator === ">=") return lhsVal >= rhsVal;
4448 if (operator === "match") return lhsVal != null && this.sloppyMatches(lhs, lhsVal, rhsVal);
4449 if (operator === "not match") return lhsVal == null || !this.sloppyMatches(lhs, lhsVal, rhsVal);
4450 if (operator === "in") return rhsVal != null && this.sloppyContains(rhs, rhsVal, lhsVal);
4451 if (operator === "not in") return rhsVal == null || !this.sloppyContains(rhs, rhsVal, lhsVal);
4452 if (operator === "contain" || operator === "include") return lhsVal != null && this.sloppyContains(lhs, lhsVal, rhsVal);
4453 if (operator === "not contain" || operator === "not include") return lhsVal == null || !this.sloppyContains(lhs, lhsVal, rhsVal);
4454 if (operator === "start with") return lhsVal != null && String(lhsVal).startsWith(rhsVal);
4455 if (operator === "not start with") return lhsVal == null || !String(lhsVal).startsWith(rhsVal);
4456 if (operator === "end with") return lhsVal != null && String(lhsVal).endsWith(rhsVal);
4457 if (operator === "not end with") return lhsVal == null || !String(lhsVal).endsWith(rhsVal);
4458 if (operator === "between") return lhsVal >= rhsVal && lhsVal <= rhs2Val;
4459 if (operator === "not between") return lhsVal < rhsVal || lhsVal > rhs2Val;
4460 if (operator === "precede") return lhsVal != null && rhsVal != null && (lhsVal.compareDocumentPosition(rhsVal) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0;
4461 if (operator === "not precede") return lhsVal == null || rhsVal == null || (lhsVal.compareDocumentPosition(rhsVal) & Node.DOCUMENT_POSITION_FOLLOWING) === 0;
4462 if (operator === "follow") return lhsVal != null && rhsVal != null && (lhsVal.compareDocumentPosition(rhsVal) & Node.DOCUMENT_POSITION_PRECEDING) !== 0;
4463 if (operator === "not follow") return lhsVal == null || rhsVal == null || (lhsVal.compareDocumentPosition(rhsVal) & Node.DOCUMENT_POSITION_PRECEDING) === 0;
4464 if (operator === "empty") return context.meta.runtime.isEmpty(lhsVal);
4465 if (operator === "not empty") return !context.meta.runtime.isEmpty(lhsVal);
4466 if (operator === "exist") return context.meta.runtime.doesExist(lhsVal);
4467 if (operator === "not exist") return !context.meta.runtime.doesExist(lhsVal);
4468 if (operator === "a") return context.meta.runtime.typeCheck(lhsVal, typeName.value, nullOk);
4469 if (operator === "not a") return !context.meta.runtime.typeCheck(lhsVal, typeName.value, nullOk);
4470 throw new Error("Unknown comparison : " + operator);
4471 }
4472 };
4473 var LogicalOperator = class _LogicalOperator extends Expression {
4474 static grammarName = "logicalOperator";

Callers

nothing calls this directly

Calls 5

sloppyMatchesMethod · 0.95
sloppyContainsMethod · 0.95
isEmptyMethod · 0.45
doesExistMethod · 0.45
typeCheckMethod · 0.45

Tested by

no test coverage detected