140 Commits

Author SHA1 Message Date
Ramesh Vijayaraghavan
c7f4c53483
Support for Percentage Operation (#2304)
* Support for Percentage Operation

* Fixed Style issue

* Added Test case to check for modulo followed by pi

* Support for % addition and % subtraction

* Fixed Documentation comment

* Support - Should not calculate mod for negative divisor

* Updated Docs

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2021-09-22 11:45:37 +02:00
CRIMX
fe7d8a7100
docs(expressions): fix incorrect example link (#2273) 2021-07-07 08:28:01 +02:00
Jos de Jong
8b3e0e1067 Fix #2255: document the implicit property of OperatorNode 2021-06-23 10:02:33 +02:00
jhugman
e80995d52d
Add support for scopes with get and set methods (#2166)
* Add support for scopes with get and set methods

* Fix build for node v12

* Fixup cli and parser tests

* Add tests for simplify and evaluate

* Add example for a custom scope object

* Function calls need child scopes

* Transitionary step: Separate Safe and Scope Property calls

* Renamed identifiers in FunctionNode

* Evaluate with ObjectScopeWrapper

* Simplify tests passing

* Assume all scopes are map-like. Except parser

* Remove isMapLike check in customs.*SafeProperty() methods

* Change MapLike to Map

* Move keywords from an Object to a Set

* Move ScopeProperty functions in to scope.js

* Removed deprecation warning

* Rename scope.js to map.js

* Rename ScopeProperty to MapProperty

* Add tests and docs for map.js

* Put back the micro-optimization of function calls

* Use Map in the parser

* Called scope methods directly in cli.js

* Coercing of scope into a Map is done in Node, not evaluate

* Move createSubScope to its own file

* Fixup following self-review

* Add scope docs

* Final self-review changes

* Address reviewer comments

* Remove MapProperty witness marks

* Converted broken benchmark possibly lost in a rebase

* Use bare map as scope in benchmark

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2021-05-16 13:33:01 +02:00
Colin Holzman
90e15c6d95
Support for parsing non decimal numbers with radix point (#2122)
* Basic untested support for parsing non decimal numbers with radix point.

* Added some documentation for function parseNonDecimalWithRadix.

* Renamed variable in BigNumber constructor.

Not related to current feature branch but is a good change.

* Improved some variable and function names in number.js and fixed an error when parsing octal numbers with radix point.

* Added some tests and fixed linter issues.

* Added some documentation on new syntax.

* Added more tests.

* Added more tests for edge cases.
2021-03-10 09:01:08 +01:00
Colin Holzman
d12f3a5fac
Word size suffix and BigNumber support for bin oct hex literals (#1996)
* added support for word size suffix in getToken

* start modifying number(string) to support word size suffix for signed integers

* word size suffixes for Number

* initial support for BigNumber

* fix linter issues

* remove unused variable

* start extending bitwise operators for Number for values greater than 32 bits

* Revert "start extending bitwise operators for Number for values greater than 32 bits"

This reverts commit 6fac1a7b10665a221ab5de521c08fa9fcf959eb1.

* add a test for 53 bit literal

* added an optional second argument to bin, oct, and hex to allow formatting signed numbers with custom word size

* removed size checks

* Attempted to extend bin, oct, hex format functions to work with BigNumber, but not working fully.

Apparently Decimal.js toString method doesn't take a base parameter like js number does. I guess I have to do the formatting myself.

* Added n2base function to do formatting for BigNumber.

* Added check for zero in n2base.

* Removed old failing tests.

* Added some tests (failing).

* Extended 'format' function with 'base' and 'wordSize' options and changed 'bin', 'oct', and 'hex' to use 'format' function.

* Fixed lint issues.

* Fixed issues related to the merge.

* Corrected a test.

* Fixed bignumber formatter.

* Added tests for math.format with 'base' and 'wordSize' options.

* Fixed lint issue.

* Changed 'base' option to 'bin', 'oct', and 'hex' values for 'notation' option of 'format' function.

* Added word size suffix to the output of format, bin, oct, and hex.

* Updated documentation.
2021-01-06 09:46:58 +01:00
Colin Holzman
f5d843bbc6
Binary, octal, and hexadecimal literals and formatting (#1968)
* allow binary, octal, and hex literals as in JS (0b, 0o, 0x)

* add tests

* fix lint issues

* add notation for binary, octal, and hex in formatNumber

* remove the extra format notations

* add bin, oct, and hex functions for formatting

* move bin, oct, and hex from base.js to their own files, fixed built test error about documentation

* parse and format treat values as 32 bit signed 2s complement integers

* add section in syntax documentation

* typo

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2020-09-26 17:45:10 +02:00
josdejong
e9cf247c7d Fix #1902: typo in an example in the documentation 2020-07-03 08:29:15 +02:00
josdejong
ca6aa45a88 Fix typo 2020-06-28 22:14:44 +02:00
josdejong
2df28bb609 Fix #1899: documentation on expression trees still using old namespace
`math.expression.node.*` instead of `math.*`
2020-06-28 22:14:27 +02:00
jos
3153de27ee Clarify the documentation on scope when using rawArgs, see #1055 2020-04-04 17:24:36 +02:00
Tanmay
4c5aa0d23e toHTML() method example corrected. (#1627) 2019-09-21 14:56:10 +02:00
0xflotus
71a02f3164 fixed vulnerabilities (#1583) 2019-07-31 19:27:02 +02:00
jos
a602a38340 Updated docs for v6 2019-05-20 21:42:49 +02:00
jos
b4f2eb005e Merge remote-tracking branch 'origin/fix/1428' into develop
# Conflicts:
#	HISTORY.md
#	src/function/algebra/simplify.js
2019-05-04 10:07:39 +02:00
jos
6081360d6a Merged develop into modular_architecture 2019-04-13 16:51:51 +02:00
jos
5c263d3dff Fixed #1428: transform iterating over replaced nodes 2019-03-05 21:10:59 +01:00
jos
70cbc3ec30 Replace http urls with https where supported 2019-02-27 13:08:42 +01:00
jos
25be459ed3 Merge math.expression.parse into math.parse 2019-02-03 20:30:43 +01:00
jos
078f1dd69f Renamed methods .eval to .evaluate, updated all docs and examples accordingly 2019-01-16 10:11:32 +01:00
Eric Mansfield
d23d8c71a4 Chained conditionals (#1267)
* Minimally working

* Added tests, toString

* Added tests for evaluation

* Minor changes

* Added a line in the docs about chained conditionals

* Documentation, replacing var and let with const
2018-10-04 20:26:39 +02:00
Mathias Rasmussen
346eb37e40 Fix parse example (#1231) 2018-09-03 20:21:11 +02:00
jean-emmanuel
710ed1e58f Add support for single quotes strings 2018-08-04 10:27:10 +02:00
jos
8e18a2bd0a Document rationalize in the Algebra section of the docs 2018-07-14 11:06:11 +02:00
Daniel Kostro
f396f2d3fa fix some broken links 2018-07-08 10:08:32 +02:00
jos
8b5eb89a02 Minor tweaks in the docs 2018-06-16 14:57:28 +02:00
jos
b6b36bfd9b Use strict equality checks everywhere (=== and !==) 2018-06-13 15:02:21 +02:00
jos
b3b96749bf Refactored var into const/let, and removed a lot of semicolons 2018-06-13 12:21:14 +02:00
jos
cf5c1c1af8 Fixes #1054: renamed eye to identity 2018-06-06 10:52:08 +02:00
jos
6613f1c844 Release the second release candidate 4.0.0-rc.2 2018-02-21 11:36:43 +01:00
jos
99ab11b234 Dropped constant uninitialized 2018-02-04 13:09:09 +01:00
Jos de Jong
cdda817d9f
Merge pull request #1036 from ericman314/implicit-multiplication
Implicit multiplication
2018-02-04 11:55:15 +01:00
Eric Mansfield
e0b8640ab4 Added more examples for implicit multiplication 2018-02-03 14:26:04 -07:00
Eric Mansfield
cd5381a64f Minor formatting 2018-02-03 11:39:37 -07:00
Eric Mansfield
3f62bd9ebd Finished docs 2018-02-03 11:32:17 -07:00
Eric Mansfield
260bb8d823 Halfway done with docs 2018-02-03 11:01:10 -07:00
jos
82b41e696a - Implemented OperatorNode.isUnary and OperatorNode.isBinary.
- Explicit checks for number of arguments everywhere working with `OperatorNode` and `FunctionNode`.
- Fixed #1014: derivative silently ignoring additional arguments.
2018-01-31 11:00:39 +01:00
jos
ae8f61a84b Merge branch 'v4_constant_node' into v4_binary_operator_node 2018-01-31 10:07:10 +01:00
jos
a00b333e00 Fixed some broken links and an example output 2018-01-27 17:18:47 +01:00
jos
924299c42b Changed ConstantNode(valueStr, valueType) to ConstantNode(value) (breaking change) 2018-01-23 12:08:29 +01:00
denisx
b5729262af
Fix Bitwise xor sample result 2018-01-12 21:50:45 +03:00
jos
e7766e4468 Replaced examples resulting in round-off errors to prevent confusion (see #910) 2017-08-02 20:02:51 +02:00
jos
469e6bf3cf Fixed #895: added support for the dollar character $ in symbol names 2017-07-10 20:29:30 +02:00
Nekomajin42
7301b6fcf9 Implement toHTML() to Nodes
toHTML() method to each Node, and update in the docs
2017-05-21 15:47:43 +02:00
jos
be913efa29 Added docs and example on making the expression parser less vulnerable 2017-05-12 12:15:46 +02:00
jos
34f948f808 Fixed an issue in a code example in the docs 2017-04-22 12:56:56 +02:00
jos
ee6efa3768 Only allow accessing/assigning properties on plain objects. Only allow calling known methods. 2017-04-08 15:32:10 +02:00
jos
04cbd0c0b1 Added a section on how to report security issues 2017-04-02 20:08:48 +02:00
jos
52462a8e29 Released v3.10.2 2017-03-31 10:26:04 +02:00
jos
2f45600905 Fixed a security vulnerability in the expression parser allowing execution of arbitrary JavaScript 2017-03-31 10:18:14 +02:00