After having a bit of time off to wander around Thailand, and finding that — despite having lovely people, beaches, street food, temples and sea life — that the country is drowning in vehicles and unwalkable roads.. this meant there were a few days of relaxing near my laptop. So I took the time to code in the sun and do some extra work with describe.js. In doing so I notice a few problems, which I've now tried to rectify.
- Collections only worked for constructors with one method, the foolish mistake of relying on a variable referenced from within a loop.
- The 'private' tag was working based on the constructor, so each instance of a constructor was sharing the same private object. Doh!
- The 'private' methods were attached (as wanted) to the ._ object, however this meant that 'this' inside a private method refered to the _ object, rather than the constructed instance.
So, I have now repaired these issues, which should definitely speed up development in my other projects. At the same time I've also added a few extra abilities:
- Getters and Setters — two new tags exists by default, get and set. These utilise the __defineGetter__ and __defineSetter__ methods, if the browser supports them. The upshot of this is that you can now create getter and setter attributes, that also support type overloading.
- Improved support for merging or wrapping functions — This was a byproduct of the fixes. There are now the following methods: merge, unmerge, wrap and unwrap.
- Rewrote the tag/plugin handling — this was mainly to fix the private issues above, but now gives the coder a choice to implement a tag/plugin method on the constructor or on the instance (the choice is made by creating a tag function of either 3 or 4 arguments). Implemented on the constructor the prototype object is used (saving resources), implemented on the instance (all private methods use this) the methods are specifically applied to the instance's private object.
- I've worked out many of the bugs with regards to properties (before describe only concerned itself with methods). So, now it is possible to create constructors with simple base type attributes... rather silly not to be able to support this in the first place.
Before I go...
I say 0.4ish because there is one major issue that I still hope to fix before uploading the new version, this is the good old multiple inheritance system. This will be the fourth rewrite of this particular bit of code, it's complicated, but I hope to simplify things and stop trying to be so clever (mainly because clever always causes issues unless you've managed to discover perfection lying around somewhere).
I think I'm going to go the same way as a number of other libraries and just use a shallow copy system for the inheritance, rather than relying on a dynamically morphing prototype chain. The reason for this is that I seem to be using the prototype chain more and more with my work in other projects, and the current system is getting in the way. I generally don't need the power of inheritance anyway, just the power of mixins, which is what a shallow copy system would provide.
I guess what I'm saying is there will be an update shortly... so watch the skies, or something.
Oh, a few more other improvements that are in the pipe line:
- Collections don't support Getters and Setters, but they will do.
- Also, I need to work out a way of describing tag behaviour when using multiple tags. For example, currently specifying 'private get methodName' or 'private set methodName' does not create a private getter or setter. Instead it creates a private method called methodName and a public getter/setter called methodName too.
- One comment • Category: Coding, JavaScript
- Share on Twitter, Facebook, Delicious, Digg, Reddit
One comment
188bet Sign Up Offer - Bet £10 Get £50 Welcome bonus
188bet Sign Up Offer. It's a relatively 바카라 young company that still operates on top 188bet sportsbooks. Their platform is already quite popular amongst 1XBET people
by Anonymous on 23 January 2022 at 07:10. #