0.0.12 • Published 7 years ago

hypercalc v0.0.12

Weekly downloads
2
License
AGPLv3
Repository
github
Last release
7 years ago

Hypercalc

A multi-dimensional, headless JavaScript spreadsheet for the browser or Node.js.

  1. Moderate Size: 67K Raw ES6, 60K Compressed ES6, 11K gzipped ES6, 11k transpiled, minified, gizpped ES5
  2. Zero dependencies.
  3. Multi-dimensional ranges can be flattened for operations like sum and product or left as arrays to support vector and matrix operations.
  4. Single, two, three, and n-dimensional ranges can be created and updated through the use of wildcard matching. No need to modify formulas every time a new sheet is addded.
  5. Extensible with custom functions in as little as one line of code per function.

Why Hypercalc

  1. Computing using a spreasheet approach is often more convenient than using a database.
  2. We got tired of building complex spreasheets that were rigid and fragile with respect to cross sheet or matrix calculations.
  3. We had many situations in which we did not need the front end of a spreadsheet.

Use

Installation

npm install hypercalc

or

grab the browser code from Github

or

use a CDN: https://public.cachegit.com/anywhichway/hypercalc/master/browser/hypercalc.es5.js

Formulas

Hypercalc formulas look similar to those in MS Excel or Google sheets. They start with = followed by a function name and arguments in parentheses.

Hypercalc range specifications are always wrapped in a value selection call as $(range string) or $summary(range string,options). The range string must NOT be quoted and all portions are . delimited. The MS Excel range Sheet1!A1 would be Sheet1.A.1 in Hypercalc.

Range strings support:

1) wild card matching, e.g. *.A.1 matches column A of row 1 on all sheets. 2) literal or conditions, e.g. Sheet1|Sheet3.A.1 matches column A of row 1 on sheets 1 and 3. 3) range matching, e.g. Sheet1|Sheet3.A:D.1 matches columns A through D of row 1 on sheets 1 and 3.

The value selection function, $, returns an array. This can be destructured to pass the results to functions taking multiple arguments, e.g. =sum(...$(*.A.1)). However, most multiple argument functions will also accept an array as the first argument, e.g. =sum($(*.A.1)). This is important for large ranges since exploding the selection will push each element onto the stack which may cause an out of memory error.

The value selection function, $summary can return an array or an object. By default it returns an ordered 3 dimensional array with the min, average, and max of values within the provided range. The options argument is an object with two properties:

  1. result, which can have the value array or object. It defaults to array.

  2. values, which is an array of function names to call on the values within the provided range. It defaults to ['min','average','max']. Functions such as variance and stdev can be added. A return array is ordered the same as the values array. If an object is returned, then the function names are added as properties.

There is much more to say, but Hypercalc is in ALPHA, so be patient.

Functions

The below list covers approximately 70% of Hypercalc functionality. Instructions on how to add functions are after the function list.

We have a lot to document .... bear with us.

Extending Hypercalc

Hypercalc can be reliably extended two ways:

1) At runtime after a spreadsheet has been created.

2) At the source code level using a convention based approach. (Not yet ready for testing).

Runtime Extensions

To add a function to Hypercalc at runtime, simply add it to the functions property of the spreadsheet instance.

const hc = new Hypercalc();
hc.functions.hello = () => "Hello";

const cell = hc.Cell("Welcome","=hello()"); // creates a cell that always contains the message "Hello"

So long as your function can accept arrays as arguments, it can consume the results of $(range string). Dependency tracking and updating will be handled automatically.

Release History (reverse chronological order)

2017-05-20 v0.0.12 ALPHA math.js Fixed corrupt es5 file

2017-05-20 v0.0.11 ALPHA math.js reference was still in package.json. Removed it.

2017-05-19 v0.0.10 ALPHA Removed the use of quotes inside range specifier, i.e. $(range string), so that it is easier to type ranges into spreasheet formulas. The function range('range string') is equivalent, except it takes quotes. The same applies to $summary and summary. Added over 75 unit tests.

2017-05-17 v0.0.9 ALPHA Lost some of the re-architected project structure as code was re-worked to support Unit based calculations. Added interval function. Refined Vector and Matrix.

2017-05-10 v0.0.8 ALPHA Re-architected project structure so each function is a separate file along with a parrallel unit test file. Added lots more unit tests. Added dimensions,invert,isMatrix,isPrime,isVector,nthRoot,random,sign. Documented a number of undocumented functions. Added documentation on extending Hypercalc.

2017-05-08 v0.0.7 ALPHA Mathjs dependency removed. Some trigonometric functions sacrificed along with algebraic solving and unit conversions. dotProduct and dotDivided changed to support industry standard scalar result.

2017-05-07 v0.0.6 ALPHA Added $summary function.

2017-05-06 v0.0.5 ALPHA More unit tests and documentation.

2017-05-05 v0.0.4 ALPHA More unit tests and documentation.

2017-05-04 v0.0.3 ALPHA Started adding unit tests and documentation.

2017-05-03 v0.0.2 ALPHA Cleaned-up directory structure, browserified.

2017-05-03 v0.0.1 ALPHA Initial public release.

License

Dual: AGPLv3 or Commercial

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago