The JavaScript blog.


mathematics node

Crunch, NodeRT

Posted on .


Crunch (GitHub: vukicevic / crunch, License: MIT) by Nenad Vukicevic is an arbitrary-precision integer arithmetic library, with a focus on speed. It has no dependencies, and the project includes examples for finding prime-numbers, generating keys for RSA, encryption, and decryption.

The examples also demonstrate using WebWorkers with the library, so you could farm out mathematical operations to multiple workers. Crunch includes unit tests and documentation in the readme file.


NodeRT is a WinRT module generator for Node:

NodeRT automatically exposes Microsoft's WinRT APIs to Node.js by generating Node modules. This enables Node developers to write code that consumes native Windows capabilities. The generated APIs are (almost) the same as the WinRT APIs listed in MSDN.

This is an example of windows.devices.geolocation:

var geolocation = require('windows.devices.geolocation');  
var locator = new geolocation.Geolocator();

locator.getGeopositionAsync(function(err, res) {  
  if (err) {

  console.info('(', res.coordinate.longitude, ',',  res.coordinate.latitude, ')');

The project has fairly detailed documentation in the readme, including the requirements which includes VisualStudio 2013.


html5 audio mathematics localStorage

Numeric JavaScript, howler.js, depot.js

Posted on .

Numeric JavaScript

Numeric JavaScript (GitHub: sloisel / numeric, License: MIT) by Sébastien Loisel is a library that provides tools for matrix and vector calculations, convex optimisation, and linear programming. This library was sent in by Emil Bay, who uses it for computationally intensive tasks like genetic programming and AI. Emil says it's extremely fast, and the Numeric author has some detailed benchmarks of Numeric with comparisons against Closure and Sylvester.



howler.js (GitHub: goldfire / howler.js, License: MIT) by James Simpson and GoldFire Studios is an audio library that works with Web Audio and HTML5 Audio. Like similar libraries, it can automatically load the right file format for a given browser, but also comes with a bevy of other features as well. It has an event-based API, and methods like fadeIn for handling some of the basic tasks you'll face when working with audio.

It implements a cache pool and automatically fetches the audio files, which explains why it seemed so fast when I played around with the examples. It's implemented without any dependencies, and I noticed the source was consistently formatted and easy to follow.


depot.js (GitHub: mkuklis / depot.js, License: MIT, bower: depot) by Michal Kuklis is a localStorage wrapper that can be used with CommonJS or AMD, but also works with plain-old script tags. To use it, define a store and then call methods on the store's instance:

var todoStore = depot('todos');

todoStore.save({ title: 'todo1' });  
todoStore.updateAll({ completed: false });

// Fetch all:

It comes with Mocha tests which can be run with PhantomJS.


games mathematics webgl errors

tQuery, Catchall, Geometry.js

Posted on .

tQuery Valentine's Day Card

Jerome Etienne, WebGL experimenter and author of the Learning Three.js blog, recently published a WebGL Valentine's Day card tutorial which demonstrates his new library, tQuery (License: MIT). While development on tQuery is still ongoing, it provides a friendly alternative API for WebGL based around chainable calls:

tQuery.createText('tQuery is fun!').addTo(world);

  .moveTo(0, 0)
  .lineTo(1, 1)
  .lineTo(-1, 1)
  .lineTo(0, 0);

As a JavaScript developer, this API appeals to me and results in some surprisingly concise code. The tutorial also includes a screencast which covers the methods used by the Valentine's Day card example in detail.


Catchall (License: MIT) by Craig Condon is an alternative to window.onerror created to aid development by catching all exceptions. To do this, all functions are wrapped, which is why the author recommends using it during development and testing only.

Connect middleware is also included, which allows arbitrary scripts to be wrapped by the catchall module. The project's API allows strings of code to be wrapped by using catchall.wrap, and catchall.load can be called on a source file URL or file system path:

catchall.load('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js', function(err, result) {  
    //do something

catchall.load('/from/fs', function(err, result) {  
    //do something


Geometry.js (License: AOL) by Nijiko Yonskai is a collection of geometry classes used by the author for game development. The following classes are included: Circle, Direction, Rectangle, Vec2d. The vector class in particular seems like something I've found myself writing and rewriting for various WebGL and game-related experiments.

The library includes a rich set of methods, and even aliases mathematical operators:

var v1 = new Vec2d(10, 20)  
  , v2 = new Vec2d(33, 10);

// 43
// 43
// [33, 10]
// [0, 0]


libraries mathematics


Posted on .

MathExt is a JavaScript library for parsing mathematical formulas by Lars Knickrehm. It has a
very advanced and flexible API, allowing configuration over accuracy,
separators, and the radix character. It supports things like hyperbolic
functions, trigonometric functions, and has translations for English and

Loading the required files and performing a calculation looks like this:

    var oMathExt = MathExt.Load();
    oMathExt.Calculate('cos(8) * π');

It's clever enough to get the precedence correct:

oMathExt.Calculate('cos 8 * π');

The scientific-calculator interface shown above can be found in the
project's documentation. It uses
explorercanvas, which means it works in IE too.