The JavaScript blog.


libraries modules timers api

Parrot, Flush Timeouts

Posted on .


Parrot (GitHub: sailorjs/parrotjs, License: MIT, Bower: parrotjs) by Kiko Beats is a library for wrapping API calls to your server. You can register different environments, which makes it easy to switch between development and production. You can also register URLs with different protocols, so it's possible to make WebSocket or Ajax requests.

It has a fluent API, so you can chain calls. If you wanted to register your production and development servers, then you'd call endpoint.add:

  .add(name: 'development', url: 'http://localhost:3000')
  .add(name: 'production', url: 'http://example.com')

Specific API URLs can be added as well:

  .add(name: 'signup', path: 'user', method: 'post')
  .add(name: 'login', path: 'user/login', method: 'post');

Making an Ajax request to the signup route would just be parrot.ajax('signup', function(err, res) {.

This seems preferable to some client-side HTTP APIs. The author intended it to be used with Sails.js, but you could use it with other frameworks as well.


I've noticed a few libraries recently that aim to improve the JavaScript timer API. Alex Lawrence sent in flush-timeout (GitHub: efacilitation/flush-timeouts, License: MIT, Bower: flush-timeouts, npm: flush-timeouts), a module for overriding setTimeout.

Here's a quick example:


var i = 0;

function demo() {  
  console.log('i:', i);

setTimeout(demo, 500);  
setTimeout(demo, 1000);  
setTimeout(demo, 1500);



This will cause demo to immediately run three times, and then print Done. If you removed global.flushTimeouts then it would execute based on the delays passed to setTimeout.

flush-timeouts might be useful when you're trying to queue up tasks with setTimeout but have additional logic that determines if it's safe to run all the tasks at once. Or perhaps you've got tests for code that depends on setTimeout and don't want to wait. The author has supplied tests and build scripts so you can pick it apart to see how it works.


speech github storage chrome api

Speech Router, Botdylan, Google Cloud Storage

Posted on .

Speech Router

Speech Router (GitHub: lukasolson / speech-router, License: MIT) is a router that wraps around Chrome's Web Speech API. It's based around a constructor function that accepts a routes object:

new SpeechRouter({  
  routes: {
    'search google for *query': function(query) {
      window.open('https://google.com/search?q=' + query);

If you haven't seen the Web Speech API before, it's worth checking out. At least the results seem quite good with my accent and Chrome -- your mileage may vary!


Botdylan (GitHub: botdylan / botdylan, License: MIT) by Pau Ramon is a Hubot-inspired GitHub automation system:

We use GitHub heavily. There are some repetitive tasks that were taking away our time to hack on a better product. Since we are in the productivity space we decided to stop doing things manually and start to have a more productive environment to work with.

It can do things like add labels to issues based on events, integrate with a CI server, talk to chat rooms, and so on. It runs as a daemon, and can execute tasks periodically in the background.

Google Cloud Storage

Google Cloud Storage, sent in by Jonathan Simon, is a screencast that demonstrates a JavaScript application that talks to Google's Cloud Storage platform. The source code is here: storage-getting-started-javascript.

This demonstration covers getting started with Google Cloud Storage using JavaScript. See the process of setting up the sample application, running the sample and using it to try out Cloud Storage API commands like 'list buckets'.


frameworks libraries graphics node api

OrganicJS, HALbert, BromBone

Posted on .


OrganicJS (GitHub: idibidiart / organicjs) by Marc Fawzi is a reusable component framework, which combines ideas from the author's previous work with D3.js. It supports chainable properties, dynamic getters and setters, reusable and nestable markup, in-place fragment cloning and rendering, and decoupled data/behaviour sharing across components.

The project is currently in an early state, without much documentation or tests, but Marc is looking for feedback on the project. If you want to try it out, the best way to get started is by looking at the OrganicJS demo site.


HALbert (GitHub: xcambar / halbert, License: MIT, npm: halbert) by Xavier Cambar is a HAL-JSON parser:

There is an emergence of non-HTML HTTP applications ("Web APIs") which use hyperlinks to direct clients around their resources.

The JSON Hypertext Application Language (HAL) is a standard which establishes conventions for expressing hypermedia controls, such as links, with JSON [RFC4627].

HAL is a generic media type with which Web APIs can be developed and exposed as series of links. Clients of these APIs can select links

It can be used as a Node module or in browsers, through Browserify. The author has designed it to work pretty much anywhere in your application's stack: Express middleware, or in client-side frameworks like Backbone or AngularJS.


Although PhantomJS is extremely useful, there are times when you don't want to include the dependency in a server-side project. I've considered making my own mini REST services for such cases, so the "heavier" dependencies like PDF generation or PhantomJS are split off into their own self-contained projects. But why bother building such services at all? Surely there are suitable APIs that can be used from services like Heroku and Nodejitsu?

Enter BromBone, by Chad DeShon. BromBone is a web service for PhantomJS, with a simple API and reasonable pricing. It currently allows a page to be rendered as a PNG with an optional delay, and can also run JavaScript on a page. Chad only released the project recently so he's looking for new users to try it out.