I rearranged the order of the methods and properties in this definition, to be consistent with the original JS code.