Update linting
This commit is contained in:
1 parent
4f2dfb4f48
commit
0c9c027a77
112 files changed
+3781
-4125
No files matched your search
@@ -78,7 +78,7 @@ export default class Authorizer {
|
||||
|
||||
public getValidator(
|
||||
resourceType: string,
|
||||
resource: unknown
|
||||
resource: unknown,
|
||||
): (mutationType: string, mutation?: any, args?: any) => boolean {
|
||||
if (this.validatorCache.has(resource))
|
||||
return this.validatorCache.get(resource);
|
||||
@@ -99,7 +99,7 @@ export default class Authorizer {
|
||||
const validator = (
|
||||
mutationType: string,
|
||||
mutation: any,
|
||||
any: any
|
||||
any: any,
|
||||
): boolean => {
|
||||
if (!validators.length) return false;
|
||||
|
||||
@@ -134,7 +134,7 @@ export default class Authorizer {
|
||||
const res = evaluate(
|
||||
validators.length > 1 ? ["OR", validators] : validators[0],
|
||||
valueFunction,
|
||||
Date.now()
|
||||
Date.now(),
|
||||
);
|
||||
return !Array.isArray(res) && !!res;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export default function debounce<T>(
|
||||
func: (args: T[]) => void,
|
||||
timeout: number
|
||||
timeout: number,
|
||||
): (arg: T) => void {
|
||||
let timer: ReturnType<typeof setTimeout>;
|
||||
let args: T[] = [];
|
||||
|
||||
@@ -32,7 +32,7 @@ class Indeterminates {
|
||||
|
||||
public static multiply(
|
||||
indeterminates1: Indeterminates,
|
||||
indeterminates2: Indeterminates
|
||||
indeterminates2: Indeterminates,
|
||||
): Indeterminates {
|
||||
const res = new Indeterminates();
|
||||
res.sortedKeys = indeterminates1.sortedKeys.slice();
|
||||
@@ -108,7 +108,7 @@ class Polynomial {
|
||||
const ts = terms
|
||||
.slice()
|
||||
.sort((a: Term, b: Term) =>
|
||||
Indeterminates.compare(a.indeterminates, b.indeterminates)
|
||||
Indeterminates.compare(a.indeterminates, b.indeterminates),
|
||||
);
|
||||
|
||||
for (let i = 1; i < ts.length; ++i) {
|
||||
@@ -117,12 +117,12 @@ class Polynomial {
|
||||
if (Indeterminates.compare(t1.indeterminates, t2.indeterminates) === 0) {
|
||||
const numerator = BI.add(
|
||||
BI.mul(t1.coefficientNumerator, t2.coefficientDenominator),
|
||||
BI.mul(t2.coefficientNumerator, t1.coefficientDenominator)
|
||||
BI.mul(t2.coefficientNumerator, t1.coefficientDenominator),
|
||||
);
|
||||
|
||||
const denominator = BI.mul(
|
||||
t1.coefficientDenominator,
|
||||
t2.coefficientDenominator
|
||||
t2.coefficientDenominator,
|
||||
);
|
||||
|
||||
const gcd = findGcd(numerator, denominator);
|
||||
@@ -163,7 +163,7 @@ class Polynomial {
|
||||
denominator = BI.exp(TWO, BI.BigInt(frac.length));
|
||||
numerator = BI.add(
|
||||
BI.mul(numerator, denominator),
|
||||
BI.BigInt("0b" + frac)
|
||||
BI.BigInt("0b" + frac),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ class Polynomial {
|
||||
|
||||
public add(rhs: Polynomial): Polynomial {
|
||||
return new Polynomial(
|
||||
Polynomial.simplifyTerms(this.terms.concat(rhs.terms))
|
||||
Polynomial.simplifyTerms(this.terms.concat(rhs.terms)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -219,18 +219,18 @@ class Polynomial {
|
||||
for (const t2 of rhs.terms) {
|
||||
const numerator = BI.mul(
|
||||
t1.coefficientNumerator,
|
||||
t2.coefficientNumerator
|
||||
t2.coefficientNumerator,
|
||||
);
|
||||
const denominator = BI.mul(
|
||||
t1.coefficientDenominator,
|
||||
t2.coefficientDenominator
|
||||
t2.coefficientDenominator,
|
||||
);
|
||||
const gcd = findGcd(numerator, denominator);
|
||||
|
||||
terms.push({
|
||||
indeterminates: Indeterminates.multiply(
|
||||
t1.indeterminates,
|
||||
t2.indeterminates
|
||||
t2.indeterminates,
|
||||
),
|
||||
coefficientNumerator: BI.div(numerator, gcd),
|
||||
coefficientDenominator: BI.div(denominator, gcd),
|
||||
@@ -339,7 +339,7 @@ function normalizeCallback(exp: Expression): Expression {
|
||||
const e = (r[1] as Expression[]).slice();
|
||||
e[i] = t;
|
||||
return [and(w, r[0]), e] as [Expression, Expression];
|
||||
})
|
||||
}),
|
||||
);
|
||||
if (!Array.isArray(w) && w) break;
|
||||
}
|
||||
@@ -373,7 +373,7 @@ function normalizeCallback(exp: Expression): Expression {
|
||||
}
|
||||
return args.reduce(
|
||||
(previousValue, currentValue) => previousValue.add(currentValue),
|
||||
ADDITIVE_IDENTITY
|
||||
ADDITIVE_IDENTITY,
|
||||
) as unknown as Expression;
|
||||
} else if (op === "*") {
|
||||
const args: Polynomial[] = [];
|
||||
@@ -384,7 +384,7 @@ function normalizeCallback(exp: Expression): Expression {
|
||||
}
|
||||
return args.reduce(
|
||||
(previousValue, currentValue) => previousValue.multiply(currentValue),
|
||||
MULTIPLICATIVE_IDENTITY
|
||||
MULTIPLICATIVE_IDENTITY,
|
||||
) as unknown as Expression;
|
||||
} else if (op === "-") {
|
||||
const args: Polynomial[] = [];
|
||||
@@ -394,7 +394,7 @@ function normalizeCallback(exp: Expression): Expression {
|
||||
args.push(p);
|
||||
}
|
||||
return args.reduce((previousValue, currentValue) =>
|
||||
previousValue.subtract(currentValue)
|
||||
previousValue.subtract(currentValue),
|
||||
) as unknown as Expression;
|
||||
} else if (op === "/") {
|
||||
const args: Polynomial[] = [];
|
||||
@@ -404,7 +404,7 @@ function normalizeCallback(exp: Expression): Expression {
|
||||
args.push(p);
|
||||
}
|
||||
return args.reduce((previousValue, currentValue) =>
|
||||
previousValue.divide(currentValue)
|
||||
previousValue.divide(currentValue),
|
||||
) as unknown as Expression;
|
||||
} else if (["=", "<>", ">", ">=", "<", "<="].includes(op)) {
|
||||
if (exp[1] == null || exp[2] == null) return null;
|
||||
@@ -471,7 +471,7 @@ function normalizeCallback(exp: Expression): Expression {
|
||||
|
||||
// Restore polynomial expressions
|
||||
exp = exp.map((e) =>
|
||||
e instanceof Polynomial ? JSON.parse(e.toString()) : e
|
||||
e instanceof Polynomial ? JSON.parse(e.toString()) : e,
|
||||
);
|
||||
|
||||
exp = evaluateCallback(exp);
|
||||
@@ -485,7 +485,7 @@ export default function normalize(expr: Expression): Expression {
|
||||
expr = JSON.parse(expr.toString());
|
||||
} else if (Array.isArray(expr) && expr[0] === "CASE") {
|
||||
expr = expr.map((e) =>
|
||||
e instanceof Polynomial ? JSON.parse(e.toString()) : e
|
||||
e instanceof Polynomial ? JSON.parse(e.toString()) : e,
|
||||
);
|
||||
}
|
||||
return expr;
|
||||
|
||||
@@ -57,7 +57,7 @@ export function map<T>(exp: Expression, callback: (e: Expression) => T): T {
|
||||
|
||||
export async function mapAsync(
|
||||
exp: Expression,
|
||||
callback: (e: Expression) => Promise<Expression>
|
||||
callback: (e: Expression) => Promise<Expression>,
|
||||
): Promise<Expression> {
|
||||
if (!Array.isArray(exp)) return callback(exp);
|
||||
|
||||
@@ -75,7 +75,7 @@ export async function mapAsync(
|
||||
|
||||
function binaryLeft(
|
||||
operatorsParser: parsimmon.Parser<string>,
|
||||
nextParser: parsimmon.Parser<Expression>
|
||||
nextParser: parsimmon.Parser<Expression>,
|
||||
): parsimmon.Parser<Expression> {
|
||||
return parsimmon.seqMap(
|
||||
nextParser,
|
||||
@@ -85,7 +85,7 @@ function binaryLeft(
|
||||
const [op, another] = ch;
|
||||
if (Array.isArray(acc) && op === acc[0]) return acc.concat([another]);
|
||||
return [op, acc, another];
|
||||
}, first)
|
||||
}, first),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ const lang = parsimmon.createLanguage({
|
||||
parsimmon.string("<="),
|
||||
parsimmon.string("="),
|
||||
parsimmon.string(">"),
|
||||
parsimmon.string("<")
|
||||
parsimmon.string("<"),
|
||||
)
|
||||
.skip(parsimmon.optWhitespace);
|
||||
},
|
||||
@@ -109,7 +109,7 @@ const lang = parsimmon.createLanguage({
|
||||
parsimmon
|
||||
.regexp(/not\s+like/i)
|
||||
.result("NOT LIKE")
|
||||
.desc("NOT LIKE")
|
||||
.desc("NOT LIKE"),
|
||||
)
|
||||
.notFollowedBy(parsimmon.regexp(/[a-zA-Z0-9_]/))
|
||||
.skip(parsimmon.optWhitespace);
|
||||
@@ -124,7 +124,7 @@ const lang = parsimmon.createLanguage({
|
||||
parsimmon
|
||||
.regexp(/is\s+not\s+null/i)
|
||||
.result("IS NOT NULL")
|
||||
.desc("IS NOT NULL")
|
||||
.desc("IS NOT NULL"),
|
||||
)
|
||||
.notFollowedBy(parsimmon.regexp(/[a-zA-Z0-9_]/))
|
||||
.skip(parsimmon.optWhitespace);
|
||||
@@ -159,8 +159,8 @@ const lang = parsimmon.createLanguage({
|
||||
parsimmon.regexp(/[a-zA-Z0-9_.*-]+/),
|
||||
r.Expression.wrap(
|
||||
parsimmon.string("{").skip(parsimmon.optWhitespace),
|
||||
parsimmon.string("}")
|
||||
)
|
||||
parsimmon.string("}"),
|
||||
),
|
||||
)
|
||||
.atLeast(1)
|
||||
.map((x) => ["PARAM", x.length > 1 ? ["||"].concat(x) : x[0]])
|
||||
@@ -194,7 +194,7 @@ const lang = parsimmon.createLanguage({
|
||||
return parsimmon
|
||||
.alt(
|
||||
parsimmon.regexp(/true/i).result(true).desc("TRUE"),
|
||||
parsimmon.regexp(/false/i).result(false).desc("FALSE")
|
||||
parsimmon.regexp(/false/i).result(false).desc("FALSE"),
|
||||
)
|
||||
.notFollowedBy(parsimmon.regexp(/[a-zA-Z0-9_]/))
|
||||
.skip(parsimmon.optWhitespace);
|
||||
@@ -215,9 +215,9 @@ const lang = parsimmon.createLanguage({
|
||||
.desc("function"),
|
||||
r.ExpressionList.wrap(
|
||||
parsimmon.string("(").skip(parsimmon.optWhitespace),
|
||||
parsimmon.string(")").skip(parsimmon.optWhitespace)
|
||||
parsimmon.string(")").skip(parsimmon.optWhitespace),
|
||||
),
|
||||
(f, args) => ["FUNC", f.toUpperCase()].concat(args)
|
||||
(f, args) => ["FUNC", f.toUpperCase()].concat(args),
|
||||
);
|
||||
},
|
||||
WhenPair: function (r) {
|
||||
@@ -233,7 +233,7 @@ const lang = parsimmon.createLanguage({
|
||||
.notFollowedBy(parsimmon.regexp(/[a-zA-Z0-9_]/))
|
||||
.skip(parsimmon.optWhitespace)
|
||||
.desc("THEN")
|
||||
.then(r.Expression)
|
||||
.then(r.Expression),
|
||||
);
|
||||
},
|
||||
CaseStatement: function (r) {
|
||||
@@ -256,10 +256,10 @@ const lang = parsimmon.createLanguage({
|
||||
.skip(
|
||||
parsimmon
|
||||
.regex(/end/i)
|
||||
.notFollowedBy(parsimmon.regexp(/[a-zA-Z0-9_]/))
|
||||
.notFollowedBy(parsimmon.regexp(/[a-zA-Z0-9_]/)),
|
||||
)
|
||||
.skip(parsimmon.optWhitespace),
|
||||
(...arr) => arr.flat(2)
|
||||
(...arr) => arr.flat(2),
|
||||
);
|
||||
},
|
||||
Value: function (r) {
|
||||
@@ -270,7 +270,7 @@ const lang = parsimmon.createLanguage({
|
||||
r.StringValueSql,
|
||||
r.StringValueJs,
|
||||
r.FuncValue,
|
||||
r.CaseStatement
|
||||
r.CaseStatement,
|
||||
);
|
||||
},
|
||||
ValueExpression: function (r) {
|
||||
@@ -285,7 +285,7 @@ const lang = parsimmon.createLanguage({
|
||||
.alt(
|
||||
parsimmon.string("*"),
|
||||
parsimmon.string("/"),
|
||||
parsimmon.string("%")
|
||||
parsimmon.string("%"),
|
||||
)
|
||||
.skip(parsimmon.optWhitespace),
|
||||
parsimmon.alt(
|
||||
@@ -293,11 +293,11 @@ const lang = parsimmon.createLanguage({
|
||||
r.Parameter,
|
||||
r.Expression.wrap(
|
||||
parsimmon.string("(").skip(parsimmon.optWhitespace),
|
||||
parsimmon.string(")").skip(parsimmon.optWhitespace)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
parsimmon.string(")").skip(parsimmon.optWhitespace),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
Comparison: function (r) {
|
||||
@@ -307,7 +307,7 @@ const lang = parsimmon.createLanguage({
|
||||
r.ValueExpression,
|
||||
r.ComparisonOperator,
|
||||
r.ValueExpression,
|
||||
(p, o, v) => [o, p, v]
|
||||
(p, o, v) => [o, p, v],
|
||||
),
|
||||
parsimmon.seqMap(
|
||||
r.ValueExpression,
|
||||
@@ -317,28 +317,28 @@ const lang = parsimmon.createLanguage({
|
||||
.regexp(/escape/i)
|
||||
.result("ESCAPE")
|
||||
.skip(parsimmon.whitespace)
|
||||
.desc("ESCAPE")
|
||||
.desc("ESCAPE"),
|
||||
),
|
||||
r.ValueExpression,
|
||||
(a, b, c, d) => [b, a, c, d]
|
||||
(a, b, c, d) => [b, a, c, d],
|
||||
),
|
||||
parsimmon.seqMap(
|
||||
r.ValueExpression,
|
||||
r.LikeOperator,
|
||||
r.ValueExpression,
|
||||
(a, b, c) => [b, a, c]
|
||||
)
|
||||
(a, b, c) => [b, a, c],
|
||||
),
|
||||
);
|
||||
},
|
||||
ExpressionList: function (r) {
|
||||
return r.Expression.sepBy(
|
||||
parsimmon.string(",").skip(parsimmon.optWhitespace)
|
||||
parsimmon.string(",").skip(parsimmon.optWhitespace),
|
||||
);
|
||||
},
|
||||
Expression: function (r) {
|
||||
function unary(
|
||||
operatorsParser: parsimmon.Parser<string>,
|
||||
nextParser: parsimmon.Parser<Expression>
|
||||
nextParser: parsimmon.Parser<Expression>,
|
||||
): parsimmon.Parser<Expression> {
|
||||
return parsimmon.seq(operatorsParser, nextParser).or(nextParser);
|
||||
}
|
||||
@@ -347,8 +347,8 @@ const lang = parsimmon.createLanguage({
|
||||
r.OrOperator,
|
||||
binaryLeft(
|
||||
r.AndOperator,
|
||||
unary(r.NotOperator, r.Comparison.or(r.ValueExpression))
|
||||
)
|
||||
unary(r.NotOperator, r.Comparison.or(r.ValueExpression)),
|
||||
),
|
||||
).trim(parsimmon.optWhitespace);
|
||||
},
|
||||
});
|
||||
@@ -400,7 +400,7 @@ export function stringify(exp: Expression, level = 0): string {
|
||||
`${exp[1]}(${exp
|
||||
.slice(2)
|
||||
.map((e) => stringify(e))
|
||||
.join(", ")})`
|
||||
.join(", ")})`,
|
||||
);
|
||||
} else if (op === "PARAM") {
|
||||
if (typeof exp[1] === "string") {
|
||||
@@ -413,7 +413,7 @@ export function stringify(exp: Expression, level = 0): string {
|
||||
if (typeof p === "string") return p;
|
||||
else return `{${stringify(p)}}`;
|
||||
})
|
||||
.join("")
|
||||
.join(""),
|
||||
);
|
||||
} else {
|
||||
return wrap(`{${stringify(exp[1])}}`);
|
||||
@@ -425,15 +425,15 @@ export function stringify(exp: Expression, level = 0): string {
|
||||
return wrap(
|
||||
`${stringify(exp[1], opLevels[op])} ${op} ${stringify(
|
||||
exp[2],
|
||||
opLevels[op]
|
||||
)} ESCAPE ${stringify(exp[3], opLevels[op])}`
|
||||
opLevels[op],
|
||||
)} ESCAPE ${stringify(exp[3], opLevels[op])}`,
|
||||
);
|
||||
} else {
|
||||
return wrap(
|
||||
`${stringify(exp[1], opLevels[op])} ${op} ${stringify(
|
||||
exp[2],
|
||||
opLevels[op]
|
||||
)}`
|
||||
opLevels[op],
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
} else if (op === "CASE") {
|
||||
|
||||
@@ -7,7 +7,7 @@ type Minterm = number[];
|
||||
|
||||
export abstract class SynthContextBase<
|
||||
T extends { toString: () => string } = unknown,
|
||||
U = unknown
|
||||
U = unknown,
|
||||
> {
|
||||
public variables = new Map<string, number>();
|
||||
protected clauses = new Map<number, U>();
|
||||
@@ -88,7 +88,7 @@ export abstract class Clause {
|
||||
isNullable(c: Clause.IsNull): boolean {
|
||||
if (!this._isNullable) {
|
||||
this._isNullable = new Set(
|
||||
[...this.getNullables()].map((n) => n.toString())
|
||||
[...this.getNullables()].map((n) => n.toString()),
|
||||
);
|
||||
}
|
||||
return this._isNullable.has(c.toString());
|
||||
@@ -243,14 +243,14 @@ export namespace Clause {
|
||||
const w = this.clauses[i].true(context);
|
||||
const t = this.clauses[i + 1].true(context);
|
||||
minterms.push(
|
||||
...complement([...cumulative, ...complement(w), ...complement(t)])
|
||||
...complement([...cumulative, ...complement(w), ...complement(t)]),
|
||||
);
|
||||
if (i < this.clauses.length - 2) {
|
||||
cumulative.push(
|
||||
...complement([
|
||||
...this.clauses[i].false(context),
|
||||
...this.clauses[i].null(context),
|
||||
])
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -263,14 +263,14 @@ export namespace Clause {
|
||||
const w = this.clauses[i].true(context);
|
||||
const t = this.clauses[i + 1].false(context);
|
||||
minterms.push(
|
||||
...complement([...cumulative, ...complement(w), ...complement(t)])
|
||||
...complement([...cumulative, ...complement(w), ...complement(t)]),
|
||||
);
|
||||
if (i < this.clauses.length - 2) {
|
||||
cumulative.push(
|
||||
...complement([
|
||||
...this.clauses[i].false(context),
|
||||
...this.clauses[i].null(context),
|
||||
])
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -283,13 +283,13 @@ export namespace Clause {
|
||||
const w = this.clauses[i].true(context);
|
||||
const t = this.clauses[i + 1].null(context);
|
||||
minterms.push(
|
||||
...complement([...cumulative, ...complement(w), ...complement(t)])
|
||||
...complement([...cumulative, ...complement(w), ...complement(t)]),
|
||||
);
|
||||
cumulative.push(
|
||||
...complement([
|
||||
...this.clauses[i].false(context),
|
||||
...this.clauses[i].null(context),
|
||||
])
|
||||
]),
|
||||
);
|
||||
}
|
||||
minterms.push(...complement([...cumulative]));
|
||||
@@ -313,7 +313,7 @@ export namespace Clause {
|
||||
minterms.push(...cases.pop().when);
|
||||
minterms = context.minimize(
|
||||
minterms,
|
||||
cases.flatMap((c) => c.when)
|
||||
cases.flatMap((c) => c.when),
|
||||
);
|
||||
if (!minterms.length) continue;
|
||||
cases.push({ when: minterms, then });
|
||||
@@ -395,7 +395,7 @@ export namespace Clause {
|
||||
constructor(
|
||||
public lhs: Clause,
|
||||
public op: ">" | "<" | "=",
|
||||
public rhs: boolean | number | string
|
||||
public rhs: boolean | number | string,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
@@ -425,7 +425,11 @@ export namespace Clause {
|
||||
public readonly pattern: string[];
|
||||
public readonly lhs: Clause;
|
||||
|
||||
constructor(lhs: Clause, public rhs: string, public esc?: string) {
|
||||
constructor(
|
||||
lhs: Clause,
|
||||
public rhs: string,
|
||||
public esc?: string,
|
||||
) {
|
||||
super();
|
||||
const exp = lhs.expression();
|
||||
let caseSensitive = true;
|
||||
@@ -515,7 +519,7 @@ export namespace Clause {
|
||||
clause = new Clause.Compare(
|
||||
e[1],
|
||||
op,
|
||||
rhs as boolean | number | string
|
||||
rhs as boolean | number | string,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -535,7 +539,7 @@ export namespace Clause {
|
||||
|
||||
function groupBy<T, K>(
|
||||
input: T[],
|
||||
callback: (item: T) => K
|
||||
callback: (item: T) => K,
|
||||
): Iterable<[K, T[]]> {
|
||||
const groups = new Map<K, T[]>();
|
||||
for (const item of input) {
|
||||
@@ -567,12 +571,12 @@ export class SynthContext extends SynthContextBase<Clause, Clause> {
|
||||
|
||||
const allClauses = [...whitelist].map((v) => this.getClause(v));
|
||||
const comparisons = allClauses.filter(
|
||||
(c) => c instanceof Clause.Compare
|
||||
(c) => c instanceof Clause.Compare,
|
||||
) as Clause.Compare[];
|
||||
|
||||
// Comparisons
|
||||
for (const [, clauses] of groupBy(comparisons, (c) =>
|
||||
JSON.stringify(c.lhs)
|
||||
JSON.stringify(c.lhs),
|
||||
)) {
|
||||
const lhs = clauses[0].lhs;
|
||||
const values = new Set(clauses.map((c) => c.rhs));
|
||||
@@ -600,13 +604,13 @@ export class SynthContext extends SynthContextBase<Clause, Clause> {
|
||||
|
||||
for (let j = 0; j < i; j++) {
|
||||
const eq2 = this.getVar(
|
||||
new Clause.Compare(lhs, "=", valuesSorted[j])
|
||||
new Clause.Compare(lhs, "=", valuesSorted[j]),
|
||||
);
|
||||
const gt2 = this.getVar(
|
||||
new Clause.Compare(lhs, ">", valuesSorted[j])
|
||||
new Clause.Compare(lhs, ">", valuesSorted[j]),
|
||||
);
|
||||
const lt2 = this.getVar(
|
||||
new Clause.Compare(lhs, "<", valuesSorted[j])
|
||||
new Clause.Compare(lhs, "<", valuesSorted[j]),
|
||||
);
|
||||
|
||||
// This is the minimum clauses required if all relavent vars
|
||||
@@ -631,7 +635,7 @@ export class SynthContext extends SynthContextBase<Clause, Clause> {
|
||||
|
||||
// LIKE
|
||||
const likes = allClauses.filter(
|
||||
(c) => c instanceof Clause.Like
|
||||
(c) => c instanceof Clause.Like,
|
||||
) as Clause.Like[];
|
||||
|
||||
for (const [, clauses] of groupBy(likes, (c) => JSON.stringify(c.lhs))) {
|
||||
@@ -734,7 +738,7 @@ export class SynthContext extends SynthContextBase<Clause, Clause> {
|
||||
for (const [k, v] of merged) {
|
||||
if (v === 0b1010) continue loop;
|
||||
const isNullVars = [...this.clauses.get(k).getNullables()].map((c) =>
|
||||
this.getVar(c)
|
||||
this.getVar(c),
|
||||
);
|
||||
const t = k << 2;
|
||||
if (v === 0b0101) {
|
||||
@@ -858,7 +862,7 @@ export function minimize(expr: Expression, boolean = false): Expression {
|
||||
|
||||
export function unionDiff(
|
||||
expr1: Expression,
|
||||
expr2: Expression
|
||||
expr2: Expression,
|
||||
): [Expression, Expression] {
|
||||
expr2 = normalize(expr2);
|
||||
|
||||
@@ -887,7 +891,7 @@ export function unionDiff(
|
||||
complement([
|
||||
...complement([...expr1NullMinterms, ...expr1FalseMinterms]),
|
||||
...complement(expr2Minterms),
|
||||
])
|
||||
]),
|
||||
);
|
||||
|
||||
return [context.toExpression(union), context.toExpression(diff)];
|
||||
|
||||
@@ -74,7 +74,7 @@ export function likePatternToRegExp(pat: string, esc = "", flags = ""): RegExp {
|
||||
|
||||
function compare(
|
||||
a: boolean | number | string,
|
||||
b: boolean | number | string
|
||||
b: boolean | number | string,
|
||||
): number {
|
||||
if (typeof a === "boolean") a = +a;
|
||||
if (typeof b === "boolean") b = +b;
|
||||
@@ -287,19 +287,19 @@ export function evaluate(
|
||||
exp: Expression,
|
||||
obj: Record<string, unknown> | ((e: string) => Expression),
|
||||
now: number,
|
||||
cb?: (e: Expression) => Expression
|
||||
cb?: (e: Expression) => Expression,
|
||||
): string | number | boolean | null;
|
||||
export function evaluate(
|
||||
exp: Expression,
|
||||
obj?: Record<string, unknown> | ((e: string) => Expression),
|
||||
now?: number,
|
||||
cb?: (e: Expression) => Expression
|
||||
cb?: (e: Expression) => Expression,
|
||||
): Expression;
|
||||
export function evaluate(
|
||||
exp: Expression,
|
||||
obj?: Record<string, unknown> | ((e: string) => Expression),
|
||||
now?: number,
|
||||
cb?: (e: Expression) => Expression
|
||||
cb?: (e: Expression) => Expression,
|
||||
): Expression {
|
||||
return map(exp, (e) => {
|
||||
if (cb) e = cb(e);
|
||||
@@ -327,19 +327,19 @@ export async function evaluateAsync(
|
||||
exp: Expression,
|
||||
obj: Record<string, unknown>,
|
||||
now: number,
|
||||
cb?: (e: Expression) => Promise<Expression>
|
||||
cb?: (e: Expression) => Promise<Expression>,
|
||||
): Promise<string | number | boolean | null>;
|
||||
export async function evaluateAsync(
|
||||
exp: Expression,
|
||||
obj?: Record<string, unknown>,
|
||||
now?: number,
|
||||
cb?: (e: Expression) => Promise<Expression>
|
||||
cb?: (e: Expression) => Promise<Expression>,
|
||||
): Promise<Expression>;
|
||||
export async function evaluateAsync(
|
||||
exp: Expression,
|
||||
obj?: Record<string, unknown>,
|
||||
now?: number,
|
||||
cb?: (e: Expression) => Promise<Expression>
|
||||
cb?: (e: Expression) => Promise<Expression>,
|
||||
): Promise<Expression> {
|
||||
return mapAsync(exp, async (e) => {
|
||||
if (cb) e = await cb(e);
|
||||
|
||||
@@ -75,7 +75,7 @@ export default class PathSet {
|
||||
path: Path,
|
||||
superset = false,
|
||||
subset = false,
|
||||
depth: number = path.length
|
||||
depth: number = path.length,
|
||||
): Path[] {
|
||||
if (path.alias) throw new Error("PathSet does not support aliased paths");
|
||||
|
||||
@@ -115,7 +115,7 @@ export default class PathSet {
|
||||
res = [...fragmentIndexSet1, ...fragmentIndexSet2];
|
||||
} else {
|
||||
res = res.filter(
|
||||
(r) => fragmentIndexSet1.has(r) || fragmentIndexSet2.has(r)
|
||||
(r) => fragmentIndexSet1.has(r) || fragmentIndexSet2.has(r),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -57,7 +57,7 @@ export default class Path {
|
||||
|
||||
protected static parseAliasValue(
|
||||
pattern: string,
|
||||
index: number
|
||||
index: number,
|
||||
): { index: number; value: string } {
|
||||
let i = index;
|
||||
while (charCodeAt(pattern, i) === CHAR_SPACE) ++i;
|
||||
@@ -89,7 +89,7 @@ export default class Path {
|
||||
|
||||
protected static parseAliasPath(
|
||||
pattern: string,
|
||||
index: number
|
||||
index: number,
|
||||
): { index: number; path: Path } {
|
||||
let i = index;
|
||||
while (charCodeAt(pattern, i) === CHAR_SPACE) ++i;
|
||||
@@ -103,7 +103,7 @@ export default class Path {
|
||||
|
||||
protected static parseAlias(
|
||||
pattern: string,
|
||||
index: number
|
||||
index: number,
|
||||
): { index: number; alias: Alias } {
|
||||
const alias: Alias = [];
|
||||
let i = index;
|
||||
@@ -136,7 +136,7 @@ export default class Path {
|
||||
|
||||
protected static parsePath(
|
||||
pattern: string,
|
||||
index: number
|
||||
index: number,
|
||||
): { index: number; segments: Segments } {
|
||||
const segments = [];
|
||||
|
||||
@@ -173,7 +173,7 @@ export default class Path {
|
||||
if (Array.isArray(s)) {
|
||||
alias |= 1 << i;
|
||||
const parts = s.map(
|
||||
(al) => `${al[0].toString()}:${JSON.stringify(al[1])}`
|
||||
(al) => `${al[0].toString()}:${JSON.stringify(al[1])}`,
|
||||
);
|
||||
return `[${parts.join(",")}]`;
|
||||
} else if (s === "*") {
|
||||
|
||||
+6
-6
@@ -15,7 +15,7 @@ const STRING_RESERVED = new Set([
|
||||
|
||||
function isPrintable(str: string): boolean {
|
||||
return !/[^\t\n\x20-\x7e\x85\u{a0}-\u{d7ff}\u{e000}-\u{fffd}\u{10000}-\u{10ffff}]/u.test(
|
||||
str
|
||||
str,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ function stringifyString(str: string, res: string[], prefix1, prefix2): void {
|
||||
if (!isFolded) {
|
||||
res.push(
|
||||
`${prefix1}|${idt}${chmp}`,
|
||||
...lines.map((l) => (l ? prefix2 + l : l))
|
||||
...lines.map((l) => (l ? prefix2 + l : l)),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ function stringifyAny(
|
||||
obj: unknown,
|
||||
res: string[],
|
||||
prefix1 = "",
|
||||
prefix2 = ""
|
||||
prefix2 = "",
|
||||
): void {
|
||||
if (obj == null) {
|
||||
res.push(`${prefix1}null`);
|
||||
@@ -183,7 +183,7 @@ function stringifyAny(
|
||||
entries[0][1],
|
||||
res,
|
||||
prefix1 + `${stringifyKey(entries[0][0])}: `,
|
||||
prefix2 + INDENTATION
|
||||
prefix2 + INDENTATION,
|
||||
);
|
||||
prefix1 = prefix2;
|
||||
prefix2 = prefix2 + INDENTATION;
|
||||
@@ -192,7 +192,7 @@ function stringifyAny(
|
||||
entries[i][1],
|
||||
res,
|
||||
prefix1 + `${stringifyKey(entries[i][0])}: `,
|
||||
prefix2
|
||||
prefix2,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -204,7 +204,7 @@ function stringifyAny(
|
||||
entries[i][1],
|
||||
res,
|
||||
prefix1 + `${stringifyKey(entries[i][0])}: `,
|
||||
prefix2
|
||||
prefix2,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user