Web Design Forum: I've started writing a JavaScript library. - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
-----
I haven't written one before, but it seems like the cool thing to do, so I've started. My library is designed to add the ES5 methods to all browsers that don't understand them. It's also supposed to be easy to expand and modify so anyone can add their own methods. At the moment it will only work on standard JavaScript types (string, object, number, date etc., although I've only built support for arrays so far) but it's easy to add the ability to manipulate DOM nodes or specific types of object differently.

It all runs out of the same namespace so it barely touches the global object (and let's face it, who's going to make a variable or function called "SK80"?) and acts as a wrapper to enable all the new methods.

Here's an example of how the library works:
// .map and .every were defined in the ES5 specs as Array methods.
// Unlike simply calling them on an array, putting that array through SK80
// will guarentee that it works in all browsers.
SK80([1, 2, 3]).unshift(4).map(function (no) {
    return no * 2;
}).every(function (no) {
    return no > 1;
});

The SK80 wrapper knows all the standard methods for the object too and even fixes support for unshift. Although arrays are all it can handle so far, it shows how it can be used for all objects.

I've signed up to Github and I've uploaded the library there, such as it is. You can find it at Gitbub.com/Skateside/SK80-library and I'll do my best to remember to keep it up-to-date with the latest developments. I've also built a test page to check that everything works the way it should: sk80.co.uk/library. At the moment, that page should show green across the board with 2 errors near the top. This is how it should be working. I've managed to get consistent results in the following browsers on a PC:
  • Chrome 13
  • Firefox 4
  • Opera 11
  • Safari 5
  • Internet Explorer 6 - 8

but I have a small favour to ask: The browser list above are the only ones I have. If you have any others, would you be able to go to my testing page and check that the results are the same, please? If you spot anything off, let me know and I'll fix it. If everything's fine, let me know as well and I'll update the working list.

You're more than welcome to use this library as it is if you like, I'll try not to change it too much. When I've got support built in for the major object types I'll upgrade it to beta and unleash it on the world.
0
 

0 Comments On This Entry

Recent Entries

Recent Comments

May 2012

S M T W T F S
  12345
6789101112
13141516 17 1819
20212223242526
2728293031