The JavaScript blog.


libraries surveys modules assert

Survey Closed, Predicates, Shackles

Posted on .

Survey Closed

The JavaScript Developer Survey 2014 has now closed. I received some updates for the survey to the GitHub repository, so you should see those the next time I run it. Thanks for the contributions!

I'll work on writing up the results and post again when they're ready.


Predicates (GitHub: wookieb/predicates, License: MIT, npm: predicates) by Łukasz Kużyński is a set of tools for type checking and assertions. For example:

var is = require('predicates');

is.string(1); // false  
is.string('test'); // true  
is.undefinedOr(is.string, undefined); // true  

Assertions look like this:

var assertName = createAssert(is.string, 'Name must be a string');

var Person = function(name, surname, age) {  

new Person('Tom', 'Welling', 33); // OK!  

The Predicates API guide has a list of each available method, and there's also an interesting API design document that provides some background to the project.


Shackles (GitHub: metaraine/shackles, License: ISC, npm: shackles) by Raine Lourie is a module for adding chaining to another library. Imagine if Underscore didn't support chaining. You could use Shackles to create a fluent API, like this:

var chain = shackles(_);

var result = chain([1,2,3])  
  .map(function (x) { return x*x })
  .filter(function (x) { return x > 2 })
  .value(); // [4,9]

You can insert values at any point in the chain with tap, and there's also a log method that prints values with console. Logging can be overridden as well.