@khanacademy/kas 0.5.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/index.js CHANGED
@@ -3,8 +3,11 @@ import _extends from '@babel/runtime/helpers/extends';
3
3
  import _ from 'underscore';
4
4
 
5
5
  // This file is processed by a Rollup plugin (replace) to inject the production
6
+ // version number during the release build.
7
+ // In dev, you'll never see the version number.
8
+
6
9
  const libName = "@khanacademy/kas";
7
- const libVersion = "0.5.1";
10
+ const libVersion = "2.0.0";
8
11
  addLibraryVersionToPerseusDebug(libName, libVersion);
9
12
 
10
13
  // this is a @generated file
@@ -2931,6 +2934,7 @@ class Expr {
2931
2934
  // the other Expr can have more variables than this one
2932
2935
  // this lets you multiply equations by other variables
2933
2936
  var same = function same(array1, array2) {
2937
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
2934
2938
  return !_.difference(array1, array2).length;
2935
2939
  };
2936
2940
  var lower = function lower(array) {
@@ -2966,7 +2970,7 @@ class Expr {
2966
2970
  };
2967
2971
  var equalNumbers = function equalNumbers(num1, num2) {
2968
2972
  var delta = getDelta(num1, num2);
2969
- return num1 === num2 /* needed if either is +/- Infinity */ || isNaN(num1) && isNaN(num2) || delta < Math.pow(10, -TOLERANCE);
2973
+ return num1 === num2 /* needed if either is +/- Infinity */ || isNaN(num1) && isNaN(num2) || delta < Math.pow(10, -9);
2970
2974
  };
2971
2975
 
2972
2976
  // If no variables, only need to evaluate once.
@@ -2975,6 +2979,7 @@ class Expr {
2975
2979
  // Ran into issues with it in LEMS-2777 and found that tests pass
2976
2980
  // with this removed, but keeping a modified version out of caution.
2977
2981
  const varAndFuncList = _.union(this.getVars(/* excludeFunc */false), other.getVars(/* excludeFunc */false));
2982
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
2978
2983
  if (!varAndFuncList.length && !this.has(Unit) && !other.has(Unit)) {
2979
2984
  return equalNumbers(this.eval(), other.eval());
2980
2985
  }
@@ -3372,8 +3377,12 @@ class Mul extends Seq {
3372
3377
  return "other";
3373
3378
  }
3374
3379
  });
3380
+
3381
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
3375
3382
  var inverses = terms.inverse || [];
3383
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
3376
3384
  var numbers = terms.number || [];
3385
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
3377
3386
  var others = terms.other || [];
3378
3387
  var negatives = "";
3379
3388
  var numerator;
@@ -3434,6 +3443,8 @@ class Mul extends Seq {
3434
3443
  });
3435
3444
  numerator = tex ? tex : "1";
3436
3445
  }
3446
+
3447
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
3437
3448
  if (!inverses.length) {
3438
3449
  return negatives + numerator;
3439
3450
  } else {
@@ -3564,8 +3575,11 @@ class Mul extends Seq {
3564
3575
  return "expr";
3565
3576
  }
3566
3577
  });
3578
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
3567
3579
  let trigs = groupedPairs.trig || [];
3580
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
3568
3581
  let logs = groupedPairs.log || [];
3582
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
3569
3583
  const exprs = groupedPairs.expr || [];
3570
3584
  if (trigs.length > 1) {
3571
3585
  // combine sines and cosines into other trig functions
@@ -3652,7 +3666,10 @@ class Mul extends Seq {
3652
3666
  // `partition` splits the terms into two Seqs - one containing
3653
3667
  // only Nums and the all non-Num nodes.
3654
3668
  var numbers = partitioned[0].terms;
3669
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
3655
3670
  var fold = numbers.length && _.all(numbers, num => num.n > 0);
3671
+
3672
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
3656
3673
  if (fold) {
3657
3674
  // e.g. - x*2*3 -> x*-2*3
3658
3675
  var num = numbers[0].negate();
@@ -4703,6 +4720,8 @@ class Abs extends Expr {
4703
4720
  }
4704
4721
  });
4705
4722
  var positives = terms.positive.concat(_.invoke(terms.number, "abs"));
4723
+
4724
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
4706
4725
  if (terms.other.length) {
4707
4726
  positives.push(new Abs(new Mul(terms.other).flatten()));
4708
4727
  }
@@ -4842,15 +4861,21 @@ class Eq extends Expr {
4842
4861
  return expr;
4843
4862
  }
4844
4863
  const terms = factored.terms;
4864
+
4865
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
4845
4866
  const hasVar = term => !!term.getVars().length;
4846
4867
  const isOne = term => term.equals(NumOne);
4847
4868
  const [adds, others] = partition(terms, isAdd);
4869
+
4870
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
4848
4871
  if (adds.length && this.isEquality()) {
4849
4872
  // keep only Adds
4850
4873
  // e.g. 2xy(z+1)(=0) -> z+1(=0)
4851
4874
  return new Mul(adds).flatten();
4852
4875
  }
4853
4876
  let denominator = others;
4877
+
4878
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
4854
4879
  if (!adds.length) {
4855
4880
  // if no Adds, keep all variable terms to preserve meaning
4856
4881
  // e.g. 42xyz(=0) -> xyz(=0)