2009-08-10

realStorage 1.1.0 is out

Taking the "release early, release often" mantra almost too seriously, I have now released realStorage 1.1.0 a day after 1.0.0 came out. This new version adds two convenience functions: 'contains' and keysArray.

I added contains() to help prevent people from making the mistake of trying to test for key existence with != instead of !==. Since values are coerced to strings it would mean checking for key existence with realStorage.getItem(key) != null would succeed if the value for a key was null. But if you use !== you will never get an incorrect result as setting a value of null will always lead to "null" being returned.

I added keysArray() because I needed a way to loop through all keys in the store while being able to delete or add keys in a loop. Using realStorage.length and realStorage.key() to loop through keys only works if you don't add/remove keys as key() is only stable as long as all key names are stable. By creating an array of all keys this solves the problem.

This brings realStorage up to parity with my code that I forked it from. Looking at my personal needs, the only thing of great consequence is adding getJSON()/setJSON() so as to simplify my own code. After that I have some interest to get a Gears back-end working, especially if Gears in Chromium on OS X starts working before localStorage does.