2011.10.25

amd-utils : modular JavaScript utilities

Last week I decided to split some of my personal JavaScript code into individual modules to provide an easy way of loading only what is really necessary and increase code reuse between multiple projects/libraries. The purpose isn’t to replace Dojo, jQuery, YUI, Mootools, etc, but to provide modular solutions for common problems that aren’t solved by most of them and to avoid using a full library when you only need a small subset of features.

The project is on github and I will keep adding new features as needed, there is still a lot of stuff to be ported from my legacy JS/PHP/AS3 code and also to be coded from scratch…
Read more…


2011.10.20

JavaScript chaining and Trainwreck.js


source images from public domain (1, 2) and edited by Miller Medeiros

Yesterday I released a piece of code that I wrote a long time ago, it’s called trainwreck.js and it’s main purpose is to provide easy method chaining.

The main reason behind it is because a lot of people don’t really understand how chaining works and end up extending jQuery or underscore.js just to be able to use chaining…

Read more…


2011.08.18

Convert YUI Test to Jasmine

I decided to port some of my old YUI Test tests to Jasmine yesterday (specifically JS-Signals and Crossroads.js tests) and realized that a big part of the process could be automated by using simple regular expressions, so I decided to create a tool to help me.

The main reason for switching from YUI Test to Jasmine was that I wanted to run the tests on node.js and also to be able to run the tests without needing an internet connection… Another reason for the switch is because I like Jasmine syntax and I think that the simple fact of describing what you want the code to do makes you think about possible edge cases.

I coded the tool very quickly just to help me on the bureaucratic process… It doesn’t do any magic but can help you to speed up the process.

You can use the tool online at: http://millermedeiros.github.com/YUI_to_Jasmine/.

Maybe it is useful to somebody else…

That’s it!


2011.08.08

Hasher: deep linking for rich-media applications

Hasher Logo

There are many available polyfills and libraries that provides deep-linking capabilities using the browser location.hash to generate a new history state. Hasher was created to do exactly the same thing but providing a cleaner API and solving a few problems present on some of the other libraries, it was also designed to make use of JS-Signals providing many advanced features like enabling/disabling the event dispatch, adding multiple listeners, etc… and to also be used together with Crossroads.js easily.

Check the README file on the project repository to understand better how does it work, why it was created, some benefits over the other solutions and also when should you favor using the HTML5 history API over location.hash to store application state and when you should avoid it.

Watch the project on Github for future updates and use the issue tracker to report bugs and ask for new features, contributors are welcome!

PS: I’ve been using Hasher for more than 1 year on a few projects but only decided to release it last week (after revising API and refactoring unit tests).

Related Posts:


2011.05.19

Crossroads.js: JavaScript Routes

The project isn’t that new anymore and was already featured on a couple places but I think I should also create a post just in case someone missed it and also to register the release.

Crossroads is basically a routing system used to map strings to functions (usually URL fragments), it acts similar to a pub/sub (event listener) but uses Regular Expressions and dynamic string patterns to identify listeners. The main feature is the robust and flexible string validation/match/parsing system.

The greatest advantage of Crossroads when compared to other similar libraries is that it is not directly tied to server requests (in case you are using it on the server-side) or to the window.location (if you are on the browser). Another important advantages are the flexibility and the support for advanced use cases, provided by different kinds of validation rules and multiple listeners to each route. – It gives you flexibility to do any kind of action you want and doesn’t do anything you don’t ask it to do.

Check the project page and examples to know more about it. It can be specially helpful for large websites and single page apps – as I mentioned on my previous post.

I hope you enjoy, contributors are welcome.