Packery, Gumba, watch-array

29 Apr 2013 | By Alex Young | Tags browser libraries ui arrays events

Packery

Packery

Victor sent in Packery (GitHub: metafizzy / packery, License: MIT/Commercial, bower: packery) from Metafizzy, which is a bin packing library. It organises elements to fit around the space available. Certain elements can be “stamped” into a specific position, fit an ideal spot, or be draggable.

Packery can be configured in JavaScript using the Packery constructor function, or purely in HTML using a class and data attributes. jQuery is not required, but the project does have some dependencies, so the authors recommend installation with Bower.

The project can be used under the MIT license, but commercial projects require a license that starts at $25.

Gumba

Gumba (GitHub: welldan97 / gumba, License: MIT, npm: gumba) by Dmitry Yakimov is CoffeeScript for the command-line:

$ echo '1234567' | gumba 'toNumber().numberFormat()'
1,234,567

It’s a bit like Awk or sed, but for the chainable text operations supported by CoffeeScript and Underscore.string.

watch-array

watch-array (GitHub: azer / watch-array, License: BSD, npm: watch-array) by Azer Ko├žulu causes arrays to emit events when mutator methods are used. Usage is simple – just call watchArray on an array, and pass it a callback that will be triggered when the array changes:

var watchArray = require('watch-array');
var people = ['Joe', 'Smith'];

watchArray(people, function(update) {
  console.log(update.add);
  // => { 1: Taylor, 2: Brown }

  console.log(update.remove);
  // => [0]
});

people.shift();
people.push('Taylor', 'Brown');

In a way this is like a micro version of what data binding frameworks implement. The author has included tests written with his fox test framework.


blog comments powered by Disqus