DailyJS

DailyJS

The JavaScript blog.


Tagcalendar
Featured

testing node dom modules calendar

Prüfer, Calendar Base

Posted on .

Prüfer

Johnathan Leppert wanted a way to generate complex DOM structures for UI performance testing. He decided to use the Prüfer sequence, and created a Node module that can generate random trees of data (GitHub: jleppert/prufer, License: MIT).

Here's an example of the usage:

var prufer = require('prufer');

// to make a tree, supply a series of integers
var tree = prufer([3, 3, 3, 4]);

// you'll get back an array of edges
console.log(tree);  

I thought the Prüfer sequence sounded like a cool way to do this -- it might be useful for lots of Node-related stream tools.

Calendar Base

Wesley de Souza sent in a module for generating calendars as arrays of objects. The module is called Calendar Base (GitHub: WesleydeSouza/calendar-base, License: MIT, npm: calendar-base). To use it, you just need to instantiate a new calendar:

var cal = new Calendar({ siblingMonths: true });  
cal.getCalendar(2015, 5);  

The arrays it generates have objects like this: { day: 31, weekDay: 0, month: 4, year: 2015, siblingMonth: true }. It also has methods for changing the start date, and selecting the current date.

It reminds me of typing cal in Unix, which is still how I use calendars instead of using a fancy desktop application...