Blanket.js, xsdurationjs, attr

2012-11-23 00:00:00 +0000 by Alex R. Young


Blanket and QUnit

Blanket.js (GitHub: Migrii / blanket, License: MIT, npm: blanket) by Alex Seville is a code coverage library tailored for Mocha and QUnit, although it should work elsewhere. Blanket wraps around code that requires coverage, and this can be done by applying a data-cover attribute to script tags, or by passing it a path, regular expression, or array of paths in Node.

It actually parses and instruments code using uglify-js, and portions of Esprima and James Halliday's falafel library.

The author has prepared an example test suite that you can run in a browser: backbone-koans-qunit. Check the "Enable coverage" box, and it will run through the test suite using Blanket.js.


xsdurationjs (License: MIT, npm: xsdurationjs) by Pedro Narciso GarcĂ­a Revington is an implementation of Adding durations to dateTimes from the W3C Recommendation XML Schema Part 2. By passing it a duration and a date, it will return a new date by evaluating the duration expression.

The duration expressions are ISO 8601 durations -- these can be quite short like P5M, or contain year, month, day, and time:

For example, "P3Y6M4DT12H30M5S" represents a duration of "three years, six months, four days, twelve hours, thirty minutes, and five seconds".

The project includes Vows tests that include coverage for the W3C functions (fQuotient and modulo).


attr (License: MIT) by Jonah Fox is a component for "evented attributes with automatic dependencies." Once an attribute has been created with attr('name'), it will emit events when the value changes. Convenience methods are also available for toggling boolean values and getting the last value.

It's designed to be used in browsers, and comes with Mocha tests.