DailyJS

Krasota.js, Drink, Limit.js

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

libraries cli node

Krasota.js, Drink, Limit.js

Posted by Alex R. Young on .
Featured

libraries cli node

Krasota.js, Drink, Limit.js

Posted by Alex R. Young on .

Krasota.js

Krasota.js (GitHub: veged / krasota.js, npm: krasota) by Sergey Berezhnoy is a modular source beautifier that uses grammars written with a fork of OMeta. It can force semicolons, join or split var statements, or even remove trailing whitespace.

It can be used as a Node module, or as a command-line utility:

$ krasota -i tests/join-vars.js -b krasota/lib/beautifiers/trailing-whitespaces -b krasota/lib/beautifiers/join-vars

Custom beautifiers can also be called from the command-line by using the -b switch with a file name.

Drink

Drink (GitHub: Nijikokun / drink, License: AOL/MIT, npm: drink) by Nijiko Yonskai is a wrapper around process that helps write periodic console utilities. The API is themed around "coffee" -- not CoffeeScript, but the brewed bean beverage, which is confusing because the author's examples are written in CoffeeScript.

A session is started and potentially kept alive by passing drink a process object. Calling sip will pass data to stir without line breaks. Listeners for single character input can be added by calling onTap. The author suggests this could be used to keep any kind of session from dying, so it could be used with something like an IRC client.

Limit.js

Limit.js (GitHub: m-gagne / limit.js, License: MIT) by Marc Gagne is a reusable event debouncer. I've written similar code myself to sensibly handle certain client-side UI elements, and events like window resizing.

Marc's implementation works by extending Function.prototype. There's an example on jsFiddle that illustrates the usage: Limit.js demo.

$(document).bind('mousemove', function(e) {
    $("#debounce").children().last().text(debounceCalls++);
}.debounce(150)); // debounce with a 150 millisecond limit

$(document).bind('mousemove', function(e) {
    $("#throttle").children().last().text(throttleCalls++);
}.throttle(150)); // throttle with a 150 millisecond limit