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…
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…
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.
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).
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.
I hope you enjoy, contributors are welcome.