DailyJS

Node Roundup: Node 0.12.1, io.js 1.6.2, DIY, Typescript-Deferred

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

libraries node modules npm build iojs

Node Roundup: Node 0.12.1, io.js 1.6.2, DIY, Typescript-Deferred

Posted by Alex R. Young on .
Featured

libraries node modules npm build iojs

Node Roundup: Node 0.12.1, io.js 1.6.2, DIY, Typescript-Deferred

Posted by Alex R. Young on .

Node 0.12.1

Yesterday Node 0.12.1 was released. It has OpenSSL fixes for security vulnerabilities that include a DoS. Two fixes are ranked as high, and nine are marked as moderate.

io.js just hit version 1.6.2. The recent io.js releases have had tls and http fixes, but there are other very interesting changes if you dig into the changelog. For example, the Node binary can now be invoked with a list of modules to preload:

iojs -r foo -r /bar/baz.js -r quux  

This is equivalent to:

require('foo');  
require('/bar/baz.js');  
require('quux');  

The reason I like this is it means environment-specific modules can be loaded without changing your code. You could use this to load modules that instrument the runtime with debugging and logging functionality.

The npm blog (yet again) has a useful post for client-side developers: Using Angular's new improved Browserify support:

With the recent release 1.3.14 instantaneous-browserification, Angular introduced better support for those using Browserify. Thank you to everyone who worked on that issue, and especially to Ben Clinkinbeard for his unflagging dedication in getting it in.

I prefer reading AngularJS code with CommonJS modules, so it would be cool to see AngularJS module maintainers using Browserify for modules on npm.

DIY: JavaScript that Compiles to a Makefile

DIY

I've used Gulp and Grunt to manage client-side builds, but as someone who used to write makefiles I'll admit to wishing everyone just used make. Well, now maybe we can, with Vittorio Zaccaria's DIY (GitHub: vzaccaria/diy, License: BSD, npm: diy).

Here's a sample configuration file:

generateProject(_ => {  
  _.collectSeq("all", _ => {
    _.collect("build", _ => {
      /* specify how to build files */
    })
    _.collect("deploy", _ => {
      /* specify how to deploy files */
    }
  })
})

DIY is a DSL for describing build processes. The generateProject function is used to wrap calls to various methods that describe build steps. The final makefile is generated by using babel, so you just have to type babel configure.js | node. Once you've got a makefile you can invoke the targets that were defined by calls to the collect method.

This module gets top marks for using Babel and for generating something that's friendly for Unix grumps like me.

Typescript-Deferred

What if you want TypeScript-friendly promises? Typescript-Deferred (GitHub: DirtyHairy/typescript-deferred, License: MIT, npm: typescript-deferred) by Christian Speckner is a Promises/A+ implementation written in TypeScript. The author says nobody needs another promises implementation, but this implementation is pretty cool: it has no dependencies, and fully implements the specification.

If, like me, you're a TypeScript tourist, then here's what strongly typed promises look like:

// A promise for a number that resolves to 10
var promise: tsd.PromiseInterface<number> =  
    tsd.when<number>(10);

// A promise that adopts the state of some other thenable that wraps a value
// of type sometype
var promise: tsd.PromiseInterface<number> =  
    tsd.when<sometype>(someThenable);

Christian suggests that this will be useful if you want to embed a small promises implementation into your own libraries.