Skip to content

Commit

Permalink
Bite the bullet and commit build outputs so that they are as accessib…
Browse files Browse the repository at this point in the history
…le as possible for people that may not be able to run the build in some OS or setup. An upside of this is that examples and documentation can be served out of the box without having to build them. Remove package.json 'prepare' scripts because they are no longer needed, as installing from git will already include build outputs.
  • Loading branch information
trusktr committed Sep 8, 2023
1 parent 369051a commit 6063c99
Show file tree
Hide file tree
Showing 25 changed files with 3,698 additions and 4 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
.vscode
node_modules
tmp/
es/
/coverage
lib/

*.lock
*lock.json
62 changes: 62 additions & 0 deletions es/constraint.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Expression } from './expression.js';
import { Variable } from './variable.js';
/**
* An enum defining the linear constraint operators.
*
* |Value|Operator|Description|
* |----|-----|-----|
* |`Le`|<=|Less than equal|
* |`Ge`|>=|Greater than equal|
* |`Eq`|==|Equal|
*
* @enum {Number}
*/
export declare enum Operator {
Le = 0,
Ge = 1,
Eq = 2
}
/**
* A linear constraint equation.
*
* A constraint equation is composed of an expression, an operator,
* and a strength. The RHS of the equation is implicitly zero.
*
* @class
* @param {Expression} expression The constraint expression (LHS).
* @param {Operator} operator The equation operator.
* @param {Expression} [rhs] Right hand side of the expression.
* @param {Number} [strength=Strength.required] The strength of the constraint.
*/
export declare class Constraint {
constructor(expression: Expression | Variable, operator: Operator, rhs?: Expression | Variable | number, strength?: number);
/**
* Returns the unique id number of the constraint.
* @private
*/
id(): number;
/**
* Returns the expression of the constraint.
*
* @return {Expression} expression
*/
expression(): Expression;
/**
* Returns the relational operator of the constraint.
*
* @return {Operator} linear constraint operator
*/
op(): Operator;
/**
* Returns the strength of the constraint.
*
* @return {Number} strength
*/
strength(): number;
toString(): string;
private _expression;
private _operator;
private _strength;
private _id;
}
//# sourceMappingURL=constraint.d.ts.map
1 change: 1 addition & 0 deletions es/constraint.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 86 additions & 0 deletions es/constraint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { Expression } from './expression.js';
import { Strength } from './strength.js';
/**
* An enum defining the linear constraint operators.
*
* |Value|Operator|Description|
* |----|-----|-----|
* |`Le`|<=|Less than equal|
* |`Ge`|>=|Greater than equal|
* |`Eq`|==|Equal|
*
* @enum {Number}
*/
export var Operator;
(function (Operator) {
Operator[Operator["Le"] = 0] = "Le";
Operator[Operator["Ge"] = 1] = "Ge";
Operator[Operator["Eq"] = 2] = "Eq";
})(Operator || (Operator = {}));
/**
* A linear constraint equation.
*
* A constraint equation is composed of an expression, an operator,
* and a strength. The RHS of the equation is implicitly zero.
*
* @class
* @param {Expression} expression The constraint expression (LHS).
* @param {Operator} operator The equation operator.
* @param {Expression} [rhs] Right hand side of the expression.
* @param {Number} [strength=Strength.required] The strength of the constraint.
*/
var Constraint = /** @class */ (function () {
function Constraint(expression, operator, rhs, strength) {
if (strength === void 0) { strength = Strength.required; }
this._id = CnId++;
this._operator = operator;
this._strength = Strength.clip(strength);
if (rhs === undefined && expression instanceof Expression) {
this._expression = expression;
}
else {
this._expression = expression.minus(rhs);
}
}
/**
* Returns the unique id number of the constraint.
* @private
*/
Constraint.prototype.id = function () {
return this._id;
};
/**
* Returns the expression of the constraint.
*
* @return {Expression} expression
*/
Constraint.prototype.expression = function () {
return this._expression;
};
/**
* Returns the relational operator of the constraint.
*
* @return {Operator} linear constraint operator
*/
Constraint.prototype.op = function () {
return this._operator;
};
/**
* Returns the strength of the constraint.
*
* @return {Number} strength
*/
Constraint.prototype.strength = function () {
return this._strength;
};
Constraint.prototype.toString = function () {
return (this._expression.toString() + ' ' + ['<=', '>=', '='][this._operator] + ' 0 (' + this._strength.toString() + ')');
};
return Constraint;
}());
export { Constraint };
/**
* The internal constraint id counter.
* @private
*/
var CnId = 0;
74 changes: 74 additions & 0 deletions es/expression.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { IMap } from './maptype.js';
import { Variable } from './variable.js';
/**
* An expression of variable terms and a constant.
*
* The constructor accepts an arbitrary number of parameters,
* each of which must be one of the following types:
* - number
* - Variable
* - Expression
* - 2-tuple of [number, Variable|Expression]
*
* The parameters are summed. The tuples are multiplied.
*
* @class
* @param {...(number|Variable|Expression|Array)} args
*/
export declare class Expression {
constructor(...args: any[]);
/**
* Returns the mapping of terms in the expression.
*
* This *must* be treated as const.
* @private
*/
terms(): IMap<Variable, number>;
/**
* Returns the constant of the expression.
* @private
*/
constant(): number;
/**
* Returns the computed value of the expression.
*
* @private
* @return {Number} computed value of the expression
*/
value(): number;
/**
* Creates a new Expression by adding a number, variable or expression
* to the expression.
*
* @param {Number|Variable|Expression} value Value to add.
* @return {Expression} expression
*/
plus(value: number | Variable | Expression): Expression;
/**
* Creates a new Expression by substracting a number, variable or expression
* from the expression.
*
* @param {Number|Variable|Expression} value Value to substract.
* @return {Expression} expression
*/
minus(value: number | Variable | Expression): Expression;
/**
* Creates a new Expression by multiplying with a fixed number.
*
* @param {Number} coefficient Coefficient to multiply with.
* @return {Expression} expression
*/
multiply(coefficient: number): Expression;
/**
* Creates a new Expression by dividing with a fixed number.
*
* @param {Number} coefficient Coefficient to divide by.
* @return {Expression} expression
*/
divide(coefficient: number): Expression;
isConstant(): boolean;
toString(): string;
private _terms;
private _constant;
}
//# sourceMappingURL=expression.d.ts.map
1 change: 1 addition & 0 deletions es/expression.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6063c99

Please sign in to comment.