@khanacademy/kas 0.3.9 → 0.3.11
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/README.md +9 -14
- package/dist/compare.d.ts +2 -0
- package/dist/es/index.js +20 -14
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +9 -15
- package/dist/index.js.map +1 -1
- package/dist/parser-generator.d.ts +45 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
===
|
|
1
|
+
# @khanacademy/kas
|
|
3
2
|
|
|
4
3
|
A lightweight JavaScript CAS (Computer Algebra System) for comparing expressions and equations.
|
|
5
4
|
It is used throughout [Khan Academy](https://khanacademy.org)'s interactive exercises.
|
|
6
5
|
|
|
7
|
-
What can it do?
|
|
8
|
-
---------------
|
|
6
|
+
## What can it do?
|
|
9
7
|
|
|
10
8
|
It can parse plain text math, LaTeX, or a mix of both:
|
|
11
9
|
|
|
@@ -77,18 +75,15 @@ expr.simplify().print();
|
|
|
77
75
|
// "(-1+3*p)^(-1)*(3*n+-1*m+2*p)"
|
|
78
76
|
```
|
|
79
77
|
|
|
80
|
-
How to build the library
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
npm run build
|
|
78
|
+
## How to build the library
|
|
79
|
+
yarn
|
|
80
|
+
yarn build
|
|
84
81
|
|
|
85
|
-
How to build the parser
|
|
86
|
-
-----------------------
|
|
82
|
+
## How to build the parser
|
|
87
83
|
First, make any changes in `src/parser-generator.js`
|
|
88
84
|
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
yarn
|
|
86
|
+
yarn build:parser
|
|
91
87
|
|
|
92
|
-
License
|
|
93
|
-
-------
|
|
88
|
+
## License
|
|
94
89
|
[MIT License](http://opensource.org/licenses/MIT)
|
package/dist/es/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import _ from 'underscore';
|
|
|
3
3
|
|
|
4
4
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
5
5
|
const libName = "@khanacademy/kas";
|
|
6
|
-
const libVersion = "0.3.
|
|
6
|
+
const libVersion = "0.3.11";
|
|
7
7
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
8
8
|
|
|
9
9
|
// this is a @generated file
|
|
@@ -5817,15 +5817,27 @@ var derivedUnits = {
|
|
|
5817
5817
|
const Zero = Num.Zero;
|
|
5818
5818
|
const One = Num.One;
|
|
5819
5819
|
|
|
5820
|
-
|
|
5820
|
+
function _extends() {
|
|
5821
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
5822
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
5823
|
+
var source = arguments[i];
|
|
5824
|
+
for (var key in source) {
|
|
5825
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
5826
|
+
target[key] = source[key];
|
|
5827
|
+
}
|
|
5828
|
+
}
|
|
5829
|
+
}
|
|
5830
|
+
return target;
|
|
5831
|
+
};
|
|
5832
|
+
return _extends.apply(this, arguments);
|
|
5833
|
+
}
|
|
5821
5834
|
|
|
5822
5835
|
// Assumes that both expressions have already been parsed
|
|
5823
5836
|
// TODO(alex): be able to pass a random() function to compare()
|
|
5824
5837
|
const compare = function compare(expr1, expr2, options) {
|
|
5825
|
-
|
|
5838
|
+
const defaults = {
|
|
5826
5839
|
form: false,
|
|
5827
|
-
|
|
5828
|
-
simplify: false // Check that the second expression is simplified
|
|
5840
|
+
simplify: false
|
|
5829
5841
|
};
|
|
5830
5842
|
|
|
5831
5843
|
/* Options that could be added in the future:
|
|
@@ -5833,20 +5845,14 @@ const compare = function compare(expr1, expr2, options) {
|
|
|
5833
5845
|
* like slope
|
|
5834
5846
|
* - Allow student to choose their own variable names
|
|
5835
5847
|
*/
|
|
5836
|
-
|
|
5837
|
-
if (options !== undefined) {
|
|
5838
|
-
// eslint-disable-next-line no-undef
|
|
5839
|
-
options = _.extend(defaults, options);
|
|
5840
|
-
} else {
|
|
5841
|
-
options = defaults;
|
|
5842
|
-
}
|
|
5848
|
+
options = _extends({}, defaults, options);
|
|
5843
5849
|
|
|
5844
5850
|
// TODO(CP-1614): Figure out how to make these messages translatable
|
|
5845
5851
|
|
|
5846
5852
|
// Variable check
|
|
5847
|
-
|
|
5853
|
+
const vars = expr1.sameVars(expr2);
|
|
5848
5854
|
if (!vars.equal) {
|
|
5849
|
-
|
|
5855
|
+
let message;
|
|
5850
5856
|
if (vars.equalIgnoringCase) {
|
|
5851
5857
|
message = "Check your variables; one or more are using " + "the wrong case (upper or lower).";
|
|
5852
5858
|
} else {
|