esformatter & rocambole

Yesterday I pushed 2 new projects to github, was unsure if I was going to do it since maintaining opensource projects can demand a lot of time but heck, I’m looking for contributors and they can be useful to more people, so why not?

I used editors/IDEs that had a good code formatter for a while and ever since I started doing more JavaScript development I missed a code formatter as powerful/flexible as FDT. I know WebStorm has a very good support for JavaScript but nowadays I’m a Vim user and it’s really hard to make the switch. I wish I could have the same amount of settings on a command-line tool, that way it could be hooked into multiple text editors (Vim, Emacs, SublimeText, Cloud9, etc…), have an external configuration file (so it could be shared between team members) and used to batch-process files. Being written in JavaScript would also be a plus (so it could be used inside the browser and have more contributors).

Read more…


Why I favor while loops

I remember that my first contact with programming loops was through the for statement and I used it almost exclusively for many years. I’ll explain why I’ve been favoring while loops over for loops in the past couple years. Beware that this is only my personal preference and the reasoning behind it are very subjective. Use what works better for you.

TL;DR: while is less verbose and more clear in many cases.

Read more…


nodefy: convert AMD modules to node.js

I’ve been using amd-utils on almost all my projects and sometimes I find myself wanting to use some of the methods on my node.js programs as well, so I decided to write a tool to convert the modules automatically.

The tool uses Esprima internally so it will keep the indentation, comments and it should work as long as the code can be parsed by Esprima. It will do as few replacements as possible to avoid undesired side effects.

Check the project repository for more info and please use the issue tracker for feature requests, bug reports and questions/feedback.



Avoiding the this keyword on jQuery related code

jQuery implements some nice abstractions for DOM manipulation and browser events, removing a lot of crossbrowser issues and making it easier to accomplish non-trivial tasks. - it also has drawbacks and some poor design decisions, but I will leave that for another post. Maybe one day I will write my jQuery 2.0 wishlist… - Today I will explain why I usually avoid using the magic this keyword inside event handlers and inside most methods that manipulates jQuery collections.

Read more…


Node.js Protip: Avoid Global Test Runners

Some of the most popular Node.js test frameworks advertise that they should be installed globally: Jasmine, Mocha, Buster.js, etc… I consider this an anti-pattern.

On this post I will try to explain why it’s an anti-pattern and show how to avoid global installs by using npm test instead.

Read more…