November 4th, 2010 – by Kris Zyp
The CommonJS AMD proposal defines an elegant, simple API for declaring modules that can be used with synchronous or asynchronous script-tag based loading in the browser. RequireJS already implements this API, and Dojo will soon have full support as well. The API for defining modules is as simple as:
define(, , );
This simple API can be used in a variety of different ways for different situations.
Continue reading
Tags: Dojo, nodejs, nodules, Persevere, RequireJS, transporter
Posted in CommonJS, Dojo, JavaScript | 14 Comments
September 21st, 2010 – by Kris Zyp
Patr (Promise-based Asynchronous Test Runner) is a simple lightweight cross-platform test runner for promised-based applications. Patr executes tests by simply executing functions of an object and is intended to be used in combination with the “assert” module (which is available on NodeJS and Narwhal), so tests can be as simple as:
var assert = require("assert");
tests = {
testSomething: function(){
assert.eq(3, 3);
}
}
require("patr/runner").run(tests);
Continue reading
Tags: Dojo, narwhal, nodejs, unit testing
Posted in CommonJS, Persevere | No Comments
September 20th, 2010 – by Kris Zyp
Promises are a well-established mechanism for modeling future or asynchronous actions. Promises allow asynchronicity while maintaining the core programming principles of composability and encapsulation. Writing asynchronous code in JavaScript can often be a confusing exercise due to the extensive need for callbacks, but promises help to define composable units of asynchronicity to encapsulate actions and reliably separate caller and callee’s concerns.
Promised-IO
Promised-IO utilizes promises as an abstraction for I/O operations on top of Node, Narwhal/Rhino, and the browser (where possible). This serves two purposes. First, this package provides the benefits of promise usage: clean separation of concerns and proper encapsulation of eventual values. Second, Promised-IO provides a consistent normalized interface for I/O that will work on multiple platforms without sacrificing any of the advantages of asynchronous I/O, making it easy to build modules that can be used by developers on many platforms.
Continue reading
Tags: and Persevere 2.0, narwhal, node, nodejs, pintura, Server-Side JavaScript
Posted in CommonJS, Persevere | 11 Comments
July 19th, 2010 – by Kris Zyp
Node is a server-side JavaScript platform that is known for being well suited for Comet-style applications that utilize long-lived connections to allow applications to send messages from the server to the browser asynchronously. In fact, the beginning of the front page of nodejs.org starts out with an example of a web application that delays for a couple seconds before sending a response without any type of blocking; the code is asynchronous and efficient.
However, building a real-life real-time application involves more than just a platform that gives you asynchronous communication, there are a number of other important techniques to understand. We will look at these techniques and introduce project Tunguska that provides some helpful tools to assist in building applications. While a number of Comet projects out there attempt to provide a black box solution to Comet, Tunguska recognizes that most real-time applications involve deep integration into the application and its security, messaging, and data structures. Consequently Tunguska is a set of tools for building real-time applications rather than a closed black box that can’t easily be integrated with. Let’s look at some of these tools.
Continue reading
Tags: comet, jack, narwhal, nodejs, tunguska
Posted in CommonJS, Persevere | 3 Comments