DailyJS

DailyJS

The JavaScript blog.


Tagnpm
Featured

libraries console node apps modules npm iojs

Node Roundup: TJ Steps Down, Node and io.js Performance, Cloud Commander, Blessed

Posted on .

TJ Steps Down

Timothy J Fontaine has stepped down as the leader of the Node project:

Given the strength of its community, I'm confident that Node.js is heading in the right direction. With that said, it's time for me to step back.

The formation of the Node.js Foundation couldn't have happened at a better time in the life of Node.js. I believe this will be the tipping point that cements Node's place in technology. Soon, the foundation will be announcing its first meeting, initial membership, and future plans for Node.js.

The announcement includes details about Julien Gilli's work on the project, who is paid as a full-time developer on Node itself:

Julien has been responsible for the last few releases of Node.js -- both the v0.10 and v0.12 branches.

Thanks to him, we were able to ship v0.12.0 with all our tests passing and on all of our supported platforms. This was the first Node.js release ever to have that feature.

There's also another post on the Node blog by Scott Hammond that reiterates the move towards the Node.js Foundation:

Under the aegis of the Foundation, the Node.js project is entering the next phase of maturity and adopting a model in which there is no BD or project lead. Instead, the technical direction of the project will be established by a technical steering committee run with an open governance model.

That all sounds promising, except most of us just want a Node that has ES6 features without flags and continued updates to the V8 core. Naturally that brings me to io.js which just hit version 2.0.1. This release updates libuv and V8, and has fixes for async-wrap, documentation, and some of the internal C++ in the src/ folder. And you may also remember that the io.js 2.0.x branch has enabled lots of ES6 features without flags.

Node and io.js Performance

Nick Harley sent in Performance Showdown: Node.js vs. io.js v2.0.0:

A 14.8% speedup from Node to the latest version of io.js - certainly worthy of note. If you’re looking at one of the latest generation of JS backend frameworks, it certainly pays to give io.js a look as out-of-the-box you get some rather impressive perf improvements. When running a cluster of VMs using the Node stack, depending on scale, that speedup may result in several fewer boxes needed and correspondingly less infrastructure costs - all for free.

Cloud Commander

Coderaiser sent in Cloud Commander (GitHub: coderaiser/cloudcmd, License: MIT, npm: cloudcmd), a Node app that's been under active development since 2012. It's a file manager that reminded me of a web version of Midnight Commander, and it bundles CodeMirror and Ace so you can edit code with it quite comfortably.

It's built with Express and Socket.IO, and I was pleased to see they're on Express 4.x. The documentation the homepage includes details on how to deploy it with a non-root user for Linux/iptables or nginx.

The web app has a console interface as well, so you can type commands rather than using the web GUI.

Blessed and Blessed-Contrib

A colleague kept telling me how good Blessed-Contrib was, and I've only briefly mentioned Blessed on DailyJS before so I wanted to mention it. The attached gif illustrates why. Blessed is a curses-like library, but it has a very high-level API that I find much easier to understand than most terminal GUI libraries.

However, the magic really happens when you get blessed-contrib:

Blessed-Contrib

I've been waiting for something like this for years but never found a high-level scripting language library good enough to make my 1980s Unix console UI fantasies come true. Now I can finally bring to life my W.O.P.R version of our status dashboard!

Featured

libraries modules npm angularjs state-machine

ngPromiseStatus, fsm-event

Posted on .

ngPromiseStatus

ngPromiseStatus (GitHub: BarakChamo/ng-promise-status, License: MIT, npm: ng-promise-status) by Barak Chamo is a collection of promise-aware Angular directives that make it easy to bind UI elements to the outcome of promises. This could be a button that takes an unspecified amount of time to run, that will eventually display success or failure.

You can also bind the promise values to alerts, and the author has provided Bootstrap samples that use Bootstrap's ubiquitous .alert message boxes.

fsm-event

fsm by Dominic Tarr is a very useful module for making finite state machines. I've used it with some success on a few Node projects. However, when I'm writing Node I prefer to deal with streams and events, rather than the methods in fsm's API. Yoshua Wuyts sent in fsm-event (GitHub: hyoshuawuyts/fsm-event, License: MIT, npm: fsm-event), a wrapper that uses EventEmitter.

To use it, create a new instance of fsm with the states you need, and then call m(state) to enter a given state. The corresponding listener will fire.

Why? Most state machines have overly complicated interfaces for managing state. The fsm state machine is simple but doesn't manage state for you, so I wrote a wrapper around it that manages state in an event-driven way. The initial use case was to manage complex, stateful UI elements but it can be used anywhere.

This would have actually helped with my specific use of fsm, where I ended up using it heavily alongside EventEmitter objects.

Featured

libraries node modules markdown epub npm cms

Node Roundup: npm Scopes, AkashaEPUB, mdjson

Posted on .

npm Scopes

Since npm got private modules, it has supported scopes, because private modules are resolved based on your username. However, one thing that I didn't realise was scopes are available to everyone -- you don't have to use them for private modules. That means you can reuse an existing package name, which makes sense if the package name is generic enough.

This was mentioned in this week's npm weekly post, under "solving npm’s hard problem: naming packages":

As part of the private modules rollout last week, we introduced a new free feature: scopes for packages. If you’re a registered npm user then you already have a scope, so check out the post if you want to learn how to use it.

This will be handy if you want to distribute your own fork for existing modules through npm.

AkashaEPUB

David Herron sent in AkashaEPUB (GitHub: akashacms/akashacms-epub, License: Apache 2.0, npm: akashacms-epub), a toolchain for constructing EPUB version 3 books. It allows you to write books using Markdown, and helps manage the asset files (CSS, images, fonts), and builds a correct EPUB3 file.

AkashaEPUB is built using AkashaCMS, which is a static site generator:

The goal for AkashaCMS is to provide most of the flexibility of a full scale CMS, incorporate modern JavaScript/CSS UI frameworks, while producing static HTML files, and skipping the administrative overhead of running a full CMS.

To use AkashaEPUB, you'll need Grunt and an EPUB to generate. There's a sample project and a skeleton. The following example will build the EPUB Guidebook that David Herron created:

npm install -g akashacms  
npm install -g grunt-cli  
git clone https://github.com/akashacms/epub-guide.git  
cd epub-guide  
npm install  
grunt doepub  

mdjson

mdjson (GitHub: yoshuawuyts/mdjson, License: MIT, npm: mdjson) by Yoshua Wuyts is a module for generating JSON from Markdown. The properties in the JSON are based on the headings, which means you can use it to write JavaScript objects in a more friendly manner. This works particularly well with template strings:

mdjson(`  
  This part (before any headers) is ignored. Feel free
  to use this section for commentary on the file's purpose,
  if you wish.

  ## my heading
  oh wow, amazing

  ## another heading
  gorgeous copy, stunning
`)

The output contains the original input and HTML:

{
  'my heading': {
    raw: 'oh wow, amazing',
    html: '<p>oh wow, amazing</p>'
  },

  'another heading': {
    raw: 'gorgeous copy, stunning',
    html: '<p>gorgeous copy, stunning</p>'
  }
}

I think this might be a cool way of converting Markdown to something more structured to store in a database for a CMS or static site generator.

Featured

mobile node modules npm mongo generators libraires

Orientation and Vibration APIs, Mongomery

Posted on .

Orientation and Vibration APIs for Games

Andrzej Mazur sent in an article about using the orientation and vibration APIs for game development:

The Device Orientation API specification is still in the Working Draft status, so there might be some code-breaking changes introduced in the future. It's an experimental technology and should be treated as such. All implementations are still missing the compassneedscalibration event. Also, there are differences in browser implementations which should be taken into consideration. For instance, Chrome and Opera don't support the devicemotion event.

The Vibration API is another feature that can boost the mobile experience. Most devices support it (except iOS Safari and Opera Mini), and it works great on Firefox OS devices.

I've never used the vibration API, but apparently you can access it with window.navigator.vibrate. It even supports an array of values for vibrating multiple times. Andrzej's argument is that you can use these APIs to differentiate your game from other mobile web games, and while this is true it'll take a fair bit of experimentation to get orientation-based controls working well!

Mongomery

Coderaiser has sent in a few generator-based modules recently, but I missed Mongomery (GitHub: coderaiser/node-mongomery, License: MIT, npm: mongomery), a module that uses generators for MongoDB. It uses ruff, which was Coderaiser's module for giving generators a more EventEmitter-inspired API:

var mongomery = require('mongomery');

mongomery(function*(mongo) {  
  var url = 'mongodb://localhost:27017/myproject',
  var db = yield mongo.connect(url),
  var collection = db.collection('mongolog'),
  var docs = yield collection.find({}).toArray();

  docs.forEach(function(item) {
    console.log(item);
  });

  db.close();
}).on('error', function(error) {
  console.log(error.message);
});

It'll take us a few years to really understand how new features like generators should be used in terms of databases, but I'm very interested in using generator syntax for databases.

An alternative that I've enjoyed experimenting with is Mongorito, which is more of an ODM-style API. The syntax is more succinct than Mongoose, while still remaining familiar.

Featured

hosting node modules npm desktop libraires

Free js.org Subdomains, Wallpaper

Posted on .

Free js.org Subdomains

Stefan Keim wanted to give something back to the JavaScript community, so he's started js.org -- a service that provides free subdomains for JavaScript programmers. You can host your project on GitHub, then point a js.org subdomain at it.

To claim a subdomain you need to do three things:

  1. Create your GitHub Pages-hosted site
  2. Add a CNAME file to your repository with the js.org name that you want
  3. Make a pull request to GitHub: js-org/dns that adds your CNAME to the list

Given how valuable the js.org domain is I think this is very generous of Stefan, and the GitHub-based approach is a nice idea as well.

Wallpaper

Sindre Sorhus sent in wallpaper (GitHub: sindresorhus/wallpaper, License: MIT, npm: wallpaper), a module for changing the desktop wallpaper in Mac OS X, Linux, and Windows.

It has a command-line tool (wallpaper [file]) and a Node API:

var wallpaper = require('wallpaper');

wallpaper.set('unicorn.jpg', function(err) {  
 console.log('done');
});

wallpaper.get(function(err, imagePath) {  
  console.log(imagePath);
  //=> '/Users/sindresorhus/unicorn.jpg' 
});

It would be great to combine this with a Node Canvas module that generates data-driven art, or maybe even using PhantomJS to render a webpage to recreate the joys of Active Desktop!