I think it's important not to load up on too many esoteric tricks or the code base becomes expensive to maintain (time/money).
I'm more inclined to build a small toolkit for common transforms like this at the point of usage.
Now seriously, is this running in the client or in the server?