The JavaScript blog.


maths angularjs react

From AngularJS to React, Math.js 1.0

Posted on .

From AngularJS to React: The Isomorphic Way

Gergely Nemeth sent in From AngularJS to React: the isomorphic way, which outlines how his company used React, Flux, and Koa to reuse code in the browser and on the server. The server-side code is capable of generating a Flux-React application instance and then rendering views.

The browser loads the same code (built with Browserify/Webpack) and bootstraps the application from the shared state. (shared by the server and injected into the global/window scope). This means that our application can continue from the point where the server has finished.

It seems like a lot of people struggle to share code this way, so it's interesting to see how the author's Angular experiences compared with React.

Math.js 1.0

Jos de Jong sent us an email to say Math.js has been updated to version 1.0. The project now has more tests and BigNumber support.

There are more examples so you can see cool features like chained operators and function transforms.

You can create BigNumbers with strings, like this:

  number: 'bignumber',
  precision: 20 // Number of significant digits for BigNumbers

math.bignumber('1.2e+500');  // BigNumber, 1.2e+500  

Jos is working on some new features, including derived units (like km/h, kg*m/s^2), and performance improvements. He also wanted to thank the JavaScript community for helping with the project:

I want to thank the community for all valuable and constructive feedback and discussions. Without them, I don't think we would have had an API so elegant and consistent as it is now. I'm looking forward to the coming period, implementing more great features, making math.js better and better.


libraries node maths


Posted on .


Cytoscape.js (GitHub: cytoscape / cytoscape.js, License: LGPL, npm: cytoscape), developed at the Donnelly Centre at the University of Toronto by Max Franz, is a graph library that works with Node and browsers. This library is for working with "graphs" in the mathematical sense -- interconnected sets of nodes connected by edges.

The API uses lots of sensible JavaScript idioms: it's event-based, functions return objects so calls can be chained, JSON definitions of elements can be used, and nodes can be selected with selectors that are modelled on CSS selectors and jQuery's API. That means you can query a graph with something like this: cy.elements('node:locked, edge:selected').

Styling graphs is also handled in a natural manner:

Graph style and data should be separate, and the library should provide core functionality with extensions adding functionality on top of the library.

Max and several contributs have been working on the project for two years now, so it's quite mature at this point. The project comes with detailed documentation, a build script, and a test suite written with QUnit.


frameworks libraries ui mobile maths

LungoJS, Math.js, Collage

Posted on .



LungoJS (GitHub: TapQuo / Lungo.js, License: GPLv3) from TapQuo is a framework for HTML5 apps that aims to be cross-device. It supports mobile, desktop, and TV devices. The JavaScript API has support for working with the DOM, localStorage, caching, navigation routing, remote services, and views.

There's a designer-focused tutorial that explains how to create an application with Lungo, and a Google group (which currently requires permission to join).


Math.js (GitHub: josdejong / mathjs, License: Apache 2.0, npm: mathjs, bower: mathjs) by Jos de Jong is a maths library for client-side JavaScript and Node. It supports complex numbers, units, strings, arrays, and matrices, built-in functions and constants, as well as mathematical expression parsing.

It has no dependencies and is compatible with the built-in Math library. One feature I particularly like is the expression parser:

var parser = math.parser();  
parser.eval('1.2 / (2.3 + 0.7)'); // 0.4  
parser.eval('a = 5.08 cm');  
parser.eval('a in inch');         // 2 inch  
parser.eval('sin(45 deg) ^ 2');   // 0.5  

This opens up some interesting possibilities for storing mathematical expressions in databases then safely evaluating them later on.

The project includes unit tests, and detailed documentation can be found in the readme file.


Collage (GitHub: ozanturgut / collage, License: Apache 2.0) by Ozan Turgut is a framework for creating interactive collages. It can knit together remote APIs then present media in a two-dimensional space.

This example demonstrates some of the APIs that are supported as standard:

var collage = Collage.create(document.getElementById('PopcornCollage'));  
collage.load('popcorn media', {  
  flickr: [{ tags: 'popcorn'}],
  googleNews: ['popcorn'],
  twitter: [{ query: 'popcorn' }]
  collage.start('popcorn media');


libraries date screencasts time maths backbone.js

Backbone.js Screencasts, XDate, JavaScript BigInteger Library

Posted on .

Backbone.js Screencasts

Backbone.js Screencasts is a commercial set of
Backbone.js tutorials from 30 Cubits that costs \$9 (until November 9th, then \$18 thereafter) for 106 minutes of videos. The videos cover the
core Backbone.js functionality like views, routers, events, models,
collections, and also how to use other JavaScript techniques alongside
your Backbone.js code.

There's a preview of the content on Vimeo here: Backbone.js Quickly -


XDate (GitHub: arshaw / xdate, License: dual MIT and GPL)
by Adam Shaw is a wrapper around Date that provides
improved date parsing, formatting, and manipulation. XDate format
really help with
formatting dates, which I find myself doing a lot lately in Node or
single page applications.

Here's an example of XDate's formatting method:

new XDate(2011, 0, 1, 6, 0).toString('d/M/yy h(:mm)TT');

Another useful feature of this library is the set of XDate diffing
. They provide a friendly API
around date subtraction.

Most of XDate's methods return an XDate, so it's chainable

d1 = new XDate();
d2 = d1.clone()

JavaScript BigInteger Library

The JavaScript BigInteger Library
(GitHub: silentmatt / javascript-biginteger,
License: MIT) by Matthew Crumley is a BigInteger library for
JavaScript. The author has written detailed blog posts on how the
library works and the algorithms behind it:

If you look at the source, you'll probably notice that I'm actually using base 10000000, not base 10. I'm using decimal in these examples because it makes things clearer but everything works pretty much exactly the same way in any base. Using a larger base just makes things more efficient because you get 7 digits in each array entry.

Matthew created this library to support his Google Chrome Scientific


server cli node database maths

Node Roundup: bigint, mingy, kyoto-client, Blagovest's NPM Search

Posted on .


bigint by James Halliday is an arbitrary precision arithmetic library for Node. Large integers can
be defined with strings, then manipulated with the library's methods:

var bigint = require('bigint');

var b = bigint('782910138827292261791972728324982')

Note that there's also a destroy method:

Destroy a bigint. This module is using node-ffi so I can't hook onto the GC easily. You only need to call this if you're creating bigints in a loop.

Other methods include rand, pow, and more.
This library can be installed with npm install bigint.

I actually have some experience in working with arbitrary precision
arithmetic from back in my university days -- I wrote a distributed
fractal generator with various numerical libraries. In Ada... This
sounds like a lot more fun!


I like writing CLI stuff, so I thought
Mingy by Mike Cantelon sounded pretty cool. He describes it as a "cheap and cheerful command
parser/server for node.js", perfect for creating command-line tools,
text adventure games, and even MUDs.

It can run as a server (hence the MUD reference), copes with multiple
users, includes validation support, and even has Expresso tests.


kyoto-client (GitHub: wezm / kyoto-client, BSD License) by
Wesley Moore is a Kyoto Tycoon client
library. Kyoto Tycoon is a lightweight database server, from FAL Labs,
who also created the older Tokyo Cabinet key value database.

The kyoto-client module has some good documentation on the site and
seems straightforward to use. It can be installed with npm install

Blagovest's NPM Search

Blagovest's NPM Search by Blagovest Dachev is a convenient (and fast) way to browse npm. In fact, it's
exactly the kind of thing I need to find things to write about for
DailyJS. Thanks Blagovest!