These are the problems that I’ve tried to solve:
- Inconsistent enumeration across platforms
instanceofdoesn’t always work
typeofis inconsistent (RegExps identify as type “function” in Mozilla browsers)
- Consistent object/platform detection
- Other various bugs
And the sugar:
- A mechanism for inheritance
- A decent hash object
- Array and String generics
- Array extras
- Support for ISO date parsing
Here is a brief outline of the base2 API. In subsequent blog posts I’ll drill into specific classes and functions in more detail.
- The base class for inheritance. Based on my old Base class.
- A hash class. Based on ES4’s Map.
- A Map that is more array-like. Items may be referenced by index as well by key.
- A Collection of regular expressions and their associated replacement values. For building powerful parsers.
- A mechanism for grouping functions that operate on particular types of object. I will explain this in more detail in a later blog post.
- A mechanism for grouping functions and classes. base2.DOM is an example of a Package. I will provide an overview of this class in a later blog post.
- A Module that defines useful methods for enumeration (
I won’t bother to describe the functions here you can read the online documentation for more information. Hopefully, you can guess what most of the functions do. I will explain some of them in more detail in a later blog post.
assignID, detect, Undefined, Null, True, False
http://base2.googlecode.com/svn/version/1.0(beta2)/src/base2.js (source code)
As previously mentioned, I intend to showcase some of the features of base2 in individual blog posts. Stay tuned.