New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@khanacademy/kas

Package Overview
Dependencies
Maintainers
1
Versions
995
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@khanacademy/kas - npm Package Compare versions

Comparing version 0.2.7 to 0.3.0

src/__tests__/checking-form.test.ts

1

.eslintrc.js

@@ -0,1 +1,2 @@

/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable import/no-commonjs */

@@ -2,0 +3,0 @@ const path = require("path");

# @khanacademy/kas
## 0.3.0
### Minor Changes
- 53fd3768: Migrate source code to TypeScript
## 0.2.7

@@ -4,0 +10,0 @@

2

package.json

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "0.2.7",
"version": "0.3.0",
"publishConfig": {

@@ -9,0 +9,0 @@ "access": "public"

@@ -1,2 +0,2 @@

export * from "./nodes.js";
export {compare} from "./compare.js";
export * from "./nodes";
export {compare} from "./compare";
#!/usr/bin/env node
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable comma-dangle */
/* eslint-disable comma-spacing */
/* eslint-disable import/no-commonjs */
/* eslint-disable max-len */
/* eslint-disable no-var */
/* eslint-disable prettier/prettier */
/* TODO(charlie): fix these lint errors (http://eslint.org/docs/rules): */
/* eslint-disable no-var, comma-dangle, max-len, comma-spacing */
const fs = require("fs");
const path = require("path");
var fs = require("fs");
var path = require("path");
const jison = require("jison");
var jison = require("jison");
var grammar = {
lex: {
rules: [
["\\s+", "/* skip whitespace */"],
["\\\\space", "/* skip \\space */"],
["\\\\ ", "/* skip '\\ ' */"],
["[0-9]+\\.?", "return \"INT\""],
["([0-9]+)?\\.[0-9]+", "return \"FLOAT\""],
["\\*\\*", "return \"^\""],
["\\*", "return \"*\""],
["\\\\cdot|\u00b7", "return \"*\""],
["\\\\times|\u00d7", "return \"*\""],
["\\\\ast", "return \"*\""],
["\\/", "return \"/\""],
["\\\\div|\u00F7", "return \"/\""],
["-", "return \"-\""],
["\u2212", "return \"-\""], // minus
["\\+", "return \"+\""],
["\\^", "return \"^\""],
["\\(", "return \"(\""],
["\\)", "return \")\""],
["\\\\left\\(", "return \"(\""],
["\\\\right\\)", "return \")\""],
["\\[", "return \"[\""],
["\\]", "return \"]\""],
["\\{", "return \"{\""],
["\\}", "return \"}\""],
["\\\\left\\{", "return \"{\""],
["\\\\right\\}", "return \"}\""],
["_", "return \"_\""],
["\\|", "return \"|\""],
["\\\\left\\|", "return \"LEFT|\""],
["\\\\right\\|", "return \"RIGHT|\""],
["\\!", "return \"!\""], // not yet interpreted
["<=|>=|<>|<|>|=", "return \"SIGN\""],
["\\\\le", "yytext = \"<=\"; return \"SIGN\""],
["\\\\ge", "yytext = \">=\"; return \"SIGN\""],
["\\\\leq", "yytext = \"<=\"; return \"SIGN\""],
["\\\\geq", "yytext = \">=\"; return \"SIGN\""],
["=\\/=", "yytext = \"<>\"; return \"SIGN\""],
["\\\\ne", "yytext = \"<>\"; return \"SIGN\""],
["\\\\neq", "yytext = \"<>\"; return \"SIGN\""],
["\u2260", "yytext = \"<>\"; return \"SIGN\""], // ne
["\u2264", "yytext = \"<=\"; return \"SIGN\""], // le
["\u2265", "yytext = \">=\"; return \"SIGN\""], // ge
["\\\\frac", "return \"FRAC\""],
["\\\\dfrac", "return \"FRAC\""],
["sqrt|\\\\sqrt", "return \"sqrt\""],
["abs|\\\\abs", "return \"abs\""],
["ln|\\\\ln", "return \"ln\""],
["log|\\\\log", "return \"log\""],
["sin|cos|tan", "return \"TRIG\""],
["csc|sec|cot", "return \"TRIG\""],
["sinh|cosh|tanh", "return \"TRIG\""],
["csch|sech|coth", "return \"TRIG\""],
["\\\\sin", "yytext = \"sin\"; return \"TRIG\""],
["\\\\cos", "yytext = \"cos\"; return \"TRIG\""],
["\\\\tan", "yytext = \"tan\"; return \"TRIG\""],
["\\\\csc", "yytext = \"csc\"; return \"TRIG\""],
["\\\\sec", "yytext = \"sec\"; return \"TRIG\""],
["\\\\cot", "yytext = \"cot\"; return \"TRIG\""],
["\\\\arcsin", "yytext = \"arcsin\"; return \"TRIG\""],
["\\\\arccos", "yytext = \"arccos\"; return \"TRIG\""],
["\\\\arctan", "yytext = \"arctan\"; return \"TRIG\""],
["\\\\arccsc", "yytext = \"arccsc\"; return \"TRIG\""],
["\\\\arcsec", "yytext = \"arcsec\"; return \"TRIG\""],
["\\\\arccot", "yytext = \"arccot\"; return \"TRIG\""],
["arcsin|arccos|arctan","return \"TRIGINV\""],
["arccsc|arcsec|arccot","return \"TRIGINV\""],
["\\\\sinh", "yytext = \"sinh\"; return \"TRIG\""],
["\\\\cosh", "yytext = \"cosh\"; return \"TRIG\""],
["\\\\tanh", "yytext = \"tanh\"; return \"TRIG\""],
["\\\\csch", "yytext = \"csch\"; return \"TRIG\""],
["\\\\sech", "yytext = \"sech\"; return \"TRIG\""],
["\\\\coth", "yytext = \"tanh\"; return \"TRIG\""],
["pi", "return \"CONST\""],
["\u03C0", "yytext = \"pi\"; return \"CONST\""], // pi
["\\\\pi", "yytext = \"pi\"; return \"CONST\""],
["theta", "return \"VAR\""],
["\u03B8", "yytext = \"theta\"; return \"VAR\""], // theta
["\\\\theta", "yytext = \"theta\"; return \"VAR\""],
["phi", "return \"VAR\""],
["\u03C6", "yytext = \"phi\"; return \"VAR\""], // phi
["\\\\phi", "yytext = \"phi\"; return \"VAR\""],
["[a-zA-Z]", "return yy.symbolLexer(yytext)"],
["$", "return \"EOF\""],
[".", "return \"INVALID\""]
["\\s+", "/* skip whitespace */"],
["\\\\space", "/* skip \\space */"],
["\\\\ ", "/* skip '\\ ' */"],
["[0-9]+\\.?", 'return "INT"'],
["([0-9]+)?\\.[0-9]+", 'return "FLOAT"'],
["\\*\\*", 'return "^"'],
["\\*", 'return "*"'],
["\\\\cdot|\u00b7", 'return "*"'],
["\\\\times|\u00d7", 'return "*"'],
["\\\\ast", 'return "*"'],
["\\/", 'return "/"'],
["\\\\div|\u00F7", 'return "/"'],
["-", 'return "-"'],
["\u2212", 'return "-"'], // minus
["\\+", 'return "+"'],
["\\^", 'return "^"'],
["\\(", 'return "("'],
["\\)", 'return ")"'],
["\\\\left\\(", 'return "("'],
["\\\\right\\)", 'return ")"'],
["\\[", 'return "["'],
["\\]", 'return "]"'],
["\\{", 'return "{"'],
["\\}", 'return "}"'],
["\\\\left\\{", 'return "{"'],
["\\\\right\\}", 'return "}"'],
["_", 'return "_"'],
["\\|", 'return "|"'],
["\\\\left\\|", 'return "LEFT|"'],
["\\\\right\\|", 'return "RIGHT|"'],
["\\!", 'return "!"'], // not yet interpreted
["<=|>=|<>|<|>|=", 'return "SIGN"'],
["\\\\le", 'yytext = "<="; return "SIGN"'],
["\\\\ge", 'yytext = ">="; return "SIGN"'],
["\\\\leq", 'yytext = "<="; return "SIGN"'],
["\\\\geq", 'yytext = ">="; return "SIGN"'],
["=\\/=", 'yytext = "<>"; return "SIGN"'],
["\\\\ne", 'yytext = "<>"; return "SIGN"'],
["\\\\neq", 'yytext = "<>"; return "SIGN"'],
["\u2260", 'yytext = "<>"; return "SIGN"'], // ne
["\u2264", 'yytext = "<="; return "SIGN"'], // le
["\u2265", 'yytext = ">="; return "SIGN"'], // ge
["\\\\frac", 'return "FRAC"'],
["\\\\dfrac", 'return "FRAC"'],
["sqrt|\\\\sqrt", 'return "sqrt"'],
["abs|\\\\abs", 'return "abs"'],
["ln|\\\\ln", 'return "ln"'],
["log|\\\\log", 'return "log"'],
["sin|cos|tan", 'return "TRIG"'],
["csc|sec|cot", 'return "TRIG"'],
["sinh|cosh|tanh", 'return "TRIG"'],
["csch|sech|coth", 'return "TRIG"'],
["\\\\sin", 'yytext = "sin"; return "TRIG"'],
["\\\\cos", 'yytext = "cos"; return "TRIG"'],
["\\\\tan", 'yytext = "tan"; return "TRIG"'],
["\\\\csc", 'yytext = "csc"; return "TRIG"'],
["\\\\sec", 'yytext = "sec"; return "TRIG"'],
["\\\\cot", 'yytext = "cot"; return "TRIG"'],
["\\\\arcsin", 'yytext = "arcsin"; return "TRIG"'],
["\\\\arccos", 'yytext = "arccos"; return "TRIG"'],
["\\\\arctan", 'yytext = "arctan"; return "TRIG"'],
["\\\\arccsc", 'yytext = "arccsc"; return "TRIG"'],
["\\\\arcsec", 'yytext = "arcsec"; return "TRIG"'],
["\\\\arccot", 'yytext = "arccot"; return "TRIG"'],
["arcsin|arccos|arctan", 'return "TRIGINV"'],
["arccsc|arcsec|arccot", 'return "TRIGINV"'],
["\\\\sinh", 'yytext = "sinh"; return "TRIG"'],
["\\\\cosh", 'yytext = "cosh"; return "TRIG"'],
["\\\\tanh", 'yytext = "tanh"; return "TRIG"'],
["\\\\csch", 'yytext = "csch"; return "TRIG"'],
["\\\\sech", 'yytext = "sech"; return "TRIG"'],
["\\\\coth", 'yytext = "tanh"; return "TRIG"'],
["pi", 'return "CONST"'],
["\u03C0", 'yytext = "pi"; return "CONST"'], // pi
["\\\\pi", 'yytext = "pi"; return "CONST"'],
["theta", 'return "VAR"'],
["\u03B8", 'yytext = "theta"; return "VAR"'], // theta
["\\\\theta", 'yytext = "theta"; return "VAR"'],
["phi", 'return "VAR"'],
["\u03C6", 'yytext = "phi"; return "VAR"'], // phi
["\\\\phi", 'yytext = "phi"; return "VAR"'],
["[a-zA-Z]", "return yy.symbolLexer(yytext)"],
["$", 'return "EOF"'],
[".", 'return "INVALID"'],
],
options: {
flex: true // pick longest matching token
}
flex: true, // pick longest matching token
},
},

@@ -110,56 +112,65 @@ operators: [

["left", "UMINUS"],
["right", "^"]
["right", "^"],
],
start: "equation",
bnf: {
"equation": [
equation: [
["expression SIGN expression EOF", "return new yy.Eq($1, $2, $3);"],
["expression EOF", "return $1;"],
["EOF", "return new yy.Add([]);"]
["EOF", "return new yy.Add([]);"],
],
"expression": [
["additive", "$$ = $1;"]
expression: [["additive", "$$ = $1;"]],
additive: [
[
"additive + multiplicative",
"$$ = yy.Add.createOrAppend($1, $3);",
],
[
"additive - multiplicative",
'$$ = yy.Add.createOrAppend($1, yy.Mul.handleNegative($3, "subtract"));',
],
["multiplicative", "$$ = $1;", {prec: "+"}],
],
"additive": [
["additive + multiplicative", "$$ = yy.Add.createOrAppend($1, $3);"],
["additive - multiplicative", "$$ = yy.Add.createOrAppend($1, yy.Mul.handleNegative($3, \"subtract\"));"],
["multiplicative", "$$ = $1;", {prec: "+"}]
],
"multiplicative": [
multiplicative: [
// the second term in an implicit multiplication cannot be negative
["multiplicative triglog", "$$ = yy.Mul.fold(yy.Mul.createOrAppend($1, $2));"],
["multiplicative * negative", "$$ = yy.Mul.fold(yy.Mul.createOrAppend($1, $3));"],
["multiplicative / negative", "$$ = yy.Mul.fold(yy.Mul.handleDivide($1, $3));"],
["negative", "$$ = $1;"]
[
"multiplicative triglog",
"$$ = yy.Mul.fold(yy.Mul.createOrAppend($1, $2));",
],
[
"multiplicative * negative",
"$$ = yy.Mul.fold(yy.Mul.createOrAppend($1, $3));",
],
[
"multiplicative / negative",
"$$ = yy.Mul.fold(yy.Mul.handleDivide($1, $3));",
],
["negative", "$$ = $1;"],
],
"negative": [
negative: [
["- negative", "$$ = yy.Mul.handleNegative($2);", {prec: "UMINUS"}],
["triglog", "$$ = $1;"]
["triglog", "$$ = $1;"],
],
"trig": [
["TRIG", "$$ = [yytext];"]
],
"trigfunc": [
trig: [["TRIG", "$$ = [yytext];"]],
trigfunc: [
["trig", "$$ = $1;"],
["trig ^ negative", "$$ = $1.concat($3);"],
["TRIGINV", "$$ = [yytext];"]
["TRIGINV", "$$ = [yytext];"],
],
"logbase": [
logbase: [
["ln", "$$ = yy.Log.natural();"],
["log", "$$ = yy.Log.common();"],
["log _ subscriptable", "$$ = $3;"]
["log _ subscriptable", "$$ = $3;"],
],
"triglog": [
triglog: [
["trigfunc negative", "$$ = yy.Trig.create($1, $2);"],
["logbase negative", "$$ = yy.Log.create($1, $2);"],
["power", "$$ = $1;"]
["power", "$$ = $1;"],
],
"power": [
power: [
["primitive ^ negative", "$$ = new yy.Pow($1, $3);"],
["primitive", "$$ = $1;"]
["primitive", "$$ = $1;"],
],
"variable": [
["VAR", "$$ = yytext;"]
],
"subscriptable": [
variable: [["VAR", "$$ = yytext;"]],
subscriptable: [
["variable _ subscriptable", "$$ = new yy.Var($1, $3);"],

@@ -171,27 +182,31 @@ ["variable", "$$ = new yy.Var($1);"],

["{ additive }", "$$ = $2.completeParse();"],
["( additive )", "$$ = $2.completeParse().addHint('parens');"] // this probably shouldn't be a hint...
["( additive )", "$$ = $2.completeParse().addHint('parens');"], // this probably shouldn't be a hint...
],
"function": [
["FUNC", "$$ = yytext;"]
],
"invocation": [
function: [["FUNC", "$$ = yytext;"]],
invocation: [
["sqrt ( additive )", "$$ = yy.Pow.sqrt($3);"],
["sqrt { additive }", "$$ = yy.Pow.sqrt($3);"],
["sqrt [ additive ] { additive }", "$$ = new yy.Pow.nthroot($6, $3);"],
[
"sqrt [ additive ] { additive }",
"$$ = new yy.Pow.nthroot($6, $3);",
],
["abs ( additive )", "$$ = new yy.Abs($3);"],
["| additive |", "$$ = new yy.Abs($2);"],
["LEFT| additive RIGHT|", "$$ = new yy.Abs($2);"],
["function ( additive )", "$$ = new yy.Func($1, $3);"]
["function ( additive )", "$$ = new yy.Func($1, $3);"],
],
"primitive": [
primitive: [
["subscriptable", "$$ = $1;"],
["invocation", "$$ = $1;"],
["FRAC { additive } { additive }", "$$ = yy.Mul.handleDivide($3, $6);"]
]
}
[
"FRAC { additive } { additive }",
"$$ = yy.Mul.handleDivide($3, $6);",
],
],
},
};
var prelude = "// This is a @gene" + "rated file\n" +
"import _ from \"underscore\";\n\n";
var parser = (new jison.Generator(grammar)).generate({moduleType: "js"});
var prelude =
"// This is a @gene" + "rated file\n" + 'import _ from "underscore";\n\n';
var parser = new jison.Generator(grammar).generate({moduleType: "js"});
// NOTE(jeresig): We need to comment out these two labels as they appear to be

@@ -202,3 +217,6 @@ // invalid ES5 (they also aren't referenced anywhere so this seems safe).

fs.writeFileSync(path.resolve(__dirname, "__genfiles__", "parser.js"), prelude + parser + postlude);
fs.writeFileSync(
path.resolve(__dirname, "__genfiles__", "parser.js"),
prelude + parser + postlude,
);

@@ -209,3 +227,7 @@ var unitPrelude = "// this is a @gene" + "rated file\n\n";

var unitParserInfile = path.resolve(__dirname, "unitvalue.jison");
var unitParserOutfile = path.resolve(__dirname, "__genfiles__", "unitparser.js");
var unitParserOutfile = path.resolve(
__dirname,
"__genfiles__",
"unitparser.js",
);

@@ -218,3 +240,5 @@ var unitParserSource = fs.readFileSync(unitParserInfile);

generatedParser = generatedParser.replace(/(_token_stack:)/g, "//$1");
fs.writeFileSync(unitParserOutfile,
unitPrelude + generatedParser + unitEpilogue);
fs.writeFileSync(
unitParserOutfile,
unitPrelude + generatedParser + unitEpilogue,
);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc